3b7393667d04cd2ac079d5313c4190e644175916
[dragonfly.git] / Makefile.inc1
1 #
2 # $FreeBSD: src/Makefile.inc1,v 1.141.2.62 2003/04/06 19:54:00 dwmalone Exp $
3 #
4 # Build-time options are documented in make.conf(5).
5 #
6 # The intended user-driven targets are:
7 #
8 # buildworld  - rebuild *everything*, including glue to help do upgrades
9 # quickworld  - skip the glue and do a depend+build on the meat
10 # realquickworld - skip the glue and depend stages and just build the meat
11 # crossworld  - only build the glue (particularly the cross-build environment)
12 # installworld- install everything built by "buildworld"
13 # backupworld - copies /bin /sbin /usr/bin /usr/sbin /usr/lib /usr/libexec
14 #               to manual backup dir
15 # restoreworld- installs binaries from manual backup dir to world
16 # restoreworld-auto - installs binaries from auto-backup dir to world
17 # most        - build user commands, no libraries or include files
18 # installmost - install user commands, no libraries or include files
19 # backup-clean - delete backup from manual backup dir
20 # backup-auto-clean - delete backup from auto-backup dir
21 #
22 # Standard targets (not defined here) are documented in the makefiles in
23 # /usr/share/mk.  These include:
24 #               obj depend all install clean cleandepend cleanobj
25
26 # Put initial settings here.
27 SUBDIR=
28
29 # We must do share/info early so that installation of info `dir'
30 # entries works correctly.  Do it first since it is less likely to
31 # grow dependencies on include and lib than vice versa.
32 .if exists(${.CURDIR}/share/info)
33 SUBDIR+= share/info
34 .endif
35
36 # We must do include and lib early so that the perl *.ph generation
37 # works correctly as it uses the header files installed by this.
38 .if exists(${.CURDIR}/include)
39 SUBDIR+= include
40 .endif
41 .if exists(${.CURDIR}/lib)
42 SUBDIR+= lib
43 .endif
44 # This exists simply to ensure that the obj dir hierarchy is
45 # intact for nrelease, allowing the nrelease Makefile's to 
46 # reference ${.OBJDIR}.
47 #
48 .if exists(${.CURDIR}/nrelease)
49 SUBDIR+= nrelease
50 .endif
51
52 .if exists(${.CURDIR}/bin)
53 SUBDIR+= bin
54 .endif
55 .if exists(${.CURDIR}/games) && !defined(NO_GAMES)
56 SUBDIR+= games
57 .endif
58 .if exists(${.CURDIR}/gnu)
59 SUBDIR+= gnu
60 .endif
61 .if exists(${.CURDIR}/libexec)
62 SUBDIR+= libexec
63 .endif
64 .if exists(${.CURDIR}/sbin)
65 SUBDIR+= sbin
66 .endif
67 .if exists(${.CURDIR}/secure) && !defined(NO_CRYPT)
68 SUBDIR+= secure
69 .endif
70 .if exists(${.CURDIR}/share) && !defined(NO_SHARE)
71 SUBDIR+= share
72 .endif
73 .if exists(${.CURDIR}/sys)
74 SUBDIR+= sys
75 .endif
76 .if exists(${.CURDIR}/usr.bin)
77 SUBDIR+= usr.bin
78 .endif
79 .if exists(${.CURDIR}/usr.sbin)
80 SUBDIR+= usr.sbin
81 .endif
82
83 .if exists(${.CURDIR}/etc)
84 SUBDIR+= etc
85 .endif
86
87 # These are last, since it is nice to at least get the base system
88 # rebuilt before you do them.
89 .if defined(LOCAL_DIRS)
90 .for _DIR in ${LOCAL_DIRS}
91 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
92 SUBDIR+= ${_DIR}
93 .endif
94 .endfor
95 .endif
96
97 .if defined(SUBDIR_OVERRIDE)
98 SUBDIR=         ${SUBDIR_OVERRIDE}
99 .endif
100
101 .if defined(NOCLEANDIR)
102 CLEANDIR=       clean cleandepend
103 .else
104 CLEANDIR=       cleandir
105 .endif
106
107 .if defined(NO_CLEAN)
108 NOCLEAN=        # defined
109 .endif
110
111 # Object directory base in primary make.  Note that when we rerun make
112 # from inside this file we change MAKEOBJDIRPREFIX to the appropriate
113 # subdirectory because the rest of the build system needs it that way.
114 # The original object directory base is saved in OBJTREE.
115 #
116 MAKEOBJDIRPREFIX?=      /usr/obj
117 OBJTREE?=               ${MAKEOBJDIRPREFIX}
118
119 # Used for stage installs and pathing
120 #
121 DESTDIRBASE:=           ${OBJTREE}${.CURDIR}
122
123 # Remove DESTDIR from MAKEFLAGS.  It is present in the environment
124 # anyhow, and we need to be able to override it for stage installs
125 .MAKEFLAGS:=    ${.MAKEFLAGS:NDESTDIR=*}
126
127 # This section sets the tools used to build the world/kernel
128 WORLD_CCVER?=           gcc47
129 WORLD_LDVER?=           ld.bfd
130 WORLD_BINUTILSVER?=     binutils224
131
132 # Set the backup parameters if they are not already defined
133 #
134 WORLD_BACKUP?=          /var/backups/world_backup
135 AUTO_BACKUP?=           ${OBJTREE}/world_backup/${DESTDIR}
136
137 TARGET_ARCH?=   ${MACHINE_ARCH}
138 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
139 TARGET?=        ${MACHINE}
140 .else
141 TARGET?=        ${TARGET_ARCH}
142 .endif
143 .if make(buildworld)
144 BUILD_ARCH!=    sysctl -n hw.machine_arch
145
146 # temporary until everybody has converted to x86_64
147 .if ${BUILD_ARCH} == "amd64"
148 BUILD_ARCH=     x86_64
149 .endif
150
151 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
152 .error To cross-build, set TARGET_ARCH.
153 .endif
154 .endif
155
156 # Backwards compatibility with older make's or older sys.mk's.  make
157 # is expected to define MACHINE_PLATFORM.
158 #
159 .if !defined(MACHINE_PLATFORM)
160 MACHINE_PLATFORM= pc32
161 .endif
162
163 # XXX this is ugly and we need to come up with a nicer solution
164 .if !defined(TARGET_PLATFORM)
165 .if ${TARGET_ARCH} == "i386"
166 TARGET_PLATFORM= pc32
167 .elif ${TARGET_ARCH} == "x86_64"
168 TARGET_PLATFORM= pc64
169 .else
170 .error Unknown target architecture.
171 .endif
172 .endif
173
174 THREAD_LIB?=    thread_xu
175 .if ${THREAD_LIB} == "c_r"
176 .if defined(NO_LIBC_R)
177 .error libc_r is chosen as the default thread library, but NO_LIBC_R is defined
178 .endif
179 .endif
180
181 # BTOOLS        (Natively built) All non-cross-development tools that the
182 #               main build needs.  This includes things like 'mkdir' and 'rm'.
183 #               We will not use the native system's exec path once we start
184 #               on WORLD.  (bootstrap-tools and build-tools or BTOOLS)
185 #
186 # CTOOLS        (Natively built) Cross development tools which are specific
187 #               to the target architecture.
188 #
189 # WORLD         (Cross built) Our ultimate buildworld, using only BTOOLS and
190 #               CTOOLS.
191 #
192 # MACHINE_PLATFORM Platform Architecture we are building on
193 # MACHINE       Machine Architecture (usually the same as MACHINE_ARCH)
194 # MACHINE_ARCH  Cpu Architecture we are building on
195 #
196 # TARGET_PLATFORM Platform Architecture we are building for
197 # TARGET        Machine Architecture we are building for
198 # TARGET_ARCH   Cpu Architecture we are building for
199 #
200 BTOOLSDEST=     ${DESTDIRBASE}/btools_${MACHINE_ARCH}
201 CTOOLSDEST=     ${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH}
202 WORLDDEST=      ${DESTDIRBASE}/world_${TARGET_ARCH}
203
204 # The bootstrap-tools path is used by the bootstrap-tools, build-tools, and
205 # cross-tools stages to augment the existing command path to access newer
206 # versions of certain utilities such as 'patch' that the cross-tools stage
207 # might expect.
208 #
209 BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
210
211 # The strict temporary command path contains all binaries required
212 # by the buildworld system after the cross-tools stage.
213 #
214 STRICTTMPPATH=  ${CTOOLSDEST}/usr/sbin:${CTOOLSDEST}/usr/bin:${CTOOLSDEST}/bin:${CTOOLSDEST}/usr/games:${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games:/usr/local/bin:/usr/pkg/bin
215
216 TMPDIR?=        /tmp
217 TMPPID!=        echo $$$$
218
219 #
220 # Building a world goes through the following stages
221 #
222 # 1. bootstrap-tool stage [BMAKE]
223 #       This stage is responsible for creating programs that
224 #       are needed for backward compatibility reasons. They
225 #       are not built as cross-tools.
226 # 2. build-tool stage [TMAKE]
227 #       This stage is responsible for creating the object
228 #       tree and building any tools that are needed during
229 #       the build process.
230 # 3. cross-tool stage [XMAKE]
231 #       This stage is responsible for creating any tools that
232 #       are needed for cross-builds. A cross-compiler is one
233 #       of them.
234 # 4. world stage [WMAKE]
235 #       This stage actually builds the world.
236 # 5. install stage (optional) [IMAKE]
237 #       This stage installs a previously built world.
238 #
239 # In all cases we must carefully adjust the environment so the proper
240 # tools and header files are used.
241 #
242 # NOTE: The M4 environment variable is used by the [f]lex binary to
243 #       override the location of the 'm4' binary.  The override is
244 #       needed for certain buildworld version transitions, specifically
245 #       past a certain point in 3.3 because the older /usr/bin/m4 will
246 #       generate output that will blow up the newer [f]lex/yacc/bison
247 #       utilities.
248 #
249
250 # bootstrap-tool stage
251 #
252 BMAKEENV=       MAKEOBJDIRPREFIX=${BTOOLSDEST} \
253                 OBJTREE=${OBJTREE} \
254                 DESTDIR=${BTOOLSDEST} \
255                 PATH=${BTOOLSPATH}:${PATH} \
256                 M4=${BTOOLSDEST}/usr/bin/m4 \
257                 INSTALL="sh ${.CURDIR}/tools/install.sh"
258
259 BMAKE=          ${BMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
260                 -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
261                 -DNO_WERROR -DNO_NLS
262
263 # build-tool stage
264 #
265 TMAKEENV=       MAKEOBJDIRPREFIX=${BTOOLSDEST} \
266                 OBJTREE=${OBJTREE} \
267                 DESTDIR= \
268                 PATH=${BTOOLSPATH}:${PATH} \
269                 M4=${BTOOLSDEST}/usr/bin/m4 \
270                 INSTALL="sh ${.CURDIR}/tools/install.sh"
271
272 TMAKE=          ${TMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
273                 -DNO_FORTRAN -DNOSHARED
274
275 # cross-tool stage
276 #
277 # note: TOOLS_PREFIX points to the obj root holding the cross
278 #       compiler binaries, while USRDATA_PREFIX points to the obj root 
279 #       holding the target environment (and also determines where cross-built
280 #       libraries, crt*.o, and include files are installed).
281 #
282 XMAKEENV=       MAKEOBJDIRPREFIX=${CTOOLSDEST} \
283                 OBJTREE=${OBJTREE} \
284                 DESTDIR=${CTOOLSDEST} \
285                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
286                 TOOLS_PREFIX=${CTOOLSDEST} \
287                 USRDATA_PREFIX=${WORLDDEST} \
288                 M4=${BTOOLSDEST}/usr/bin/m4 \
289                 PATH=${BTOOLSPATH}:${PATH}
290
291 XMAKE=          ${XMAKEENV} make -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
292                 -DBOOTSTRAPPING -DNOSHARED
293
294 # world stage, note the strict path and note that TOOLS_PREFIX is left
295 # unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
296 # which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
297 # for both binary and library paths, even though it is being compiled to
298 # WORLDDEST.  None of the programs in the world stage are ever actually
299 # executed during the buildworld/installworld.
300 #
301 CROSSENV=       MAKEOBJDIRPREFIX=${WORLDDEST} \
302                 OBJTREE=${OBJTREE} \
303                 MACHINE_ARCH=${TARGET_ARCH} \
304                 MACHINE=${TARGET} \
305                 MACHINE_PLATFORM=${TARGET_PLATFORM} \
306                 OBJFORMAT_PATH=${CTOOLSDEST} \
307                 HOST_CCVER=${HOST_CCVER} \
308                 CCVER=${WORLD_CCVER} \
309                 LDVER=${WORLD_LDVER} \
310                 BINUTILSVER=${WORLD_BINUTILSVER}
311
312 WMAKEENV=       ${CROSSENV} \
313                 DESTDIR=${WORLDDEST} \
314                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
315                 M4=${BTOOLSDEST}/usr/bin/m4 \
316                 PATH=${STRICTTMPPATH}
317
318 WMAKE=          ${WMAKEENV} make -f Makefile.inc1
319
320 # install stage
321 #
322 IMAKEENV=       ${CROSSENV} \
323                 PATH=${STRICTTMPPATH}
324 IMAKE=          ${IMAKEENV} make -f Makefile.inc1
325
326 # kernel stage
327 #
328 KMAKEENV=       ${WMAKEENV}
329
330 # buildworld
331 #
332 # Attempt to rebuild the entire system, with reasonable chance of
333 # success, regardless of how old your existing system is.
334 #
335 _worldtmp: _cleantmp _mtreetmp
336 .ORDER: _cleantmp _mtreetmp
337
338 _cleantmp:
339         @echo
340         @echo "--------------------------------------------------------------"
341         @echo ">>> Rebuilding the temporary build tree"
342         @echo "--------------------------------------------------------------"
343 .if !defined(NOCLEAN)
344         rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
345 .else
346         # XXX - These two can depend on any header file.
347         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
348         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
349 .endif
350
351 _mtreetmp:
352         mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
353 .for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
354         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist        \
355                 -p ${_dir}/  > /dev/null
356         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist         \
357                 -p ${_dir}/usr > /dev/null
358 .endfor
359         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist     \
360                 -p ${WORLDDEST}/usr/include > /dev/null
361         ${LN} -sf ${.CURDIR}/sys ${WORLDDEST}
362
363 _bootstrap-tools:
364         @echo
365         @echo "--------------------------------------------------------------"
366         @echo ">>> stage 1: bootstrap tools"
367         @echo "--------------------------------------------------------------"
368         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
369 _cleanobj:
370         @echo
371         @echo "--------------------------------------------------------------"
372         @echo ">>> stage 2a: cleaning up the object tree"
373         @echo "--------------------------------------------------------------"
374         cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
375 _obj:
376         @echo
377         @echo "--------------------------------------------------------------"
378         @echo ">>> stage 2b: rebuilding the object tree"
379         @echo "--------------------------------------------------------------"
380         cd ${.CURDIR}; ${WMAKE} par-obj
381 _build-tools:
382         @echo
383         @echo "--------------------------------------------------------------"
384         @echo ">>> stage 2c: build tools"
385         @echo "--------------------------------------------------------------"
386         cd ${.CURDIR}; ${TMAKE} build-tools
387 _cross-tools:
388         @echo
389         @echo "--------------------------------------------------------------"
390         @echo ">>> stage 3: cross tools"
391         @echo "--------------------------------------------------------------"
392         cd ${.CURDIR}; ${XMAKE} cross-tools
393 _includes:
394         @echo
395         @echo "--------------------------------------------------------------"
396         @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
397         @echo "--------------------------------------------------------------"
398         cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
399 _libraries:
400         @echo
401         @echo "--------------------------------------------------------------"
402         @echo ">>> stage 4b: building libraries"
403         @echo "--------------------------------------------------------------"
404         cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
405 _depend:
406         @echo
407         @echo "--------------------------------------------------------------"
408         @echo ">>> stage 4c: make dependencies"
409         @echo "--------------------------------------------------------------"
410         cd ${.CURDIR}; ${WMAKE} par-depend
411 everything:
412         @echo
413         @echo "--------------------------------------------------------------"
414         @echo ">>> stage 4d: building everything.."
415         @echo "--------------------------------------------------------------"
416         cd ${.CURDIR}; ${WMAKE} all
417
418 # note: buildworld no longer depends on _cleanobj because we rm -rf the
419 # entire object tree and built the bootstrap tools in a different location.
420 #
421 # buildworld    - build everything from scratch
422 # quickworld    - skip the bootstrap, build, and cross-build steps
423 # realquickworld - skip the bootstrap, build, crossbuild, and depend step.
424 #
425 # note: we include _obj in realquickworld to prevent accidental creation
426 # of files in /usr/src.
427
428 WMAKE_TGTS=
429 .if !defined(SUBDIR_OVERRIDE)
430 WMAKE_TGTS+=    _worldtmp _bootstrap-tools
431 .endif
432 WMAKE_TGTS+=    _obj _build-tools
433 .if !defined(SUBDIR_OVERRIDE)
434 WMAKE_TGTS+=    _cross-tools
435 .endif
436 WMAKE_TGTS+=    _includes _libraries _depend everything
437
438 buildworld: ${WMAKE_TGTS}
439
440 quickworld: _mtreetmp _obj _includes _libraries _depend everything
441
442 realquickworld: _mtreetmp _obj _includes _libraries everything
443
444 crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
445
446 .ORDER: ${WMAKE_TGTS}
447 .ORDER: _obj _includes
448 .ORDER: _mtreetmp _obj
449 .ORDER: installcheck backupworld-auto
450
451 #
452 # installcheck
453 #
454 # Checks to be sure system is ready for installworld
455 #
456 installcheck:
457 .if !defined(NO_SENDMAIL)
458         @pw usershow smmsp || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
459         @pw groupshow smmsp || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
460 .endif
461         @pw usershow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
462         @pw groupshow authpf || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
463         @pw groupshow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
464 .if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/"
465         @case `uname -r` in 1.2*|1.3-*|1.3.*|1.4.*|1.5.0-*|1.5.1-*|1.5.2-*|1.5.3-*) echo "You must upgrade your kernel to at least 1.5.4 and reboot before you can safely installworld, due to libc/system call ABI changes" ; /usr/bin/false ; esac
466 .endif
467 #
468 # installworld
469 #
470 # Installs everything compiled by a 'buildworld'.
471 #
472 installworld: installcheck backupworld-auto
473         cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
474         ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc ${DESTDIR}/etc/upgrade/
475         mkinitrd
476
477 #
478 # reinstall
479 #
480 # If you have a build server, you can NFS mount the source and obj directories
481 # and do a 'make reinstall' on the *client* to install new binaries from the
482 # most recent server build.
483 #
484 reinstall:
485         @echo "--------------------------------------------------------------"
486         @echo ">>> Making hierarchy"
487         @echo "--------------------------------------------------------------"
488         cd ${.CURDIR}; make -f Makefile.inc1 hierarchy
489         @echo
490         @echo "--------------------------------------------------------------"
491         @echo ">>> Installing everything.."
492         @echo "--------------------------------------------------------------"
493         cd ${.CURDIR}; make -f Makefile.inc1 install
494
495 #
496 # buildkernel, nativekernel, quickkernel, and installkernel
497 #
498 # Which kernels to build and/or install is specified by setting
499 # KERNCONF. If not defined a GENERIC kernel is built/installed.
500 # Only the existing (depending TARGET) config files are used
501 # for building kernels and only the first of these is designated
502 # as the one being installed.
503 #
504 # You can specify INSTALLSTRIPPED=1 if you wish the installed 
505 # kernel and modules to be stripped of its debug info (required
506 # symbols are left intact).  You can specify INSTALLSTRIPPEDMODULES
507 # if you only want to strip the modules of their debug info.  These
508 # only apply if you have DEBUG=-g in your kernel config or make line.
509 #
510 # Note that we have to use TARGET instead of TARGET_ARCH when
511 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
512 # be set to cross-build, we have to make sure TARGET is set
513 # properly.
514
515 .if !defined(KERNCONF) && defined(KERNEL)
516 KERNCONF=       ${KERNEL}
517 KERNWARN=       yes
518 .else
519 # XXX makeshift fix to build the right kernel for the (target) architecture
520 # We should configure this in the platform files somehow
521 .if ${TARGET_ARCH} == "i386"
522 KERNCONF?=      GENERIC
523 .else
524 KERNCONF?=      X86_64_GENERIC
525 .endif
526 .endif
527 INSTKERNNAME?=  kernel
528
529 KRNLSRCDIR=     ${.CURDIR}/sys
530 KRNLCONFDIR=    ${KRNLSRCDIR}/config
531 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
532 KERNCONFDIR?=   ${KRNLCONFDIR}
533
534 BUILDKERNELS=
535 INSTALLKERNEL=
536 .for _kernel in ${KERNCONF}
537 .if exists(${KERNCONFDIR}/${_kernel})
538 BUILDKERNELS+=  ${_kernel}
539 .if empty(INSTALLKERNEL)
540 INSTALLKERNEL= ${_kernel}
541 .endif
542 .endif
543 .endfor
544
545 # kernel version numbers survive rm -rf
546 #
547 .for _kernel in ${BUILDKERNELS}
548 .if exists(${KRNLOBJDIR}/${_kernel}/version)
549 KERNEL_VERSION_${_kernel} != cat ${KRNLOBJDIR}/${_kernel}/version
550 .endif
551 .endfor
552
553 #
554 # buildkernel
555 #
556 # Builds all kernels defined by BUILDKERNELS.
557 #
558 bk_tools:
559         @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
560             echo "You must buildworld before buildkernel.  If you wish"; \
561             echo "to build a kernel using native tools, config it manually"; \
562             echo "or use the nativekernel target if you are in a rush"; \
563             /usr/bin/false; \
564         fi
565
566 maybe_bk_tools:
567 .for _kernel in ${BUILDKERNELS}
568         @if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
569             if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
570                 echo "The kernel was build using buildworld tools which no" ; \
571                 echo "longer appear to exist, quickkernel failed!" ; \
572                 /usr/bin/false; \
573             fi; \
574         fi
575 .endfor
576
577 bk_build_list:
578 .if empty(BUILDKERNELS)
579         @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
580         @echo ">>> Did you move your kernel configs from i386/conf to config/?"
581         @false
582 .endif
583
584 bk_kernwarn:
585 .if defined(KERNWARN)
586         @echo "--------------------------------------------------------------"
587         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
588         @echo "--------------------------------------------------------------"
589         @sleep 3
590 .endif
591         @echo
592
593 # The buildkernel target rebuilds the specified kernels from scratch
594 # using the crossbuild tools generated by the last buildworld.  It is
595 # the safest (but also the most time consuming) way to build a new kernel.
596 #
597 buildkernel:    bk_tools bk_build_list bk_kernwarn
598 .for _kernel in ${BUILDKERNELS}
599         @echo "--------------------------------------------------------------"
600         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
601         @echo "--------------------------------------------------------------"
602         @echo "===> ${_kernel}"
603 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
604         rm -rf ${KRNLOBJDIR}/${_kernel}
605 .else
606         @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
607                 echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
608                 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
609 .endif
610         mkdir -p ${KRNLOBJDIR}
611 .if !defined(NO_KERNELCONFIG)
612         cd ${KRNLCONFDIR}; \
613                 PATH=${STRICTTMPPATH} \
614                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
615                         ${KERNCONFDIR}/${_kernel}
616 .endif
617 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
618         echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
619 .endif
620         touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
621 .if !defined(NO_KERNELDEPEND)
622         cd ${KRNLOBJDIR}/${_kernel}; \
623             ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
624 .endif
625         cd ${KRNLOBJDIR}/${_kernel}; \
626             ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
627         @echo "--------------------------------------------------------------"
628         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
629         @echo "--------------------------------------------------------------"
630 .endfor
631
632 # The nativekernel target rebuilds the specified kernels from scratch
633 # using the system's standard compiler rather than using the crossbuild
634 # tools generated by the last buildworld.  This is fairly safe if your
635 # system is reasonable up-to-date.
636 #
637 nativekernel:   bk_build_list bk_kernwarn
638 .for _kernel in ${BUILDKERNELS}
639         @echo "--------------------------------------------------------------"
640         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
641         @echo "--------------------------------------------------------------"
642         @echo "===> ${_kernel}"
643 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
644         rm -rf ${KRNLOBJDIR}/${_kernel}
645 .else
646         @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
647                 echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
648                 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
649 .endif
650         mkdir -p ${KRNLOBJDIR}
651 .if !defined(NO_KERNELCONFIG)
652         cd ${KRNLCONFDIR}; \
653                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
654                         ${KERNCONFDIR}/${_kernel}
655 .endif
656 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
657         echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
658 .endif
659         touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
660         cd ${KRNLOBJDIR}/${_kernel}; \
661             MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
662             make -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
663 .if !defined(NO_KERNELDEPEND)
664         cd ${KRNLOBJDIR}/${_kernel}; \
665             make KERNEL=${INSTKERNNAME} depend
666 .endif
667         cd ${KRNLOBJDIR}/${_kernel}; \
668             make KERNEL=${INSTKERNNAME} all
669         @echo "--------------------------------------------------------------"
670         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
671         @echo "--------------------------------------------------------------"
672 .endfor
673
674 # The quickkernel target rebuilds the specified kernels as quickly
675 # as possible.  It will use the native tools or the buildworld cross tools
676 # based on whether the kernel was originally generated via buildkernel or
677 # nativekernel.  Config is rerun but the object hierarchy is not rebuilt,
678 # nor is the make depend step run.
679 #
680 quickkernel:    maybe_bk_tools bk_build_list bk_kernwarn
681 .for _kernel in ${BUILDKERNELS}
682         @echo "--------------------------------------------------------------"
683         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
684         @echo "--------------------------------------------------------------"
685         @echo "===> ${_kernel}"
686 .if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
687 .if !defined(NO_KERNELCONFIG)
688         cd ${KRNLCONFDIR}; \
689                 PATH=${STRICTTMPPATH} \
690                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
691                         ${KERNCONFDIR}/${_kernel}
692 .endif
693         cd ${KRNLOBJDIR}/${_kernel}; \
694             ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
695 .else
696 .if !defined(NO_KERNELCONFIG)
697         cd ${KRNLCONFDIR}; \
698             config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
699                 ${KERNCONFDIR}/${_kernel}
700 .endif
701         cd ${KRNLOBJDIR}/${_kernel}; \
702             make KERNEL=${INSTKERNNAME} all
703 .endif
704         @echo "--------------------------------------------------------------"
705         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
706         @echo "--------------------------------------------------------------"
707 .endfor
708
709
710 # installkernel
711 #
712 # Install the kernel defined by INSTALLKERNEL
713 #
714 installkernel reinstallkernel:
715         @echo "--------------------------------------------------------------"
716         @echo ">>> Kernel install for ${INSTALLKERNEL} started on `LC_ALL=C date`"
717         @echo "--------------------------------------------------------------"
718 .if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run)
719         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
720             ${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
721 .else
722         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
723             make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
724 .endif
725
726 #
727 # most
728 #
729 # Build most of the user binaries on the existing system libs and includes.
730 #
731 most:
732         @echo "--------------------------------------------------------------"
733         @echo ">>> Building programs only"
734         @echo "--------------------------------------------------------------"
735 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
736         cd ${.CURDIR}/${_dir};          make DIRPRFX=${_dir}/ all
737 .endfor
738
739 #
740 # installmost
741 #
742 # Install the binaries built by the 'most' target.  This does not include
743 # libraries or include files.
744 #
745 installmost:
746         @echo "--------------------------------------------------------------"
747         @echo ">>> Installing programs only"
748         @echo "--------------------------------------------------------------"
749 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
750         cd ${.CURDIR}/${_dir};          make DIRPRFX=${_dir}/ install
751 .endfor
752
753 #
754 # ------------------------------------------------------------------------
755 #
756 # From here onwards are utility targets used by the 'make world' and
757 # related targets.  If your 'world' breaks, you may like to try to fix
758 # the problem and manually run the following targets to attempt to
759 # complete the build.  Beware, this is *not* guaranteed to work, you
760 # need to have a pretty good grip on the current state of the system
761 # to attempt to manually finish it.  If in doubt, 'make world' again.
762 #
763
764 # bootstrap-tools: Build all tools required to build all tools.  Note that
765 # order is important in a number of cases and also note that the bootstrap
766 # and build tools stages have access to earlier binaries they themselves
767 # had generated.
768 #
769 # patch:        older patch's do not have -i.  This program must be built
770 #               first so other bootstrap tools that need to apply patches
771 #               can use it.
772 # [x]install:   dependancies on various new install features
773 # rpcgen:       old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
774 #               envs are not compatible with older objformat binaries.
775 #
776 .if exists(${.CURDIR}/games) && !defined(NO_GAMES)
777 _strfile=       games/fortune/strfile
778 .endif
779
780 # BSTRAPDIRS1 - must be built in strict order, no parallelism
781 #
782 # order is very important. yacc before m4 before flex.  flex exec's m4,
783 # m4's parser file needs the latest byacc (insanity!).
784 #
785 BSTRAPDIRS1= ${_strfile} \
786         usr.bin/patch \
787         bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \
788         bin/test bin/cat bin/ln bin/mv bin/csh bin/expr bin/sh \
789         bin/hostname bin/kill \
790         usr.bin/yacc usr.bin/m4 usr.bin/colldef \
791         usr.bin/uudecode usr.bin/xinstall \
792         usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
793         usr.bin/find usr.bin/flex
794
795 # BSTRAPDIRS2 - may built in parallel
796 #
797 BSTRAPDIRS2= \
798         usr.bin/sed usr.bin/uname usr.bin/touch \
799         usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
800         usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
801         usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
802         usr.bin/mklocale usr.bin/uuencode usr.bin/compile_et usr.bin/hexdump \
803         usr.bin/cap_mkdb usr.bin/true usr.bin/false \
804         usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
805         usr.bin/tail usr.bin/unifdef usr.bin/tic \
806         usr.sbin/chown usr.sbin/mtree usr.sbin/config \
807         usr.sbin/btxld usr.sbin/zic usr.sbin/makewhatis \
808         gnu/usr.bin/texinfo gnu/usr.bin/grep usr.bin/sort \
809         usr.bin/gzip usr.bin/bzip2 usr.bin/mkcsmapper usr.bin/mkesdb \
810         usr.bin/crunch
811
812 bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
813         touch ${BTOOLSDEST}/.bootstrap_done
814
815 bootstrap-tools-before:
816         ${LN} -fs /bin/date ${BTOOLSDEST}/bin/date
817
818 bootstrap-tools-targets1: ${BSTRAPDIRS1:S/^/bstrap-/}
819
820 bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/}
821
822 .ORDER: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
823
824 .ORDER: ${BSTRAPDIRS1:S/^/bstrap-/}
825
826 .for _tool in ${BSTRAPDIRS1} ${BSTRAPDIRS2}
827 bstrap-${_tool}!
828         ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
829                 cd ${.CURDIR}/${_tool}; \
830                 make DIRPRFX=${_tool}/ obj; \
831                 make DIRPRFX=${_tool}/ depend; \
832                 make DIRPRFX=${_tool}/ all; \
833                 make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
834 .endfor
835
836 # build-tools: Build special purpose build tools.
837 #
838 # XXX we may be able to remove or consolidate this into bootstrap-tools
839 # now that we have the native helper (.nx/.no) infrastructure.
840 #
841 .if exists(${.CURDIR}/share) && !defined(NO_SHARE)
842 _share= share/syscons/scrnmaps
843 .endif
844
845 _gcc_common_cross= gnu/usr.bin/gmp gnu/usr.bin/mpfr
846 .if !defined(NO_GCC44)
847 _gcc44_cross= gnu/usr.bin/cc44
848 _gcc44_tools= gnu/usr.bin/cc44/cc_prep gnu/usr.bin/cc44/cc_tools
849 .endif
850 _gcc47_cross= lib/libz gnu/usr.bin/mpc gnu/usr.bin/cc47
851 _gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
852 _custom_cross= libexec/customcc
853 _binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
854
855 BTOOLSDIRS= ${_gcc44_tools} ${_gcc47_tools} ${_share}
856
857 build-tools: build-tools-targets
858         touch ${BTOOLSDEST}/.build_done
859
860 build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
861
862 .ORDER: ${_gcc44_tools:S/^/btools-/}
863 .ORDER: ${_gcc47_tools:S/^/btools-/}
864
865 .for _tool in ${BTOOLSDIRS}
866 btools-${_tool}!
867         ${ECHODIR} "===> ${_tool} (build-tools)"; \
868                 cd ${.CURDIR}/${_tool}; \
869                 make DIRPRFX=${_tool}/ obj; \
870                 make DIRPRFX=${_tool}/ depend; \
871                 make DIRPRFX=${_tool}/ all; \
872                 make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
873 .endfor
874
875 #
876 # cross-tools: Build cross-building tools
877 #
878 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
879 _btxld= usr.sbin/btxld
880 .endif
881
882 CTOOLSDIRS= ${_btxld} ${_binutils} \
883                 usr.bin/objformat usr.bin/crunch/crunchide \
884                 ${_gcc_common_cross} \
885                 ${_gcc44_cross} ${_gcc47_cross} ${_custom_cross}
886
887 cross-tools: cross-tools-targets
888         touch ${CTOOLSDEST}/.cross_done
889
890 cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}
891
892 .for _tool in ${CTOOLSDIRS}
893 ctools-${_tool}!
894         ${ECHODIR} "===> ${_tool} (cross-tools)"; \
895                 cd ${.CURDIR}/${_tool}; \
896                 make DIRPRFX=${_tool}/ obj; \
897                 make DIRPRFX=${_tool}/ depend; \
898                 make DIRPRFX=${_tool}/ all; \
899                 make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
900 .endfor
901
902 #
903 # hierarchy - ensure that all the needed directories are present
904 #
905 hierarchy:
906         cd ${.CURDIR}/etc;              make distrib-dirs
907
908 #
909 # libraries - build all libraries, and install them under ${DESTDIR}.
910 #
911 # The list of libraries with dependents (${_prebuild_libs}) and their
912 # interdependencies (__L) are built automatically by the
913 # ${.CURDIR}/tools/make_libdeps.sh script.
914 #
915 # .makeenv does not work when bootstrapping from 4.x, so we must be sure
916 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
917 #
918 libraries:
919         cd ${.CURDIR}; \
920             HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
921                 make -f Makefile.inc1 _startup_libs47;
922 .if !defined(NO_GCC44)
923         cd ${.CURDIR}; \
924             HOST_CCVER=${HOST_CCVER} CCVER=gcc44 \
925                 make -f Makefile.inc1 _startup_libs44;
926 .endif
927         cd ${.CURDIR}; \
928             make -f Makefile.inc1 _startup_libs; \
929             make -f Makefile.inc1 _prebuild_libs; \
930             make -f Makefile.inc1 _generic_libs;
931         touch ${WORLDDEST}/.libraries_done
932
933 # These dependencies are not automatically generated:
934 #
935 # gnu/lib/${CCVER}/libgcc and gnu/lib/${CCVER}/csu must be built before all
936 # shared libraries for ELF.  The target for _startup_libsXX is
937 # specifically built using gccXX.
938 #
939 _startup_libs47=        gnu/usr.bin/cc47/cc_prep \
940                         gnu/usr.bin/cc47/cc_tools \
941                         gnu/lib/gcc47/csu \
942                         gnu/lib/gcc47/libgcc \
943                         gnu/lib/gcc47/libgcc_eh \
944                         gnu/lib/gcc47/libgcc_pic
945 _startup_libs44=        gnu/usr.bin/cc44/cc_prep \
946                         gnu/usr.bin/cc44/cc_tools \
947                         gnu/lib/gcc44/csu \
948                         gnu/lib/gcc44/libgcc
949 _startup_libs=          lib/csu lib/libc lib/libc_rtld
950
951 _prebuild_libs=         lib/libbz2 lib/liblzma lib/libz
952 _prebuild_libs+=        lib/libutil
953
954 _generic_libs=  gnu/lib
955
956 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
957                 lib/libncurses/libncurses lib/libopie
958
959 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
960
961 _generic_libs+= lib
962
963 .if !defined(NO_CRYPT)
964 .if !defined(NO_OPENSSL)
965 _prebuild_libs+=        secure/lib/libcrypto secure/lib/libssl
966 .if !defined(NO_OPENSSH)
967 _prebuild_libs+=        secure/lib/libssh
968 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
969 .endif
970 .endif
971 _generic_libs+= secure/lib
972 .endif
973
974 _prebuild_libs+= lib/libradius lib/libsbuf lib/libtacplus lib/libm \
975                 lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \
976                 lib/libpthread lib/libprop lib/libdevattr
977
978 _generic_libs+= usr.bin/flex/lib
979
980 .for _lib in ${_startup_libs44} ${_startup_libs47} \
981                 ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
982 ${_lib}__L: .PHONY
983 .if exists(${.CURDIR}/${_lib})
984         ${ECHODIR} "===> ${_lib}"; \
985                 cd ${.CURDIR}/${_lib}; \
986                 make DIRPRFX=${_lib}/ depend; \
987                 make DIRPRFX=${_lib}/ all; \
988                 make DIRPRFX=${_lib}/ install
989 .endif
990 .endfor
991
992 _startup_libs: ${_startup_libs:S/$/__L/}
993 _startup_libs47: ${_startup_libs47:S/$/__L/}
994 _startup_libs44: ${_startup_libs44:S/$/__L/}
995 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
996 _generic_libs: ${_generic_libs:S/$/__L/}
997
998 # library targets must be ordered because there are inter-library
999 # races (e.g. generation of tconfig.h)
1000 #
1001 .ORDER: ${_startup_libs47:S/$/__L/}
1002 .ORDER: ${_startup_libs44:S/$/__L/}
1003 .ORDER: ${_startup_libs:S/$/__L/}
1004 .ORDER: ${_prebuild_libs:S/$/__L/}
1005 .ORDER: ${_generic_libs:S/$/__L/}
1006
1007 .for __target in clean cleandepend cleandir obj depend includes
1008 .for entry in ${SUBDIR}
1009 ${entry}.${__target}__D: .PHONY
1010         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1011                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
1012                 edir=${entry}.${MACHINE_ARCH}; \
1013                 cd ${.CURDIR}/$${edir}; \
1014         else \
1015                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
1016                 edir=${entry}; \
1017                 cd ${.CURDIR}/$${edir}; \
1018         fi; \
1019         make ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1020 .endfor
1021 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1022 .ORDER: ${SUBDIR:S/$/.${__target}__D/}
1023 .endfor
1024 .ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
1025
1026 # The wmake target is used by /usr/bin/wmake to run make in a
1027 # world build environment.
1028 #
1029 wmake:
1030         @echo '${WMAKEENV} make ${WMAKE_ARGS}'
1031
1032 wmakeenv:
1033         @echo '${WMAKEENV} /bin/sh'
1034
1035 bmake:
1036         @echo '${BMAKEENV} make ${BMAKE_ARGS}'
1037
1038 bmakeenv:
1039         @echo '${BMAKEENV} /bin/sh'
1040
1041 tmake:
1042         @echo '${TMAKEENV} make ${TMAKE_ARGS}'
1043
1044 tmakeenv:
1045         @echo '${TMAKEENV} /bin/sh'
1046
1047 xmake:
1048         @echo '${XMAKEENV} make ${XMAKE_ARGS}'
1049
1050 xmakeenv:
1051         @echo '${XMAKEENV} /bin/sh'
1052
1053 backupworld: backup-clean
1054         @mkdir -p ${WORLD_BACKUP}
1055 .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1056      exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1057      exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1058         tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1059                 --options gzip:compression-level=1 \
1060                 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1061 .endif
1062
1063 backupworld-auto:
1064 .if !defined(NO_BACKUP)
1065         rm -f ${AUTO_BACKUP}/binaries.tar.gz
1066         @mkdir -p ${AUTO_BACKUP}
1067 .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1068      exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1069      exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1070         tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1071                 --options gzip:compression-level=1 \
1072                 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1073 .endif
1074 .endif
1075
1076 backup-auto-clean:
1077         rm -f ${AUTO_BACKUP}/binaries.tar.gz
1078
1079 backup-clean:
1080         rm -f ${WORLD_BACKUP}/binaries.tar.gz
1081
1082 restoreworld:
1083 .if !exists(${WORLD_BACKUP}/binaries.tar.gz)
1084         @echo "There does not seem to be a valid archive present."
1085 .else
1086         @echo "Restoring system binaries from manual backup archive..."
1087         @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1088                 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1089                 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1090         tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1091 .endif
1092
1093 restoreworld-auto:
1094 .if !exists(${AUTO_BACKUP}/binaries.tar.gz)
1095         @echo "There does not seem to be a valid archive present."
1096 .else
1097         @echo "Restoring system binaries from auto-backup archive..."
1098         @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1099                 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1100                 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1101         tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1102 .endif
1103
1104 # Take advantage of bmake error response
1105 #
1106 MAKE_PRINT_VAR_ON_ERROR= \
1107         .CURDIR \
1108         .OBJDIR \
1109         LD_LIBRARY_PATH \
1110         MACHINE_ARCH \
1111         MACHINE \
1112         MAKEFILE \
1113         .TARGETS \
1114         .ERROR_TARGET \
1115         .MAKE.LEVEL
1116
1117 .include <bsd.subdir.mk>