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