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