4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DNO_SHARE do not go into share subdir
8 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
12 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
13 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
14 # TARGET="machine" to crossbuild world for a different machine type
17 # The intended user-driven targets are:
18 # buildworld - rebuild *everything*, including glue to help do upgrades
19 # installworld- install everything built by "buildworld"
20 # doxygen - build API documentation of the kernel
21 # update - convenient way to update your source tree (eg: cvsup/cvs)
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
29 # We must do share/info early so that installation of info `dir'
30 # entries works correctly. Do it first since it is less likely to
31 # grow dependencies on include and lib than vice versa.
33 # We must do lib/ and libexec/ before bin/, because if installworld
34 # installs a new /bin/sh, the 'make' command will *immediately*
35 # use that new version. And the new (dynamically-linked) /bin/sh
36 # will expect to find appropriate libraries in /lib and /libexec.
38 SUBDIR= share/info lib libexec
40 .if ${MK_GAMES} != "no"
43 .if ${MK_CDDL} != "no"
47 .if ${MK_KERBEROS} != "no"
50 .if ${MK_RESCUE} != "no"
54 .if ${MK_CRYPT} != "no"
57 .if !defined(NO_SHARE)
60 SUBDIR+=sys usr.bin usr.sbin
62 # We must do etc/ last for install/distribute to work.
66 # These are last, since it is nice to at least get the base system
67 # rebuilt before you do them.
68 .for _DIR in ${LOCAL_DIRS}
69 .if exists(${.CURDIR}/${_DIR}/Makefile)
74 .if defined(SUBDIR_OVERRIDE)
75 SUBDIR= ${SUBDIR_OVERRIDE}
81 .if defined(NO_CLEANDIR)
82 CLEANDIR= clean cleandepend
88 CVSFLAGS?= -A -P -d -I!
92 SUPFLAGS+= -h ${SUPHOST}
95 MAKEOBJDIRPREFIX?= /usr/obj
96 .if !defined(OSRELDATE)
97 .if exists(/usr/include/osreldate.h)
98 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
99 /usr/include/osreldate.h
105 # Guess machine architecture from machine type, and vice versa.
106 .if !defined(TARGET_ARCH) && defined(TARGET)
107 TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
108 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
109 ${TARGET_ARCH} != ${MACHINE_ARCH}
110 TARGET= ${TARGET_ARCH}
112 # Otherwise, default to current machine type and architecture.
114 TARGET_ARCH?= ${MACHINE_ARCH}
116 KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
117 .if ${TARGET} == ${TARGET_ARCH}
120 _t= ${TARGET_ARCH}/${TARGET}
123 .if empty(KNOWN_ARCHES:M${_t})
124 .error Unknown target ${TARGET_ARCH}:${TARGET}.
128 .if ${TARGET} == ${MACHINE}
129 TARGET_CPUTYPE?=${CPUTYPE}
134 .if !empty(TARGET_CPUTYPE)
135 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
137 _TARGET_CPUTYPE=dummy
139 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
140 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
141 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
142 .error CPUTYPE global should be set with ?=.
145 BUILD_ARCH!= uname -p
146 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
147 .error To cross-build, set TARGET_ARCH.
150 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
151 OBJTREE= ${MAKEOBJDIRPREFIX}
153 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
155 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
156 # /usr/games added for fortune which depend on strfile
157 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
158 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
159 STRICTTMPPATH= ${BPATH}:${XPATH}
160 TMPPATH= ${STRICTTMPPATH}:${PATH}
163 # Avoid running mktemp(1) unless actually needed.
164 # It may not be functional, e.g., due to new ABI
165 # when in the middle of installing over this system.
167 .if make(distributeworld) || make(installworld)
168 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
172 # Building a world goes through the following stages
174 # 1. legacy stage [BMAKE]
175 # This stage is responsible for creating compatibility
176 # shims that are needed by the bootstrap-tools,
177 # build-tools and cross-tools stages.
178 # 1. bootstrap-tools stage [BMAKE]
179 # This stage is responsible for creating programs that
180 # are needed for backward compatibility reasons. They
181 # are not built as cross-tools.
182 # 2. build-tools stage [TMAKE]
183 # This stage is responsible for creating the object
184 # tree and building any tools that are needed during
186 # 3. cross-tools stage [XMAKE]
187 # This stage is responsible for creating any tools that
188 # are needed for cross-builds. A cross-compiler is one
190 # 4. world stage [WMAKE]
191 # This stage actually builds the world.
192 # 5. install stage (optional) [IMAKE]
193 # This stage installs a previously built world.
198 # Common environment for world related stages
199 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
200 MACHINE_ARCH=${TARGET_ARCH} \
202 CPUTYPE=${TARGET_CPUTYPE} \
203 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
204 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
205 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
207 # bootstrap-tools stage
208 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
209 PATH=${BPATH}:${PATH} \
210 WORLDTMP=${WORLDTMP} \
211 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
212 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
213 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
215 BOOTSTRAPPING=${OSRELDATE} \
216 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
217 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
218 -DNO_CPU_CFLAGS -DNO_WARNS
221 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
222 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
223 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
225 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
228 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
229 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
230 -DWITHOUT_FORTRAN -DWITHOUT_GDB
233 WMAKEENV= ${CROSSENV} \
234 _SHLIBDIRPREFIX=${WORLDTMP} \
235 INSTALL="sh ${.CURDIR}/tools/install.sh" \
237 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
239 .if ${TARGET_ARCH} == "amd64"
241 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
243 .if empty(TARGET_CPUTYPE)
246 LIB32CPUTYPE= ${TARGET_CPUTYPE}
248 LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
249 -iprefix ${LIB32TMP}/usr/ \
250 -L${LIB32TMP}/usr/lib32 \
251 -B${LIB32TMP}/usr/lib32
253 # Yes, the flags are redundant.
254 LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
255 _SHLIBDIRPREFIX=${LIB32TMP} \
258 INSTALL="sh ${.CURDIR}/tools/install.sh" \
260 CC="${CC} ${LIB32FLAGS}" \
261 CXX="${CXX} ${LIB32FLAGS}" \
262 OBJC="${OBJC} ${LIB32FLAGS}" \
263 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
268 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
269 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
270 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
271 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
275 IMAKEENV= ${CROSSENV}
276 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
277 .if empty(.MAKEFLAGS:M-n)
278 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
279 LD_LIBRARY_PATH=${INSTALLTMP} \
280 PATH_LOCALE=${INSTALLTMP}/locale
281 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
283 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
287 KMAKEENV= ${WMAKEENV}
288 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
293 # Attempt to rebuild the entire system, with reasonable chance of
294 # success, regardless of how old your existing system is.
297 .if ${.CURDIR:C/[^,]//g} != ""
298 # The m4 build of sendmail files doesn't like it if ',' is used
299 # anywhere in the path of it's files.
301 @echo "*** Error: path to source tree contains a comma ','"
306 @echo "--------------------------------------------------------------"
307 @echo ">>> Rebuilding the temporary build tree"
308 @echo "--------------------------------------------------------------"
309 .if !defined(NO_CLEAN)
311 .if ${TARGET_ARCH} == "amd64"
315 rm -rf ${WORLDTMP}/legacy/usr/include
316 # XXX - These two can depend on any header file.
317 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
318 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
321 usr/bin usr/games usr/include/sys usr/lib \
322 usr/libexec usr/sbin usr/share/dict \
323 usr/share/groff_font/devX100 \
324 usr/share/groff_font/devX100-12 \
325 usr/share/groff_font/devX75 \
326 usr/share/groff_font/devX75-12 \
327 usr/share/groff_font/devascii \
328 usr/share/groff_font/devcp1047 \
329 usr/share/groff_font/devdvi \
330 usr/share/groff_font/devhtml \
331 usr/share/groff_font/devkoi8-r \
332 usr/share/groff_font/devlatin1 \
333 usr/share/groff_font/devlbp \
334 usr/share/groff_font/devlj4 \
335 usr/share/groff_font/devps \
336 usr/share/groff_font/devutf8 \
337 usr/share/tmac/mdoc usr/share/tmac/mm
338 mkdir -p ${WORLDTMP}/legacy/${_dir}
341 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
342 usr/libexec usr/sbin usr/share/misc
343 mkdir -p ${WORLDTMP}/${_dir}
345 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
346 -p ${WORLDTMP}/usr/include >/dev/null
347 ln -sf ${.CURDIR}/sys ${WORLDTMP}
348 .if ${MK_BIND_LIBS} != "no"
349 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
350 -p ${WORLDTMP}/usr/include >/dev/null
354 @echo "--------------------------------------------------------------"
355 @echo ">>> stage 1.1: legacy release compatibility shims"
356 @echo "--------------------------------------------------------------"
357 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
360 @echo "--------------------------------------------------------------"
361 @echo ">>> stage 1.2: bootstrap tools"
362 @echo "--------------------------------------------------------------"
363 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
365 .if !defined(NO_CLEAN)
367 @echo "--------------------------------------------------------------"
368 @echo ">>> stage 2.1: cleaning up the object tree"
369 @echo "--------------------------------------------------------------"
370 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
371 .if ${TARGET_ARCH} == "amd64"
372 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
377 @echo "--------------------------------------------------------------"
378 @echo ">>> stage 2.2: rebuilding the object tree"
379 @echo "--------------------------------------------------------------"
380 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
383 @echo "--------------------------------------------------------------"
384 @echo ">>> stage 2.3: build tools"
385 @echo "--------------------------------------------------------------"
386 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
389 @echo "--------------------------------------------------------------"
390 @echo ">>> stage 3: cross tools"
391 @echo "--------------------------------------------------------------"
392 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
395 @echo "--------------------------------------------------------------"
396 @echo ">>> stage 4.1: building includes"
397 @echo "--------------------------------------------------------------"
398 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
401 @echo "--------------------------------------------------------------"
402 @echo ">>> stage 4.2: building libraries"
403 @echo "--------------------------------------------------------------"
404 ${_+_}cd ${.CURDIR}; \
405 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
406 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
409 @echo "--------------------------------------------------------------"
410 @echo ">>> stage 4.3: make dependencies"
411 @echo "--------------------------------------------------------------"
412 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
415 @echo "--------------------------------------------------------------"
416 @echo ">>> stage 4.4: building everything"
417 @echo "--------------------------------------------------------------"
418 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
419 .if ${TARGET_ARCH} == "amd64"
422 @echo "--------------------------------------------------------------"
423 @echo ">>> stage 5.1: building 32 bit shim libraries"
424 @echo "--------------------------------------------------------------"
426 usr/include usr/lib32 usr/share/misc
427 mkdir -p ${LIB32TMP}/${_dir}
429 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
430 -p ${LIB32TMP}/usr/include >/dev/null
432 ln -sf ${.CURDIR}/sys ${WORLDTMP}
433 .if ${MK_KERBEROS} != "no"
434 .for _t in obj depend all
435 cd ${.CURDIR}/kerberos5/tools; \
436 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
439 .for _t in obj includes
440 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
441 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
442 .if ${MK_CDDL} != "no"
443 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
445 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
446 .if ${MK_CRYPT} != "no"
447 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
449 .if ${MK_KERBEROS} != "no"
450 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
453 .for _dir in usr.bin/lex/lib
454 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
456 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
457 cd ${.CURDIR}/${_dir}; \
458 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
461 ${LIB32WMAKE} -f Makefile.inc1 libraries
462 .for _t in obj depend all
463 cd ${.CURDIR}/libexec/rtld-elf; \
464 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
467 distribute32 install32:
468 .if make(distribute32)
469 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
471 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
473 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
474 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
475 .if ${MK_CRYPT} != "no"
476 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
478 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
483 .if !defined(SUBDIR_OVERRIDE)
484 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
486 WMAKE_TGTS+= _cleanobj _obj _build-tools
487 .if !defined(SUBDIR_OVERRIDE)
488 WMAKE_TGTS+= _cross-tools
490 WMAKE_TGTS+= _includes _libraries _depend everything
491 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
495 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
496 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
499 @echo "--------------------------------------------------------------"
500 @echo ">>> World build started on `LC_ALL=C date`"
501 @echo "--------------------------------------------------------------"
505 @echo "--------------------------------------------------------------"
506 @echo ">>> World build completed on `LC_ALL=C date`"
507 @echo "--------------------------------------------------------------"
510 # We need to have this as a target because the indirection between Makefile
511 # and Makefile.inc1 causes the correct PATH to be used, rather than a
512 # modification of the current environment's PATH. In addition, we need
513 # to quote multiword values.
519 @echo Entering world for ${TARGET_ARCH}:${TARGET}
520 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
522 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
523 toolchain: ${TOOLCHAIN_TGTS}
524 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
529 # Checks to be sure system is ready for installworld/installkernel.
534 # Require DESTDIR to be set if installing for a different architecture.
536 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
537 .if !make(distributeworld)
538 installcheck: installcheck_DESTDIR
539 installcheck_DESTDIR:
540 .if !defined(DESTDIR) || empty(DESTDIR)
541 @echo "ERROR: Please set DESTDIR!"; \
548 # Check for missing UIDs/GIDs.
552 .if ${MK_SENDMAIL} != "no"
558 CHECK_GIDS+= proxy authpf
560 installcheck: installcheck_UGID
562 .for uid in ${CHECK_UIDS}
563 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
564 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
568 .for gid in ${CHECK_GIDS}
569 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
570 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
576 # Required install tools to be saved in a scratch dir for safety.
578 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
579 date echo egrep find grep install-info \
580 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
581 test true uname wc zic
586 # Distributes everything compiled by a `buildworld'.
590 # Installs everything compiled by a 'buildworld'.
592 distributeworld installworld: installcheck
593 mkdir -p ${INSTALLTMP}
594 progs=$$(for prog in ${ITOOLS}; do \
595 if progpath=`which $$prog`; then \
598 echo "Required tool $$prog not found in PATH." >&2; \
602 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
603 while read line; do \
605 if [ "$$2 $$3" != "not found" ]; then \
608 echo "Required library $$1 not found." >&2; \
612 cp $$libs $$progs ${INSTALLTMP}
613 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
614 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
615 ${IMAKEENV} rm -rf ${INSTALLTMP}
620 # If you have a build server, you can NFS mount the source and obj directories
621 # and do a 'make reinstall' on the *client* to install new binaries from the
622 # most recent server build.
625 @echo "--------------------------------------------------------------"
626 @echo ">>> Making hierarchy"
627 @echo "--------------------------------------------------------------"
628 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
630 @echo "--------------------------------------------------------------"
631 @echo ">>> Installing everything"
632 @echo "--------------------------------------------------------------"
633 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
634 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
635 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
639 @echo "--------------------------------------------------------------"
640 @echo ">>> Distributing everything"
641 @echo "--------------------------------------------------------------"
642 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
643 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
644 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
647 distrib-dirs distribution:
648 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
651 # buildkernel and installkernel
653 # Which kernels to build and/or install is specified by setting
654 # KERNCONF. If not defined a GENERIC kernel is built/installed.
655 # Only the existing (depending TARGET) config files are used
656 # for building kernels and only the first of these is designated
657 # as the one being installed.
659 # Note that we have to use TARGET instead of TARGET_ARCH when
660 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
661 # be set to cross-build, we have to make sure TARGET is set
664 .if !defined(KERNCONF) && defined(KERNEL)
670 INSTKERNNAME?= kernel
672 KERNSRCDIR?= ${.CURDIR}/sys
673 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
674 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
675 KERNCONFDIR?= ${KRNLCONFDIR}
679 .for _kernel in ${KERNCONF}
680 .if exists(${KERNCONFDIR}/${_kernel})
681 BUILDKERNELS+= ${_kernel}
682 .if empty(INSTALLKERNEL)
683 INSTALLKERNEL= ${_kernel}
691 # Builds all kernels defined by BUILDKERNELS.
694 .if empty(BUILDKERNELS)
695 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
698 .if defined(KERNWARN)
699 @echo "--------------------------------------------------------------"
700 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
701 @echo "--------------------------------------------------------------"
705 .for _kernel in ${BUILDKERNELS}
706 @echo "--------------------------------------------------------------"
707 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
708 @echo "--------------------------------------------------------------"
709 @echo "===> ${_kernel}"
710 mkdir -p ${KRNLOBJDIR}
711 .if !defined(NO_KERNELCONFIG)
713 @echo "--------------------------------------------------------------"
714 @echo ">>> stage 1: configuring the kernel"
715 @echo "--------------------------------------------------------------"
718 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
719 ${KERNCONFDIR}/${_kernel}
721 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
723 @echo "--------------------------------------------------------------"
724 @echo ">>> stage 2.1: cleaning up the object tree"
725 @echo "--------------------------------------------------------------"
726 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
729 @echo "--------------------------------------------------------------"
730 @echo ">>> stage 2.2: rebuilding the object tree"
731 @echo "--------------------------------------------------------------"
732 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
734 @echo "--------------------------------------------------------------"
735 @echo ">>> stage 2.3: build tools"
736 @echo "--------------------------------------------------------------"
737 cd ${KRNLOBJDIR}/${_kernel}; \
738 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
739 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
740 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
741 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
742 .for target in obj depend all
743 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
744 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
745 ${MAKE} -DNO_CPU_CFLAGS ${target}
748 .if !defined(NO_KERNELDEPEND)
750 @echo "--------------------------------------------------------------"
751 @echo ">>> stage 3.1: making dependencies"
752 @echo "--------------------------------------------------------------"
753 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
756 @echo "--------------------------------------------------------------"
757 @echo ">>> stage 3.2: building everything"
758 @echo "--------------------------------------------------------------"
759 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
760 @echo "--------------------------------------------------------------"
761 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
762 @echo "--------------------------------------------------------------"
766 # installkernel, etc.
768 # Install the kernel defined by INSTALLKERNEL
770 installkernel installkernel.debug \
771 reinstallkernel reinstallkernel.debug: installcheck
772 .if empty(INSTALLKERNEL)
773 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
776 @echo "--------------------------------------------------------------"
777 @echo ">>> Installing kernel"
778 @echo "--------------------------------------------------------------"
779 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
780 ${CROSSENV} PATH=${TMPPATH} \
781 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
786 # Build the API documentation with doxygen
789 @if [ ! -x `/usr/bin/which doxygen` ]; then \
790 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
793 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
798 # Update the source tree, by running cvsup and/or running cvs to update to the
802 .if defined(SUP_UPDATE)
803 @echo "--------------------------------------------------------------"
804 @echo ">>> Running ${SUP}"
805 @echo "--------------------------------------------------------------"
807 @${SUP} ${SUPFLAGS} ${SUPFILE}
809 .if defined(SUPFILE1)
810 @${SUP} ${SUPFLAGS} ${SUPFILE1}
812 .if defined(SUPFILE2)
813 @${SUP} ${SUPFLAGS} ${SUPFILE2}
815 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
816 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
818 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
819 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
822 .if defined(CVS_UPDATE)
823 @echo "--------------------------------------------------------------"
824 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
825 @echo "--------------------------------------------------------------"
826 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
830 # ------------------------------------------------------------------------
832 # From here onwards are utility targets used by the 'make world' and
833 # related targets. If your 'world' breaks, you may like to try to fix
834 # the problem and manually run the following targets to attempt to
835 # complete the build. Beware, this is *not* guaranteed to work, you
836 # need to have a pretty good grip on the current state of the system
837 # to attempt to manually finish it. If in doubt, 'make world' again.
841 # legacy: Build compatibility shims for the next three targets
844 .if ${BOOTSTRAPPING} < 503000
845 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
848 .for _tool in tools/build
849 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
850 cd ${.CURDIR}/${_tool}; \
851 ${MAKE} DIRPRFX=${_tool}/ obj; \
852 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
853 ${MAKE} DIRPRFX=${_tool}/ depend; \
854 ${MAKE} DIRPRFX=${_tool}/ all; \
855 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
859 # bootstrap-tools: Build tools needed for compatibility
861 .if ${MK_GAMES} != "no"
862 _strfile= games/fortune/strfile
865 .if ${MK_CXX} != "no"
866 _gperf= gnu/usr.bin/gperf
867 .if ${BOOTSTRAPPING} < 700004
868 _groff= gnu/usr.bin/groff
870 _groff= gnu/usr.bin/groff/tmac
874 .if ${BOOTSTRAPPING} < 600029
875 _texinfo= gnu/usr.bin/texinfo
878 .if ${BOOTSTRAPPING} < 600015
879 _cap_mkdb= usr.bin/cap_mkdb
882 .if ${BOOTSTRAPPING} < 600018
883 _colldef= usr.bin/colldef
886 .if ${BOOTSTRAPPING} < 600017
887 _gencat= usr.bin/gencat
890 .if ${BOOTSTRAPPING} < 600016
891 _mklocale= usr.bin/mklocale
894 .if ${BOOTSTRAPPING} < 700018
895 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
898 .if ${MK_RESCUE} != "no" && \
899 ${BOOTSTRAPPING} < 700026
900 _crunchgen= usr.sbin/crunch/crunchgen
903 .if ${BOOTSTRAPPING} < 600020
904 _pwd_mkdb= usr.sbin/pwd_mkdb
925 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
926 cd ${.CURDIR}/${_tool}; \
927 ${MAKE} DIRPRFX=${_tool}/ obj; \
928 ${MAKE} DIRPRFX=${_tool}/ depend; \
929 ${MAKE} DIRPRFX=${_tool}/ all; \
930 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
934 # build-tools: Build special purpose build tools
936 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
937 _aicasm= sys/modules/aic7xxx/aicasm
940 .if !defined(NO_SHARE)
941 _share= share/syscons/scrnmaps
944 .if ${MK_KERBEROS} != "no"
945 _kerberos5_tools= kerberos5/tools
948 .if ${MK_RESCUE} != "no"
949 _rescue= rescue/rescue
957 lib/ncurses/ncurses \
958 lib/ncurses/ncursesw \
964 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
965 cd ${.CURDIR}/${_tool}; \
966 ${MAKE} DIRPRFX=${_tool}/ obj; \
967 ${MAKE} DIRPRFX=${_tool}/ build-tools
970 gnu/usr.bin/cc/cc_tools \
972 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
973 cd ${.CURDIR}/${_tool}; \
974 ${MAKE} DIRPRFX=${_tool}/ obj; \
975 ${MAKE} DIRPRFX=${_tool}/ depend; \
976 ${MAKE} DIRPRFX=${_tool}/ all
980 # cross-tools: Build cross-building tools
982 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
983 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
984 _btxld= usr.sbin/btxld
986 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
987 _crunchide= usr.sbin/crunch/crunchide
989 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
990 _kgzip= usr.sbin/kgzip
996 gnu/usr.bin/binutils \
999 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1003 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1004 cd ${.CURDIR}/${_tool}; \
1005 ${MAKE} DIRPRFX=${_tool}/ obj; \
1006 ${MAKE} DIRPRFX=${_tool}/ depend; \
1007 ${MAKE} DIRPRFX=${_tool}/ all; \
1008 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1012 # hierarchy - ensure that all the needed directories are present
1015 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
1018 # libraries - build all libraries, and install them under ${DESTDIR}.
1020 # The list of libraries with dependents (${_prebuild_libs}) and their
1021 # interdependencies (__L) are built automatically by the
1022 # ${.CURDIR}/tools/make_libdeps.sh script.
1026 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1027 ${MAKE} -f Makefile.inc1 _startup_libs; \
1028 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1029 ${MAKE} -f Makefile.inc1 _generic_libs;
1032 # static libgcc.a prerequisite for shared libc
1034 _prereq_libs= gnu/lib/libgcc
1036 # These dependencies are not automatically generated:
1038 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1039 # all shared libraries for ELF.
1041 _startup_libs= gnu/lib/csu
1042 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1043 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1045 _startup_libs+= lib/csu/${MACHINE_ARCH}
1047 _startup_libs+= gnu/lib/libgcc
1048 _startup_libs+= lib/libc
1050 gnu/lib/libgcc__L: lib/libc__L
1052 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1053 ${_kerberos5_lib_libroken} \
1054 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1055 ${_lib_libgssapi} ${_lib_libipx} \
1056 lib/libkiconv lib/libkvm lib/libmd \
1057 lib/ncurses/ncurses lib/ncurses/ncursesw \
1058 lib/libopie lib/libpam ${_default_thread_lib} \
1059 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1060 ${_lib_libypclnt} lib/libz lib/msun \
1061 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1062 ${_secure_lib_libssl}
1064 .if ${MK_LIBTHR} != "no" && ${MK_LIBKSE} != "no"
1065 _default_thread_lib= lib/${DEFAULT_THREAD_LIB}
1066 .elif ${MK_LIBTHR} != "no"
1067 _default_thread_lib= lib/libthr
1068 .elif ${MK_LIBKSE} != "no"
1069 _default_thread_lib= lib/libkse
1072 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1074 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1076 .if ${MK_CDDL} != "no"
1080 .if ${MK_CRYPT} != "no"
1081 .if ${MK_OPENSSL} != "no"
1082 _secure_lib_libcrypto= secure/lib/libcrypto
1083 _secure_lib_libssl= secure/lib/libssl
1084 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1085 .if ${MK_OPENSSH} != "no"
1086 _secure_lib_libssh= secure/lib/libssh
1087 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1088 .if ${MK_KERBEROS} != "no"
1089 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1090 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1091 kerberos5/lib/libroken__L
1095 _secure_lib= secure/lib
1098 .if ${MK_IPX} != "no"
1099 _lib_libipx= lib/libipx
1102 .if ${MK_KERBEROS} != "no"
1103 _kerberos5_lib= kerberos5/lib
1104 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1105 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1106 _kerberos5_lib_libroken= kerberos5/lib/libroken
1107 _lib_libgssapi= lib/libgssapi
1110 .if ${MK_NIS} != "no"
1111 _lib_libypclnt= lib/libypclnt
1114 .if ${MK_OPENSSL} == "no"
1115 lib/libradius__L: lib/libmd__L
1118 .for _lib in ${_prereq_libs}
1120 .if exists(${.CURDIR}/${_lib})
1121 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1122 cd ${.CURDIR}/${_lib}; \
1123 ${MAKE} DIRPRFX=${_lib}/ obj; \
1124 ${MAKE} DIRPRFX=${_lib}/ depend; \
1125 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1126 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1130 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1132 .if exists(${.CURDIR}/${_lib})
1133 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1134 cd ${.CURDIR}/${_lib}; \
1135 ${MAKE} DIRPRFX=${_lib}/ obj; \
1136 ${MAKE} DIRPRFX=${_lib}/ depend; \
1137 ${MAKE} DIRPRFX=${_lib}/ all; \
1138 ${MAKE} DIRPRFX=${_lib}/ install
1142 # libpam is special: we need to build static PAM modules before
1143 # static PAM library, and dynamic PAM library before dynamic PAM
1145 lib/libpam__L: .PHONY
1146 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1147 cd ${.CURDIR}/lib/libpam; \
1148 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1149 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1150 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1151 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1153 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1154 _startup_libs: ${_startup_libs:S/$/__L/}
1155 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1156 _generic_libs: ${_generic_libs:S/$/__L/}
1158 .for __target in all clean cleandepend cleandir depend includes obj
1159 .for entry in ${SUBDIR}
1160 ${entry}.${__target}__D: .PHONY
1161 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1162 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1163 edir=${entry}.${MACHINE_ARCH}; \
1164 cd ${.CURDIR}/$${edir}; \
1166 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1168 cd ${.CURDIR}/$${edir}; \
1170 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1172 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1175 .include <bsd.subdir.mk>
1177 .if make(check-old) || make(check-old-dirs) || \
1178 make(check-old-files) || make(check-old-libs) || \
1179 make(delete-old) || make(delete-old-dirs) || \
1180 make(delete-old-files) || make(delete-old-libs)
1183 # check for / delete old files section
1186 .include "ObsoleteFiles.inc"
1188 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1189 else you can not start such an application. Consult UPDATING for more \
1190 information regarding how to cope with the removal/revision bump of a \
1193 .if !defined(BATCH_DELETE_OLD_FILES)
1200 @echo ">>> Removing old files (only deletes safe to delete libs)"
1201 # Ask for every old file if the user really wants to remove it.
1202 # It's annoying, but better safe than sorry.
1203 @for file in ${OLD_FILES}; do \
1204 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1205 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1206 rm ${RM_I} "${DESTDIR}/$${file}"; \
1209 # Remove catpages without corresponding manpages.
1211 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1212 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1213 while read catpage; do \
1215 if [ ! -e "$${manpage}" ]; then \
1216 rm ${RM_I} $${catpage} <&3 ; \
1219 @echo ">>> Old files removed"
1222 @echo ">>> Checking for old files"
1223 @for file in ${OLD_FILES}; do \
1224 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1225 echo "${DESTDIR}/$${file}"; \
1228 # Check for catpages without corresponding manpages.
1229 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1230 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1231 while read catpage; do \
1233 if [ ! -e "$${manpage}" ]; then \
1234 echo $${catpage} ; \
1239 @echo ">>> Removing old libraries"
1240 @echo "${OLD_LIBS_MESSAGE}" | fmt
1241 @for file in ${OLD_LIBS}; do \
1242 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1243 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1244 rm ${RM_I} "${DESTDIR}/$${file}"; \
1247 @echo ">>> Old libraries removed"
1250 @echo ">>> Checking for old libraries"
1251 @for file in ${OLD_LIBS}; do \
1252 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1253 echo "${DESTDIR}/$${file}"; \
1258 @echo ">>> Removing old directories"
1259 @for dir in ${OLD_DIRS}; do \
1260 if [ -d "${DESTDIR}/$${dir}" ]; then \
1261 rmdir -v "${DESTDIR}/$${dir}" || true; \
1262 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1263 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1266 @echo ">>> Old directories removed"
1269 @echo ">>> Checking for old directories"
1270 @for dir in ${OLD_DIRS}; do \
1271 if [ -d "${DESTDIR}/$${dir}" ]; then \
1272 echo "${DESTDIR}/$${dir}"; \
1273 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1274 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1278 delete-old: delete-old-files delete-old-dirs
1279 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1281 check-old: check-old-files check-old-libs check-old-dirs
1282 @echo "To remove old files and directories run '${MAKE} delete-old'."
1283 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1288 # showconfig - show build configuration.
1291 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort