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