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