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.
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)
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)
42 .if exists(${.CURDIR}/lib)
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)
53 .if exists(${.CURDIR}/bin)
56 .if exists(${.CURDIR}/games) && !defined(NO_GAMES)
59 .if exists(${.CURDIR}/gnu)
62 .if exists(${.CURDIR}/sbin)
65 .if exists(${.CURDIR}/secure) && !defined(NO_CRYPT)
68 .if exists(${.CURDIR}/share) && !defined(NO_SHARE)
71 .if exists(${.CURDIR}/sys)
74 .if exists(${.CURDIR}/usr.bin)
77 .if exists(${.CURDIR}/usr.sbin)
81 .if exists(${.CURDIR}/etc)
85 # These are last, since it is nice to at least get the base system
86 # rebuilt before you do them.
87 .if defined(LOCAL_DIRS)
88 .for _DIR in ${LOCAL_DIRS}
89 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
95 .if defined(SUBDIR_OVERRIDE)
96 SUBDIR= ${SUBDIR_OVERRIDE}
99 .if defined(NOCLEANDIR)
100 CLEANDIR= clean cleandepend
105 .if defined(NO_CLEAN)
109 # Object directory base in primary make. Note that when we rerun make
110 # from inside this file we change MAKEOBJDIRPREFIX to the appropriate
111 # subdirectory because the rest of the build system needs it that way.
112 # The original object directory base is saved in OBJTREE.
114 MAKEOBJDIRPREFIX?= /usr/obj
115 OBJTREE?= ${MAKEOBJDIRPREFIX}
117 # Used for stage installs and pathing
119 DESTDIRBASE:= ${OBJTREE}${.CURDIR}
121 # Remove DESTDIR from MAKEFLAGS. It is present in the environment
122 # anyhow, and we need to be able to override it for stage installs
123 .MAKEFLAGS:= ${.MAKEFLAGS:NDESTDIR=*}
125 # This section sets the tools used to build the world/kernel
128 WORLD_BINUTILSVER?= binutils225
130 # Set the backup parameters if they are not already defined
132 WORLD_BACKUP?= /var/backups/world_backup
133 AUTO_BACKUP?= ${OBJTREE}/world_backup/${DESTDIR}
135 TARGET_ARCH?= ${MACHINE_ARCH}
136 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
139 TARGET?= ${TARGET_ARCH}
142 BUILD_ARCH!= sysctl -n hw.machine_arch
144 # temporary until everybody has converted to x86_64
145 .if ${BUILD_ARCH} == "amd64"
149 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
150 .error To cross-build, set TARGET_ARCH.
154 # XXX this is ugly and we need to come up with a nicer solution
155 .if !defined(TARGET_PLATFORM)
156 .if ${TARGET_ARCH} == "x86_64"
157 TARGET_PLATFORM= pc64
159 .error Unknown target architecture.
163 THREAD_LIB?= thread_xu
164 .if ${THREAD_LIB} == "c_r"
165 .if defined(NO_LIBC_R)
166 .error libc_r is chosen as the default thread library, but NO_LIBC_R is defined
170 # BTOOLS (Natively built) All non-cross-development tools that the
171 # main build needs. This includes things like 'mkdir' and 'rm'.
172 # We will not use the native system's exec path once we start
173 # on WORLD. (bootstrap-tools and build-tools or BTOOLS)
175 # CTOOLS (Natively built) Cross development tools which are specific
176 # to the target architecture.
178 # WORLD (Cross built) Our ultimate buildworld, using only BTOOLS and
181 # MACHINE_PLATFORM Platform Architecture we are building on
182 # MACHINE Machine Architecture (usually the same as MACHINE_ARCH)
183 # MACHINE_ARCH Cpu Architecture we are building on
185 # TARGET_PLATFORM Platform Architecture we are building for
186 # TARGET Machine Architecture we are building for
187 # TARGET_ARCH Cpu Architecture we are building for
189 BTOOLSDEST= ${DESTDIRBASE}/btools_${MACHINE_ARCH}
190 CTOOLSDEST= ${DESTDIRBASE}/ctools_${MACHINE_ARCH}_${TARGET_ARCH}
191 WORLDDEST= ${DESTDIRBASE}/world_${TARGET_ARCH}
193 # The bootstrap-tools path is used by the bootstrap-tools, build-tools, and
194 # cross-tools stages to augment the existing command path to access newer
195 # versions of certain utilities such as 'patch' that the cross-tools stage
198 BTOOLSPATH= ${BTOOLSDEST}/usr/sbin:${BTOOLSDEST}/usr/bin:${BTOOLSDEST}/bin:${BTOOLSDEST}/usr/games
200 # The strict temporary command path contains all binaries required
201 # by the buildworld system after the cross-tools stage.
203 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
209 # Building a world goes through the following stages
211 # 1. bootstrap-tool stage [BMAKE]
212 # This stage is responsible for creating programs that
213 # are needed for backward compatibility reasons. They
214 # are not built as cross-tools.
215 # 2. build-tool stage [TMAKE]
216 # This stage is responsible for creating the object
217 # tree and building any tools that are needed during
219 # 3. cross-tool stage [XMAKE]
220 # This stage is responsible for creating any tools that
221 # are needed for cross-builds. A cross-compiler is one
223 # 4. world stage [WMAKE]
224 # This stage actually builds the world.
225 # 5. install stage (optional) [IMAKE]
226 # This stage installs a previously built world.
228 # In all cases we must carefully adjust the environment so the proper
229 # tools and header files are used.
231 # NOTE: The M4 environment variable is used by the [f]lex binary to
232 # override the location of the 'm4' binary. The override is
233 # needed for certain buildworld version transitions, specifically
234 # past a certain point in 3.3 because the older /usr/bin/m4 will
235 # generate output that will blow up the newer [f]lex/yacc/bison
239 # bootstrap-tool stage
241 BMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
243 DESTDIR=${BTOOLSDEST} \
244 PATH=${BTOOLSPATH}:${PATH} \
245 M4=${BTOOLSDEST}/usr/bin/m4 \
246 INSTALL="sh ${.CURDIR}/tools/install.sh"
248 BMAKE= ${BMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
249 -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
250 -DNO_WERROR -DNO_NLS -DSYSBUILD
254 TMAKEENV= MAKEOBJDIRPREFIX=${BTOOLSDEST} \
257 PATH=${BTOOLSPATH}:${PATH} \
258 M4=${BTOOLSDEST}/usr/bin/m4 \
259 INSTALL="sh ${.CURDIR}/tools/install.sh"
261 TMAKE= ${TMAKEENV} make -f Makefile.inc1 -DBOOTSTRAPPING \
262 -DNOSHARED -DSYSBUILD
266 # note: TOOLS_PREFIX points to the obj root holding the cross
267 # compiler binaries, while USRDATA_PREFIX points to the obj root
268 # holding the target environment (and also determines where cross-built
269 # libraries, crt*.o, and include files are installed).
271 XMAKEENV= MAKEOBJDIRPREFIX=${CTOOLSDEST} \
273 DESTDIR=${CTOOLSDEST} \
274 _SHLIBDIRPREFIX=${CTOOLSDEST} \
275 INSTALL="sh ${.CURDIR}/tools/install.sh" \
276 TOOLS_PREFIX=${CTOOLSDEST} \
277 USRDATA_PREFIX=${WORLDDEST} \
278 SELECT_LINKER=${WORLD_LDVER} \
279 M4=${BTOOLSDEST}/usr/bin/m4 \
280 PATH=${BTOOLSPATH}:${PATH}
282 XMAKE= ${XMAKEENV} make -f Makefile.inc1 -DNO_GDB \
283 -DBOOTSTRAPPING -DNOSHARED -DSYSBUILD
285 # world stage, note the strict path and note that TOOLS_PREFIX is left
286 # unset and USRDATA_PREFIX (which defaults to TOOLS_PREFIX) is set to empty,
287 # which is primarily for the compiler so it targets / (e.g. /usr/<blah>)
288 # for both binary and library paths, even though it is being compiled to
289 # WORLDDEST. None of the programs in the world stage are ever actually
290 # executed during the buildworld/installworld.
292 CROSSENV= MAKEOBJDIRPREFIX=${WORLDDEST} \
294 MACHINE_ARCH=${TARGET_ARCH} \
296 MACHINE_PLATFORM=${TARGET_PLATFORM} \
297 OBJFORMAT_PATH=${CTOOLSDEST} \
298 HOST_CCVER=${HOST_CCVER} \
299 CCVER=${WORLD_CCVER} \
300 LDVER=${WORLD_LDVER} \
301 BINUTILSVER=${WORLD_BINUTILSVER}
303 WMAKEENV= ${CROSSENV} \
304 DESTDIR=${WORLDDEST} \
305 _SHLIBDIRPREFIX=${WORLDDEST} \
306 INSTALL="sh ${.CURDIR}/tools/install.sh" \
307 M4=${BTOOLSDEST}/usr/bin/m4 \
308 PATH=${STRICTTMPPATH}
310 WMAKE= ${WMAKEENV} make -f Makefile.inc1 -DSYSBUILD
314 IMAKEENV= ${CROSSENV} \
315 PATH=${STRICTTMPPATH}
316 IMAKE= ${IMAKEENV} make -f Makefile.inc1 -DSYSBUILD
320 KMAKEENV= ${WMAKEENV}
324 # Attempt to rebuild the entire system, with reasonable chance of
325 # success, regardless of how old your existing system is.
327 _worldtmp: _cleantmp _mtreetmp
328 .ORDER: _cleantmp _mtreetmp
332 @echo "--------------------------------------------------------------"
333 @echo ">>> Rebuilding the temporary build tree"
334 @echo "--------------------------------------------------------------"
335 .if !defined(NOCLEAN)
336 rm -rf ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
338 # XXX - These two can depend on any header file.
339 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
340 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
344 mkdir -p ${DESTDIRBASE} ${BTOOLSDEST} ${CTOOLSDEST} ${WORLDDEST}
345 .for _dir in ${WORLDDEST} ${BTOOLSDEST} ${CTOOLSDEST}
346 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
347 -p ${_dir}/ > /dev/null
348 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
349 -p ${_dir}/usr > /dev/null
351 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
352 -p ${WORLDDEST}/usr/include > /dev/null
353 ${LN} -sf ${.CURDIR}/sys ${WORLDDEST}
357 @echo "--------------------------------------------------------------"
358 @echo ">>> stage 1: bootstrap tools"
359 @echo "--------------------------------------------------------------"
360 cd ${.CURDIR}; ${BMAKE} bootstrap-tools
363 @echo "--------------------------------------------------------------"
364 @echo ">>> stage 2a: cleaning up the object tree"
365 @echo "--------------------------------------------------------------"
366 cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 2b: rebuilding the object tree"
371 @echo "--------------------------------------------------------------"
372 cd ${.CURDIR}; ${WMAKE} par-obj
375 @echo "--------------------------------------------------------------"
376 @echo ">>> stage 2c: build tools"
377 @echo "--------------------------------------------------------------"
378 cd ${.CURDIR}; ${TMAKE} build-tools
381 @echo "--------------------------------------------------------------"
382 @echo ">>> stage 3: cross tools"
383 @echo "--------------------------------------------------------------"
384 cd ${.CURDIR}; ${XMAKE} cross-tools
387 @echo "--------------------------------------------------------------"
388 @echo ">>> stage 4a: populating ${WORLDDEST}/usr/include"
389 @echo "--------------------------------------------------------------"
390 cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 4b: building libraries"
395 @echo "--------------------------------------------------------------"
396 cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOMAN -DNOFSCHG libraries
399 @echo "--------------------------------------------------------------"
400 @echo ">>> stage 4c: make dependencies"
401 @echo "--------------------------------------------------------------"
402 cd ${.CURDIR}; ${WMAKE} par-depend
405 @echo "--------------------------------------------------------------"
406 @echo ">>> stage 4d: building everything.."
407 @echo "--------------------------------------------------------------"
408 cd ${.CURDIR}; ${WMAKE} all
410 @echo "--------------------------------------------------------------"
411 @echo ">>> starting buildworld target"
412 @echo "--------------------------------------------------------------"
414 @echo "--------------------------------------------------------------"
415 @echo ">>> buildworld target complete"
416 @echo "--------------------------------------------------------------"
418 @echo "--------------------------------------------------------------"
419 @echo ">>> starting quickworld target"
420 @echo "--------------------------------------------------------------"
422 @echo "--------------------------------------------------------------"
423 @echo ">>> quickworld target complete"
424 @echo "--------------------------------------------------------------"
426 @echo "--------------------------------------------------------------"
427 @echo ">>> starting installworld target"
428 @echo "--------------------------------------------------------------"
430 # note: buildworld no longer depends on _cleanobj because we rm -rf the
431 # entire object tree and built the bootstrap tools in a different location.
433 # buildworld - build everything from scratch
434 # quickworld - skip the bootstrap, build, and cross-build steps
435 # realquickworld - skip the bootstrap, build, crossbuild, and depend step.
437 # note: we include _obj in realquickworld to prevent accidental creation
438 # of files in /usr/src.
441 .if !defined(SUBDIR_OVERRIDE)
442 WMAKE_TGTS+= _worldtmp _bootstrap-tools
444 WMAKE_TGTS+= _obj _build-tools
445 .if !defined(SUBDIR_OVERRIDE)
446 WMAKE_TGTS+= _cross-tools
448 WMAKE_TGTS+= _includes _libraries _depend everything
450 buildworld: _bwinit ${WMAKE_TGTS} _bwdone
452 quickworld: _qwinit _mtreetmp _obj _includes _libraries _depend everything _qwdone
454 realquickworld: _qwinit _mtreetmp _obj _includes _libraries everything _qwdone
456 crossworld: _worldtmp _bootstrap-tools _obj _build-tools _cross-tools
458 .ORDER: _bwinit ${WMAKE_TGTS} _bwdone
459 .ORDER: _obj _includes
460 .ORDER: _qwinit _mtreetmp _obj
461 .ORDER: installcheck backupworld-auto
462 .ORDER: everything _qwdone
467 # Checks to be sure system is ready for installworld
469 installcheck: _iwinit
470 @pw usershow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
471 @pw groupshow authpf || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
472 @pw groupshow _pflogd || (echo "You may need to run 'make preupgrade' first"; /usr/bin/false)
473 .if !defined(OVERRIDE_CHECKS)
474 .if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/"
475 @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
476 @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
483 # Backs up the current world if ${AUTO_BACKUP} is writable.
484 # Installs everything compiled by a 'buildworld'.
486 # Includes sleep/sync safety before running mkinitrd.
488 installworld: installcheck
489 -@mkdir -p ${AUTO_BACKUP} > /dev/null 2>&1
491 (touch ${AUTO_BACKUP}/.updating > /dev/null 2>&1 && \
492 ${IMAKE} backupworld-auto) || \
493 echo "Cannot write to ${AUTO_BACKUP} - world not backed up"
495 cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
496 ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc ${DESTDIR}/etc/upgrade/
498 @echo "--------------------------------------------------------------"
499 @echo ">>> installworld target complete"
500 @echo "--------------------------------------------------------------"
501 @echo "If things work as expected after a full reboot, consider updating the rescue"
502 @echo "image with 'make rescue'. Do not do it until after rebooting."
505 @echo "Doing a forced installworld. This will install to a temporary directory,"
506 @echo "then copy the main binaries and libraries with a static cpdup to ${DESTDIR}/"
507 @echo "and finally willl issue a normal installworld. Starting in 5 seconds.".
510 rm -rf /usr/obj/temp > /dev/null 2>& 1 || chflags -R noschg /usr/obj/temp
512 mkdir -p /usr/obj/temp/cpdup/bin
513 (cd ${.CURDIR}/bin/cpdup; make clean; make obj; make clean; make CFLAGS=-static all install DESTDIR=/usr/obj/temp/cpdup NOMAN=TRUE)
514 @echo "XXXXXXXXX Installing to temporary XXXXXXXXX"
516 (cd ${.CURDIR}; ${MAKE} installworld DESTDIR=/usr/obj/temp > /dev/null 2>&1)
517 @echo "XXXXXXXXX Blasting binaries and libraries XXXXXXXXX"
519 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/bin /bin
520 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/sbin /sbin
521 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/lib /lib
522 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/bin /usr/bin
523 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/sbin /usr/sbin
524 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/lib /usr/lib
525 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/libexec /libexec
526 /usr/obj/temp/cpdup/bin/cpdup -i0 /usr/obj/temp/usr/libexec /usr/libexec
527 @echo "XXXXXXXXX Doing final installworld XXXXXXXX"
529 (cd ${.CURDIR}; ${MAKE} installworld OVERRIDE_CHECKS=TRUE)
530 (cd ${.CURDIR}; ${MAKE} upgrade OVERRIDE_CHECKS=TRUE)
532 # Create a rescue image. We no longer do this automatically for several
533 # reasons, primarily that users have had serious issue with mismatched 'vn'
534 # vs the kldload image that can crash the system. But also, the rescue image
535 # is intended to be a rescue image, it is a bad idea to update it at the
536 # same time the world is installed.
539 mkinitrd -b ${DESTDIR}/boot
544 # If you have a build server, you can NFS mount the source and obj directories
545 # and do a 'make reinstall' on the *client* to install new binaries from the
546 # most recent server build.
549 @echo "--------------------------------------------------------------"
550 @echo ">>> Making hierarchy"
551 @echo "--------------------------------------------------------------"
552 cd ${.CURDIR}; make -f Makefile.inc1 hierarchy
554 @echo "--------------------------------------------------------------"
555 @echo ">>> Installing everything.."
556 @echo "--------------------------------------------------------------"
557 cd ${.CURDIR}; make -f Makefile.inc1 install
560 # buildkernel, nativekernel, quickkernel, and installkernel
562 # Which kernels to build and/or install is specified by setting
563 # KERNCONF. If not defined an X86_64_GENERIC kernel is built/installed.
564 # Only the existing (depending TARGET) config files are used
565 # for building kernels and only the first of these is designated
566 # as the one being installed.
568 # You can specify INSTALLSTRIPPED=1 if you wish the installed
569 # kernel and modules to be stripped of its debug info (required
570 # symbols are left intact). You can specify INSTALLSTRIPPEDMODULES
571 # if you only want to strip the modules of their debug info. These
572 # only apply if you have DEBUG=-g in your kernel config or make line.
574 # Note that we have to use TARGET instead of TARGET_ARCH when
575 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
576 # be set to cross-build, we have to make sure TARGET is set
579 .if !defined(KERNCONF) && defined(KERNEL)
583 # XXX makeshift fix to build the right kernel for the (target) architecture
584 # We should configure this in the platform files somehow
585 .if ${TARGET_ARCH} == "x86_64"
586 KERNCONF?= X86_64_GENERIC
589 INSTKERNNAME?= kernel
591 KRNLSRCDIR= ${.CURDIR}/sys
592 KRNLCONFDIR= ${KRNLSRCDIR}/config
593 KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
594 KERNCONFDIR?= ${KRNLCONFDIR}
598 .for _kernel in ${KERNCONF}
599 .if exists(${KERNCONFDIR}/${_kernel})
600 BUILDKERNELS+= ${_kernel}
601 .if empty(INSTALLKERNEL)
602 INSTALLKERNEL= ${_kernel}
607 # kernel version numbers survive rm -rf
609 .for _kernel in ${BUILDKERNELS}
610 .if exists(${KRNLOBJDIR}/${_kernel}/version)
611 KERNEL_VERSION_${_kernel} != cat ${KRNLOBJDIR}/${_kernel}/version
618 # Builds all kernels defined by BUILDKERNELS.
621 @if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
622 echo "You must buildworld before buildkernel. If you wish"; \
623 echo "to build a kernel using native tools, config it manually"; \
624 echo "or use the nativekernel target if you are in a rush"; \
629 .for _kernel in ${BUILDKERNELS}
630 @if [ ! -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
631 if [ ! -f ${WORLDDEST}/.libraries_done ]; then \
632 echo "The kernel was build using buildworld tools which no" ; \
633 echo "longer appear to exist, quickkernel failed!" ; \
640 .if empty(BUILDKERNELS)
641 @echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
642 @echo ">>> Did you move your kernel configs from i386/conf to config/?"
647 .if defined(KERNWARN)
648 @echo "--------------------------------------------------------------"
649 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
650 @echo "--------------------------------------------------------------"
655 # The buildkernel target rebuilds the specified kernels from scratch
656 # using the crossbuild tools generated by the last buildworld. It is
657 # the safest (but also the most time consuming) way to build a new kernel.
659 buildkernel: bk_tools bk_build_list bk_kernwarn
660 .for _kernel in ${BUILDKERNELS}
661 @echo "--------------------------------------------------------------"
662 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
663 @echo "--------------------------------------------------------------"
664 @echo "===> ${_kernel}"
665 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
666 rm -rf ${KRNLOBJDIR}/${_kernel}
668 @if [ -f ${KRNLOBJDIR}/${_kernel}/.nativekernel_run ]; then \
669 echo "YOU ARE REBUILDING WITH BUILDKERNEL, REMOVING OLD NATIVEKERNEL BUILD"; \
670 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
672 mkdir -p ${KRNLOBJDIR}
673 .if !defined(NO_KERNELCONFIG)
675 PATH=${STRICTTMPPATH} \
676 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
677 ${KERNCONFDIR}/${_kernel}
679 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
680 echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
682 touch ${KRNLOBJDIR}/${_kernel}/.buildkernel_run
683 .if !defined(NO_KERNELDEPEND)
684 cd ${KRNLOBJDIR}/${_kernel}; \
685 ${KMAKEENV} make KERNEL=${INSTKERNNAME} depend
687 cd ${KRNLOBJDIR}/${_kernel}; \
688 ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
689 @echo "--------------------------------------------------------------"
690 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
691 @echo "--------------------------------------------------------------"
694 # The nativekernel target rebuilds the specified kernels from scratch
695 # using the system's standard compiler rather than using the crossbuild
696 # tools generated by the last buildworld. This is fairly safe if your
697 # system is reasonable up-to-date.
699 nativekernel: bk_build_list bk_kernwarn
700 .for _kernel in ${BUILDKERNELS}
701 @echo "--------------------------------------------------------------"
702 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
703 @echo "--------------------------------------------------------------"
704 @echo "===> ${_kernel}"
705 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
706 rm -rf ${KRNLOBJDIR}/${_kernel}
708 @if [ -f ${KRNLOBJDIR}/${_kernel}/.buildkernel_run ]; then \
709 echo "YOU ARE REBUILDING WITH NATIVEKERNEL, REMOVING OLD BUILDKERNEL BUILD"; \
710 rm -rf ${KRNLOBJDIR}/${_kernel}; fi
712 mkdir -p ${KRNLOBJDIR}
713 .if !defined(NO_KERNELCONFIG)
715 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
716 ${KERNCONFDIR}/${_kernel}
718 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN) && defined(KERNEL_VERSION_${_kernel})
719 echo ${KERNEL_VERSION_${_kernel}} > ${KRNLOBJDIR}/${_kernel}/version
721 touch ${KRNLOBJDIR}/${_kernel}/.nativekernel_run
722 cd ${KRNLOBJDIR}/${_kernel}; \
723 MAKESRCPATH=${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm \
724 make -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/disk/aic7xxx/aicasm/Makefile
725 .if !defined(NO_KERNELDEPEND)
726 cd ${KRNLOBJDIR}/${_kernel}; \
727 make KERNEL=${INSTKERNNAME} depend
729 cd ${KRNLOBJDIR}/${_kernel}; \
730 make KERNEL=${INSTKERNNAME} all
731 @echo "--------------------------------------------------------------"
732 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
733 @echo "--------------------------------------------------------------"
736 # The quickkernel target rebuilds the specified kernels as quickly
737 # as possible. It will use the native tools or the buildworld cross tools
738 # based on whether the kernel was originally generated via buildkernel or
739 # nativekernel. Config is rerun but the object hierarchy is not rebuilt,
740 # nor is the make depend step run.
742 quickkernel: maybe_bk_tools bk_build_list bk_kernwarn
743 .for _kernel in ${BUILDKERNELS}
744 @echo "--------------------------------------------------------------"
745 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
746 @echo "--------------------------------------------------------------"
747 @echo "===> ${_kernel}"
748 .if exists(${KRNLOBJDIR}/${_kernel}/.buildkernel_run)
749 .if !defined(NO_KERNELCONFIG)
751 PATH=${STRICTTMPPATH} \
752 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
753 ${KERNCONFDIR}/${_kernel}
755 cd ${KRNLOBJDIR}/${_kernel}; \
756 ${KMAKEENV} make KERNEL=${INSTKERNNAME} all
758 .if !defined(NO_KERNELCONFIG)
760 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
761 ${KERNCONFDIR}/${_kernel}
763 cd ${KRNLOBJDIR}/${_kernel}; \
764 make KERNEL=${INSTKERNNAME} all
766 @echo "--------------------------------------------------------------"
767 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
768 @echo "--------------------------------------------------------------"
774 # Install the kernel defined by INSTALLKERNEL
776 installkernel reinstallkernel:
777 @echo "--------------------------------------------------------------"
778 @echo ">>> Kernel install for ${INSTALLKERNEL} started on `LC_ALL=C date`"
779 @echo "--------------------------------------------------------------"
780 .if exists(${KRNLOBJDIR}/${INSTALLKERNEL}/.buildkernel_run)
781 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
782 ${IMAKEENV} make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
784 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
785 make KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
787 @echo "--------------------------------------------------------------"
788 @echo ">>> Kernel install for ${INSTALLKERNEL} completed on `LC_ALL=C date`"
789 @echo "--------------------------------------------------------------"
794 # Build most of the user binaries on the existing system libs and includes.
797 @echo "--------------------------------------------------------------"
798 @echo ">>> Building programs only"
799 @echo "--------------------------------------------------------------"
800 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
801 cd ${.CURDIR}/${_dir}; make DIRPRFX=${_dir}/ all
807 # Install the binaries built by the 'most' target. This does not include
808 # libraries or include files.
811 @echo "--------------------------------------------------------------"
812 @echo ">>> Installing programs only"
813 @echo "--------------------------------------------------------------"
814 .for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
815 cd ${.CURDIR}/${_dir}; make DIRPRFX=${_dir}/ install
819 # ------------------------------------------------------------------------
821 # From here onwards are utility targets used by the 'make world' and
822 # related targets. If your 'world' breaks, you may like to try to fix
823 # the problem and manually run the following targets to attempt to
824 # complete the build. Beware, this is *not* guaranteed to work, you
825 # need to have a pretty good grip on the current state of the system
826 # to attempt to manually finish it. If in doubt, 'make world' again.
829 # bootstrap-tools: Build all tools required to build all tools. Note that
830 # order is important in a number of cases and also note that the bootstrap
831 # and build tools stages have access to earlier binaries they themselves
834 # patch: older patch's do not have -i. This program must be built
835 # first so other bootstrap tools that need to apply patches
837 # [x]install: dependancies on various new install features
838 # rpcgen: old rpcgen used a hardwired cpp path, newer OBJFORMAT_PATH
839 # envs are not compatible with older objformat binaries.
841 .if exists(${.CURDIR}/games) && !defined(NO_GAMES)
842 _strfile= games/fortune/strfile
845 # BSTRAPDIRS1 - must be built in strict order, no parallelism
847 # order is very important. yacc before m4 before flex. flex exec's m4,
848 # m4's parser file needs the latest byacc (insanity!).
850 BSTRAPDIRS1= ${_strfile} \
852 bin/chmod bin/cp bin/cpdup bin/dd bin/mkdir bin/rm bin/echo \
853 bin/test bin/cat bin/ln bin/mv bin/csh bin/expr bin/sh \
854 bin/hostname bin/kill \
855 usr.bin/yacc usr.bin/m4 usr.bin/localedef \
856 usr.bin/uudecode usr.bin/xinstall \
857 usr.bin/rpcgen usr.bin/bmake usr.bin/awk usr.bin/stat \
858 usr.bin/find usr.bin/flex
860 # BSTRAPDIRS2 - may built in parallel
863 usr.bin/sed usr.bin/uname usr.bin/touch \
864 usr.bin/mkdep usr.bin/mktemp usr.bin/lorder usr.bin/file2c \
865 usr.bin/tsort usr.bin/tr usr.bin/join usr.bin/wc usr.bin/basename \
866 usr.bin/gencat usr.bin/chflags usr.bin/expand usr.bin/paste \
867 usr.bin/uuencode usr.bin/hexdump \
868 usr.bin/cap_mkdb usr.bin/true usr.bin/false \
869 usr.bin/cmp usr.bin/xargs usr.bin/id usr.bin/env usr.bin/dirname \
870 usr.bin/tail usr.bin/unifdef usr.bin/tic \
871 usr.sbin/chown usr.sbin/mtree usr.sbin/config \
872 usr.sbin/btxld usr.sbin/zic usr.sbin/makewhatis \
873 gnu/usr.bin/grep usr.bin/sort usr.bin/gzip usr.bin/bzip2 \
874 usr.bin/mkcsmapper usr.bin/mkesdb usr.bin/crunch
876 bootstrap-tools: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
877 touch ${BTOOLSDEST}/.bootstrap_done
879 bootstrap-tools-before:
880 ${LN} -fs /bin/date ${BTOOLSDEST}/bin/date
882 bootstrap-tools-targets1: ${BSTRAPDIRS1:S/^/bstrap-/}
884 bootstrap-tools-targets2: ${BSTRAPDIRS2:S/^/bstrap-/}
886 .ORDER: bootstrap-tools-before bootstrap-tools-targets1 bootstrap-tools-targets2
888 .ORDER: ${BSTRAPDIRS1:S/^/bstrap-/}
890 .for _tool in ${BSTRAPDIRS1} ${BSTRAPDIRS2}
892 ${ECHODIR} "===> ${_tool} (bootstrap-tools)"; \
893 cd ${.CURDIR}/${_tool}; \
894 make DIRPRFX=${_tool}/ obj; \
895 make DIRPRFX=${_tool}/ depend; \
896 make DIRPRFX=${_tool}/ all; \
897 make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
900 # build-tools: Build special purpose build tools.
902 # XXX we may be able to remove or consolidate this into bootstrap-tools
903 # now that we have the native helper (.nx/.no) infrastructure.
905 .if exists(${.CURDIR}/share) && !defined(NO_SHARE)
906 _share= share/syscons/scrnmaps
909 _gcc_common_cross= lib/libz gnu/usr.bin/gmp gnu/usr.bin/mpfr gnu/usr.bin/mpc
910 _gcc50_cross= gnu/usr.bin/cc50
911 _gcc50_tools= gnu/usr.bin/cc50/cc_prep gnu/usr.bin/cc50/cc_tools
912 .if !defined(NO_ALTCOMPILER)
913 _gcc47_cross= gnu/usr.bin/cc47
914 _gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
916 _custom_cross= libexec/customcc
917 _binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
919 BTOOLSDIRS= ${_gcc47_tools} ${_gcc50_tools} ${_share}
921 build-tools: build-tools-targets
922 touch ${BTOOLSDEST}/.build_done
924 build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
926 .ORDER: ${_gcc47_tools:S/^/btools-/}
927 .ORDER: ${_gcc50_tools:S/^/btools-/}
929 .for _tool in ${BTOOLSDIRS}
931 ${ECHODIR} "===> ${_tool} (build-tools)"; \
932 cd ${.CURDIR}/${_tool}; \
933 make DIRPRFX=${_tool}/ obj; \
934 make DIRPRFX=${_tool}/ depend; \
935 make DIRPRFX=${_tool}/ all; \
936 make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
940 # cross-tools: Build cross-building tools
942 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
943 _btxld= usr.sbin/btxld
946 CTOOLSDIRS= ${_btxld} ${_binutils} \
947 usr.bin/objformat usr.bin/crunch/crunchide \
948 ${_gcc_common_cross} \
949 ${_gcc47_cross} ${_gcc50_cross} ${_custom_cross}
951 cross-tools: cross-tools-targets
952 touch ${CTOOLSDEST}/.cross_done
954 cross-tools-targets: ${CTOOLSDIRS:S/^/ctools-/}
956 .for _tool in ${CTOOLSDIRS}
958 ${ECHODIR} "===> ${_tool} (cross-tools)"; \
959 cd ${.CURDIR}/${_tool}; \
960 make DIRPRFX=${_tool}/ obj; \
961 make DIRPRFX=${_tool}/ depend; \
962 make DIRPRFX=${_tool}/ all; \
963 make DIRPRFX=${_tool}/ DESTDIR=${CTOOLSDEST} install
967 # hierarchy - ensure that all the needed directories are present
970 cd ${.CURDIR}/etc; make distrib-dirs
973 # libraries - build all libraries, and install them under ${DESTDIR}.
975 # The list of libraries with dependents (${_prebuild_libs}) and their
976 # interdependencies (__L) are built automatically by the
977 # ${.CURDIR}/tools/make_libdeps.sh script.
979 # .makeenv does not work when bootstrapping from 4.x, so we must be sure
980 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
984 HOST_CCVER=${HOST_CCVER} CCVER=gcc50 \
985 make -f Makefile.inc1 _startup_libs50 -DSYSBUILD;
986 .if !defined(NO_ALTCOMPILER)
988 HOST_CCVER=${HOST_CCVER} CCVER=gcc47 \
989 make -f Makefile.inc1 _startup_libs47 -DSYSBUILD;
992 make -f Makefile.inc1 _startup_libs -DSYSBUILD; \
993 make -f Makefile.inc1 _prebuild_libs -DSYSBUILD; \
994 make -f Makefile.inc1 _generic_libs -DSYSBUILD;
995 touch ${WORLDDEST}/.libraries_done
997 # These dependencies are not automatically generated:
999 # gnu/lib/${CCVER}/libgcc and gnu/lib/${CCVER}/csu must be built before all
1000 # shared libraries for ELF. The target for _startup_libsXX is
1001 # specifically built using gccXX.
1003 _startup_libs47= gnu/usr.bin/cc47/cc_prep \
1004 gnu/usr.bin/cc47/cc_tools \
1006 gnu/lib/gcc47/libgcc \
1007 gnu/lib/gcc47/libgcc_eh \
1008 gnu/lib/gcc47/libgcc_pic
1009 _startup_libs50= gnu/usr.bin/cc50/cc_prep \
1010 gnu/usr.bin/cc50/cc_tools \
1012 gnu/lib/gcc50/libgcc \
1013 gnu/lib/gcc50/libgcc_eh \
1014 gnu/lib/gcc50/libgcc_pic
1015 _startup_libs= lib/csu lib/libc lib/libc_rtld
1017 _prebuild_libs= lib/libbz2 lib/liblzma lib/libz
1018 _prebuild_libs+= lib/libutil
1020 _prebuild_libs+= lib/libpcap
1022 _generic_libs= gnu/lib
1024 _prebuild_libs+= lib/libcrypt lib/libmd \
1025 lib/libncurses/libncurses lib/libopie
1027 lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
1031 .if !defined(NO_CRYPT)
1032 .if !defined(NO_OPENSSL)
1033 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
1034 .if !defined(NO_OPENSSH)
1035 _prebuild_libs+= secure/lib/libssh
1036 secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
1039 _generic_libs+= secure/lib
1042 _prebuild_libs+= lib/libradius lib/libsbuf lib/libtacplus lib/libm \
1043 lib/libpam lib/libypclnt lib/lib${THREAD_LIB} \
1044 lib/libpthread lib/libprop lib/libdevattr
1046 _generic_libs+= usr.bin/flex/lib
1048 .for _lib in ${_startup_libs47} ${_startup_libs50} \
1049 ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
1051 .if exists(${.CURDIR}/${_lib})
1052 ${ECHODIR} "===> ${_lib}"; \
1053 cd ${.CURDIR}/${_lib}; \
1054 make DIRPRFX=${_lib}/ depend; \
1055 make DIRPRFX=${_lib}/ all; \
1056 make DIRPRFX=${_lib}/ install
1060 _startup_libs: ${_startup_libs:S/$/__L/}
1061 _startup_libs47: ${_startup_libs47:S/$/__L/}
1062 _startup_libs50: ${_startup_libs50:S/$/__L/}
1063 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1064 _generic_libs: ${_generic_libs:S/$/__L/}
1066 # library targets must be ordered because there are inter-library
1067 # races (e.g. generation of tconfig.h)
1069 .ORDER: ${_startup_libs47:S/$/__L/}
1070 .ORDER: ${_startup_libs50:S/$/__L/}
1071 .ORDER: ${_startup_libs:S/$/__L/}
1072 .ORDER: ${_prebuild_libs:S/$/__L/}
1073 .ORDER: ${_generic_libs:S/$/__L/}
1075 .for __target in clean cleandepend cleandir obj depend includes
1076 .for entry in ${SUBDIR}
1077 ${entry}.${__target}__D: .PHONY
1078 @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1079 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
1080 edir=${entry}.${MACHINE_ARCH}; \
1081 cd ${.CURDIR}/$${edir}; \
1083 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
1085 cd ${.CURDIR}/$${edir}; \
1087 make ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1089 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1090 .ORDER: ${SUBDIR:S/$/.${__target}__D/}
1092 .ORDER: par-clean par-cleandepend par-cleandir par-obj par-depend par-includes
1094 # The wmake target is used by /usr/bin/wmake to run make in a
1095 # world build environment.
1098 @echo '${WMAKEENV} make ${WMAKE_ARGS} -DSYSBUILD'
1101 @echo '${WMAKEENV} /bin/sh'
1104 @echo '${BMAKEENV} make ${BMAKE_ARGS} -DSYSBUILD'
1107 @echo '${BMAKEENV} /bin/sh'
1110 @echo '${TMAKEENV} make ${TMAKE_ARGS} -DSYSBUILD'
1113 @echo '${TMAKEENV} /bin/sh'
1116 @echo '${XMAKEENV} make ${XMAKE_ARGS} -DSYSBUILD'
1119 @echo '${XMAKEENV} /bin/sh'
1121 backupworld: backup-clean
1122 @mkdir -p ${WORLD_BACKUP}
1123 .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1124 exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1125 exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1126 tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1127 --options gzip:compression-level=1 \
1128 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1132 .if !defined(NO_BACKUP)
1133 rm -f ${AUTO_BACKUP}/binaries.tar.gz
1134 @mkdir -p ${AUTO_BACKUP}
1135 .if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1136 exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1137 exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1138 /usr/bin/tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1139 --options gzip:compression-level=1 \
1140 sbin bin usr/sbin usr/bin usr/lib usr/libexec
1145 rm -f ${AUTO_BACKUP}/binaries.tar.gz
1148 rm -f ${WORLD_BACKUP}/binaries.tar.gz
1151 .if !exists(${WORLD_BACKUP}/binaries.tar.gz)
1152 @echo "There does not seem to be a valid archive present."
1154 @echo "Restoring system binaries from manual backup archive..."
1155 @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1156 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1157 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1158 tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1162 .if !exists(${AUTO_BACKUP}/binaries.tar.gz)
1163 @echo "There does not seem to be a valid archive present."
1165 @echo "Restoring system binaries from auto-backup archive..."
1166 @chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1167 ${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1168 ${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1169 tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1172 # Take advantage of bmake error response
1174 MAKE_PRINT_VAR_ON_ERROR= \
1185 .include <bsd.subdir.mk>