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