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?= -r RELENG_7 -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}
162 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
165 # Building a world goes through the following stages
167 # 1. legacy stage [BMAKE]
168 # This stage is responsible for creating compatibility
169 # shims that are needed by the bootstrap-tools,
170 # build-tools and cross-tools stages.
171 # 1. bootstrap-tools stage [BMAKE]
172 # This stage is responsible for creating programs that
173 # are needed for backward compatibility reasons. They
174 # are not built as cross-tools.
175 # 2. build-tools stage [TMAKE]
176 # This stage is responsible for creating the object
177 # tree and building any tools that are needed during
179 # 3. cross-tools stage [XMAKE]
180 # This stage is responsible for creating any tools that
181 # are needed for cross-builds. A cross-compiler is one
183 # 4. world stage [WMAKE]
184 # This stage actually builds the world.
185 # 5. install stage (optional) [IMAKE]
186 # This stage installs a previously built world.
191 # Common environment for world related stages
192 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
193 MACHINE_ARCH=${TARGET_ARCH} \
195 CPUTYPE=${TARGET_CPUTYPE} \
196 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
197 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
198 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
200 # bootstrap-tools stage
201 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
202 PATH=${BPATH}:${PATH} \
203 WORLDTMP=${WORLDTMP} \
204 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
205 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
206 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
208 BOOTSTRAPPING=${OSRELDATE} \
209 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
210 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
211 -DNO_CPU_CFLAGS -DNO_WARNS
214 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
215 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
216 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
218 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
221 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
222 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
226 WMAKEENV= ${CROSSENV} \
227 _SHLIBDIRPREFIX=${WORLDTMP} \
228 INSTALL="sh ${.CURDIR}/tools/install.sh" \
230 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
232 .if ${TARGET_ARCH} == "amd64"
234 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
236 .if empty(TARGET_CPUTYPE)
239 LIB32CPUTYPE= ${TARGET_CPUTYPE}
241 LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
242 -iprefix ${LIB32TMP}/usr/ \
243 -L${LIB32TMP}/usr/lib32 \
244 -B${LIB32TMP}/usr/lib32
246 # Yes, the flags are redundant.
247 LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
248 _SHLIBDIRPREFIX=${LIB32TMP} \
251 INSTALL="sh ${.CURDIR}/tools/install.sh" \
253 CC="${CC} ${LIB32FLAGS}" \
254 CXX="${CXX} ${LIB32FLAGS}" \
255 OBJC="${OBJC} ${LIB32FLAGS}" \
256 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
261 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
262 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
263 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
264 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
268 .if empty(.MAKEFLAGS:M-n)
269 IMAKEENV= ${CROSSENV} \
270 PATH=${STRICTTMPPATH}:${INSTALLTMP}
272 IMAKEENV= ${CROSSENV} \
273 PATH=${TMPPATH}:${INSTALLTMP}
275 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
278 KMAKEENV= ${WMAKEENV}
279 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
284 # Attempt to rebuild the entire system, with reasonable chance of
285 # success, regardless of how old your existing system is.
288 .if ${.CURDIR:C/[^,]//g} != ""
289 # The m4 build of sendmail files doesn't like it if ',' is used
290 # anywhere in the path of it's files.
292 @echo "*** Error: path to source tree contains a comma ','"
297 @echo "--------------------------------------------------------------"
298 @echo ">>> Rebuilding the temporary build tree"
299 @echo "--------------------------------------------------------------"
300 .if !defined(NO_CLEAN)
302 .if ${TARGET_ARCH} == "amd64"
306 rm -rf ${WORLDTMP}/legacy/usr/include
307 # XXX - These three can depend on any header file.
308 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
309 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
310 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
313 usr/bin usr/games usr/include/sys usr/lib \
314 usr/libexec usr/sbin usr/share/dict \
315 usr/share/groff_font/devX100 \
316 usr/share/groff_font/devX100-12 \
317 usr/share/groff_font/devX75 \
318 usr/share/groff_font/devX75-12 \
319 usr/share/groff_font/devascii \
320 usr/share/groff_font/devcp1047 \
321 usr/share/groff_font/devdvi \
322 usr/share/groff_font/devhtml \
323 usr/share/groff_font/devkoi8-r \
324 usr/share/groff_font/devlatin1 \
325 usr/share/groff_font/devlbp \
326 usr/share/groff_font/devlj4 \
327 usr/share/groff_font/devps \
328 usr/share/groff_font/devutf8 \
329 usr/share/tmac/mdoc usr/share/tmac/mm
330 mkdir -p ${WORLDTMP}/legacy/${_dir}
333 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
334 usr/libexec usr/sbin usr/share/misc
335 mkdir -p ${WORLDTMP}/${_dir}
337 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
338 -p ${WORLDTMP}/usr/include >/dev/null
339 ln -sf ${.CURDIR}/sys ${WORLDTMP}
340 .if ${MK_BIND_LIBS} != "no"
341 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
342 -p ${WORLDTMP}/usr/include >/dev/null
346 @echo "--------------------------------------------------------------"
347 @echo ">>> stage 1.1: legacy release compatibility shims"
348 @echo "--------------------------------------------------------------"
349 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
352 @echo "--------------------------------------------------------------"
353 @echo ">>> stage 1.2: bootstrap tools"
354 @echo "--------------------------------------------------------------"
355 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
357 .if !defined(NO_CLEAN)
359 @echo "--------------------------------------------------------------"
360 @echo ">>> stage 2.1: cleaning up the object tree"
361 @echo "--------------------------------------------------------------"
362 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
363 .if ${TARGET_ARCH} == "amd64"
364 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 2.2: rebuilding the object tree"
371 @echo "--------------------------------------------------------------"
372 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
375 @echo "--------------------------------------------------------------"
376 @echo ">>> stage 2.3: 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 4.1: building includes"
389 @echo "--------------------------------------------------------------"
390 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 4.2: building libraries"
395 @echo "--------------------------------------------------------------"
396 ${_+_}cd ${.CURDIR}; \
397 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
398 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
401 @echo "--------------------------------------------------------------"
402 @echo ">>> stage 4.3: make dependencies"
403 @echo "--------------------------------------------------------------"
404 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
407 @echo "--------------------------------------------------------------"
408 @echo ">>> stage 4.4: building everything"
409 @echo "--------------------------------------------------------------"
410 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
411 .if ${TARGET_ARCH} == "amd64"
414 @echo "--------------------------------------------------------------"
415 @echo ">>> stage 5.1: building 32 bit shim libraries"
416 @echo "--------------------------------------------------------------"
418 usr/include usr/lib32 usr/share/misc
419 mkdir -p ${LIB32TMP}/${_dir}
421 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
422 -p ${LIB32TMP}/usr/include >/dev/null
424 ln -sf ${.CURDIR}/sys ${WORLDTMP}
425 .if ${MK_KERBEROS} != "no"
426 .for _t in obj depend all
427 cd ${.CURDIR}/kerberos5/tools; \
428 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
431 .for _t in obj includes
432 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
433 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
434 .if ${MK_CDDL} != "no"
435 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
437 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
438 .if ${MK_CRYPT} != "no"
439 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
441 .if ${MK_KERBEROS} != "no"
442 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
445 .for _dir in usr.bin/lex/lib
446 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
448 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
449 cd ${.CURDIR}/${_dir}; \
450 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
453 ${LIB32WMAKE} -f Makefile.inc1 libraries
454 .for _t in obj depend all
455 cd ${.CURDIR}/libexec/rtld-elf; \
456 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
459 distribute32 install32:
460 .if make(distribute32)
461 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
463 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
465 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
466 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
467 .if ${MK_CRYPT} != "no"
468 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
470 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
475 .if !defined(SUBDIR_OVERRIDE)
476 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
478 WMAKE_TGTS+= _cleanobj _obj _build-tools
479 .if !defined(SUBDIR_OVERRIDE)
480 WMAKE_TGTS+= _cross-tools
482 WMAKE_TGTS+= _includes _libraries _depend everything
483 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
487 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
488 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
491 @echo "--------------------------------------------------------------"
492 @echo ">>> World build started on `LC_ALL=C date`"
493 @echo "--------------------------------------------------------------"
497 @echo "--------------------------------------------------------------"
498 @echo ">>> World build completed on `LC_ALL=C date`"
499 @echo "--------------------------------------------------------------"
502 # We need to have this as a target because the indirection between Makefile
503 # and Makefile.inc1 causes the correct PATH to be used, rather than a
504 # modification of the current environment's PATH. In addition, we need
505 # to quote multiword values.
511 @echo Entering world for ${TARGET_ARCH}:${TARGET}
512 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
514 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
515 toolchain: ${TOOLCHAIN_TGTS}
516 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
521 # Checks to be sure system is ready for installworld/installkernel.
526 # Require DESTDIR to be set if installing for a different architecture.
528 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
529 .if !make(distributeworld)
530 installcheck: installcheck_DESTDIR
531 installcheck_DESTDIR:
532 .if !defined(DESTDIR) || empty(DESTDIR)
533 @echo "ERROR: Please set DESTDIR!"; \
540 # Check for missing UIDs/GIDs.
544 .if ${MK_SENDMAIL} != "no"
550 CHECK_GIDS+= proxy authpf
552 installcheck: installcheck_UGID
554 .for uid in ${CHECK_UIDS}
555 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
556 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
560 .for gid in ${CHECK_GIDS}
561 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
562 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
570 # Distributes everything compiled by a `buildworld'.
574 # Installs everything compiled by a 'buildworld'.
576 distributeworld installworld: installcheck
577 mkdir -p ${INSTALLTMP}
578 for prog in [ 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; do \
582 cp `which $$prog` ${INSTALLTMP}; \
584 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
590 # If you have a build server, you can NFS mount the source and obj directories
591 # and do a 'make reinstall' on the *client* to install new binaries from the
592 # most recent server build.
595 @echo "--------------------------------------------------------------"
596 @echo ">>> Making hierarchy"
597 @echo "--------------------------------------------------------------"
598 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
600 @echo "--------------------------------------------------------------"
601 @echo ">>> Installing everything"
602 @echo "--------------------------------------------------------------"
603 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
604 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
605 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
609 @echo "--------------------------------------------------------------"
610 @echo ">>> Distributing everything"
611 @echo "--------------------------------------------------------------"
612 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
613 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
614 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
617 distrib-dirs distribution:
618 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
621 # buildkernel and installkernel
623 # Which kernels to build and/or install is specified by setting
624 # KERNCONF. If not defined a GENERIC kernel is built/installed.
625 # Only the existing (depending TARGET) config files are used
626 # for building kernels and only the first of these is designated
627 # as the one being installed.
629 # Note that we have to use TARGET instead of TARGET_ARCH when
630 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
631 # be set to cross-build, we have to make sure TARGET is set
634 .if !defined(KERNCONF) && defined(KERNEL)
640 INSTKERNNAME?= kernel
642 KERNSRCDIR?= ${.CURDIR}/sys
643 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
644 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
645 KERNCONFDIR?= ${KRNLCONFDIR}
649 .for _kernel in ${KERNCONF}
650 .if exists(${KERNCONFDIR}/${_kernel})
651 BUILDKERNELS+= ${_kernel}
652 .if empty(INSTALLKERNEL)
653 INSTALLKERNEL= ${_kernel}
661 # Builds all kernels defined by BUILDKERNELS.
664 .if empty(BUILDKERNELS)
665 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
668 .if defined(KERNWARN)
669 @echo "--------------------------------------------------------------"
670 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
671 @echo "--------------------------------------------------------------"
675 .for _kernel in ${BUILDKERNELS}
676 @echo "--------------------------------------------------------------"
677 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
678 @echo "--------------------------------------------------------------"
679 @echo "===> ${_kernel}"
680 mkdir -p ${KRNLOBJDIR}
681 .if !defined(NO_KERNELCONFIG)
683 @echo "--------------------------------------------------------------"
684 @echo ">>> stage 1: configuring the kernel"
685 @echo "--------------------------------------------------------------"
688 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
689 ${KERNCONFDIR}/${_kernel}
691 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
693 @echo "--------------------------------------------------------------"
694 @echo ">>> stage 2.1: cleaning up the object tree"
695 @echo "--------------------------------------------------------------"
696 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
699 @echo "--------------------------------------------------------------"
700 @echo ">>> stage 2.2: rebuilding the object tree"
701 @echo "--------------------------------------------------------------"
702 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
704 @echo "--------------------------------------------------------------"
705 @echo ">>> stage 2.3: build tools"
706 @echo "--------------------------------------------------------------"
707 cd ${KRNLOBJDIR}/${_kernel}; \
708 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
709 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
710 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
711 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
712 .for target in obj depend all
713 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
714 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
715 ${MAKE} -DNO_CPU_CFLAGS ${target}
718 .if !defined(NO_KERNELDEPEND)
720 @echo "--------------------------------------------------------------"
721 @echo ">>> stage 3.1: making dependencies"
722 @echo "--------------------------------------------------------------"
723 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
726 @echo "--------------------------------------------------------------"
727 @echo ">>> stage 3.2: building everything"
728 @echo "--------------------------------------------------------------"
729 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
730 @echo "--------------------------------------------------------------"
731 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
732 @echo "--------------------------------------------------------------"
736 # installkernel, etc.
738 # Install the kernel defined by INSTALLKERNEL
740 installkernel installkernel.debug \
741 reinstallkernel reinstallkernel.debug: installcheck
742 .if empty(INSTALLKERNEL)
743 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
746 @echo "--------------------------------------------------------------"
747 @echo ">>> Installing kernel"
748 @echo "--------------------------------------------------------------"
749 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
750 ${CROSSENV} PATH=${TMPPATH} \
751 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
756 # Build the API documentation with doxygen
759 @if [ ! -x `/usr/bin/which doxygen` ]; then \
760 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
763 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
768 # Update the source tree, by running cvsup and/or running cvs to update to the
772 .if defined(SUP_UPDATE)
773 @echo "--------------------------------------------------------------"
774 @echo ">>> Running ${SUP}"
775 @echo "--------------------------------------------------------------"
777 @${SUP} ${SUPFLAGS} ${SUPFILE}
779 .if defined(SUPFILE1)
780 @${SUP} ${SUPFLAGS} ${SUPFILE1}
782 .if defined(SUPFILE2)
783 @${SUP} ${SUPFLAGS} ${SUPFILE2}
785 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
786 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
788 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
789 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
792 .if defined(CVS_UPDATE)
793 @echo "--------------------------------------------------------------"
794 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
795 @echo "--------------------------------------------------------------"
796 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
800 # ------------------------------------------------------------------------
802 # From here onwards are utility targets used by the 'make world' and
803 # related targets. If your 'world' breaks, you may like to try to fix
804 # the problem and manually run the following targets to attempt to
805 # complete the build. Beware, this is *not* guaranteed to work, you
806 # need to have a pretty good grip on the current state of the system
807 # to attempt to manually finish it. If in doubt, 'make world' again.
811 # legacy: Build compatibility shims for the next three targets
814 .if ${BOOTSTRAPPING} < 503000
815 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
818 .for _tool in tools/build
819 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
820 cd ${.CURDIR}/${_tool}; \
821 ${MAKE} DIRPRFX=${_tool}/ obj; \
822 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
823 ${MAKE} DIRPRFX=${_tool}/ depend; \
824 ${MAKE} DIRPRFX=${_tool}/ all; \
825 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
829 # bootstrap-tools: Build tools needed for compatibility
831 .if ${MK_GAMES} != "no"
832 _strfile= games/fortune/strfile
835 .if ${MK_CXX} != "no"
836 _gperf= gnu/usr.bin/gperf
837 .if ${BOOTSTRAPPING} < 700004
838 _groff= gnu/usr.bin/groff
840 _groff= gnu/usr.bin/groff/tmac
844 .if ${BOOTSTRAPPING} < 600029
845 _texinfo= gnu/usr.bin/texinfo
848 .if ${BOOTSTRAPPING} < 600015
849 _cap_mkdb= usr.bin/cap_mkdb
852 .if ${BOOTSTRAPPING} < 600018
853 _colldef= usr.bin/colldef
856 .if ${BOOTSTRAPPING} < 600017
857 _gencat= usr.bin/gencat
860 .if ${BOOTSTRAPPING} < 600016
861 _mklocale= usr.bin/mklocale
864 .if ${BOOTSTRAPPING} < 700018
865 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
868 .if ${MK_RESCUE} != "no" && \
869 ${BOOTSTRAPPING} < 700026
870 _crunchgen= usr.sbin/crunch/crunchgen
873 .if ${BOOTSTRAPPING} < 600020
874 _pwd_mkdb= usr.sbin/pwd_mkdb
895 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
896 cd ${.CURDIR}/${_tool}; \
897 ${MAKE} DIRPRFX=${_tool}/ obj; \
898 ${MAKE} DIRPRFX=${_tool}/ depend; \
899 ${MAKE} DIRPRFX=${_tool}/ all; \
900 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
904 # build-tools: Build special purpose build tools
906 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
907 _aicasm= sys/modules/aic7xxx/aicasm
910 .if !defined(NO_SHARE)
911 _share= share/syscons/scrnmaps
914 .if ${MK_KERBEROS} != "no"
915 _kerberos5_tools= kerberos5/tools
918 .if ${MK_RESCUE} != "no"
919 _rescue= rescue/rescue
927 lib/ncurses/ncurses \
928 lib/ncurses/ncursesw \
934 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
935 cd ${.CURDIR}/${_tool}; \
936 ${MAKE} DIRPRFX=${_tool}/ obj; \
937 ${MAKE} DIRPRFX=${_tool}/ build-tools
940 gnu/usr.bin/cc/cc_tools \
942 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
943 cd ${.CURDIR}/${_tool}; \
944 ${MAKE} DIRPRFX=${_tool}/ obj; \
945 ${MAKE} DIRPRFX=${_tool}/ depend; \
946 ${MAKE} DIRPRFX=${_tool}/ all
950 # cross-tools: Build cross-building tools
952 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
953 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
954 _btxld= usr.sbin/btxld
956 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
957 _crunchide= usr.sbin/crunch/crunchide
959 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
960 _kgzip= usr.sbin/kgzip
966 gnu/usr.bin/binutils \
969 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
973 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
974 cd ${.CURDIR}/${_tool}; \
975 ${MAKE} DIRPRFX=${_tool}/ obj; \
976 ${MAKE} DIRPRFX=${_tool}/ depend; \
977 ${MAKE} DIRPRFX=${_tool}/ all; \
978 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
982 # hierarchy - ensure that all the needed directories are present
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.
996 ${MAKE} -f Makefile.inc1 _prereq_libs; \
997 ${MAKE} -f Makefile.inc1 _startup_libs; \
998 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
999 ${MAKE} -f Makefile.inc1 _generic_libs;
1002 # static libgcc.a prerequisite for shared libc
1004 _prereq_libs= gnu/lib/libgcc
1006 # These dependencies are not automatically generated:
1008 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1009 # all shared libraries for ELF.
1011 _startup_libs= gnu/lib/csu
1012 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1013 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1015 _startup_libs+= lib/csu/${MACHINE_ARCH}
1017 _startup_libs+= gnu/lib/libgcc
1018 _startup_libs+= lib/libc
1020 gnu/lib/libgcc__L: lib/libc__L
1022 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1023 ${_kerberos5_lib_libroken} \
1024 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1025 ${_lib_libgssapi} ${_lib_libipx} \
1026 lib/libkiconv lib/libkvm lib/libmd \
1027 lib/ncurses/ncurses lib/ncurses/ncursesw \
1028 lib/libopie lib/libpam ${_default_thread_lib} \
1029 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1030 ${_lib_libypclnt} lib/libz lib/msun \
1031 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1032 ${_secure_lib_libssl}
1034 .if ${MK_LIBTHR} != "no" && ${MK_LIBKSE} != "no"
1035 _default_thread_lib= lib/${DEFAULT_THREAD_LIB}
1036 .elif ${MK_LIBTHR} != "no"
1037 _default_thread_lib= lib/libthr
1038 .elif ${MK_LIBKSE} != "no"
1039 _default_thread_lib= lib/libkse
1042 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1044 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1046 .if ${MK_CDDL} != "no"
1050 .if ${MK_CRYPT} != "no"
1051 .if ${MK_OPENSSL} != "no"
1052 _secure_lib_libcrypto= secure/lib/libcrypto
1053 _secure_lib_libssl= secure/lib/libssl
1054 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1055 .if ${MK_OPENSSH} != "no"
1056 _secure_lib_libssh= secure/lib/libssh
1057 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1058 .if ${MK_KERBEROS} != "no"
1059 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1060 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1061 kerberos5/lib/libroken__L
1065 _secure_lib= secure/lib
1068 .if ${MK_IPX} != "no"
1069 _lib_libipx= lib/libipx
1072 .if ${MK_KERBEROS} != "no"
1073 _kerberos5_lib= kerberos5/lib
1074 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1075 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1076 _kerberos5_lib_libroken= kerberos5/lib/libroken
1077 _lib_libgssapi= lib/libgssapi
1080 .if ${MK_NIS} != "no"
1081 _lib_libypclnt= lib/libypclnt
1084 .if ${MK_OPENSSL} == "no"
1085 lib/libradius__L: lib/libmd__L
1088 .for _lib in ${_prereq_libs}
1090 .if exists(${.CURDIR}/${_lib})
1091 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1092 cd ${.CURDIR}/${_lib}; \
1093 ${MAKE} DIRPRFX=${_lib}/ obj; \
1094 ${MAKE} DIRPRFX=${_lib}/ depend; \
1095 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1096 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1100 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1102 .if exists(${.CURDIR}/${_lib})
1103 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1104 cd ${.CURDIR}/${_lib}; \
1105 ${MAKE} DIRPRFX=${_lib}/ obj; \
1106 ${MAKE} DIRPRFX=${_lib}/ depend; \
1107 ${MAKE} DIRPRFX=${_lib}/ all; \
1108 ${MAKE} DIRPRFX=${_lib}/ install
1112 # libpam is special: we need to build static PAM modules before
1113 # static PAM library, and dynamic PAM library before dynamic PAM
1115 lib/libpam__L: .PHONY
1116 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1117 cd ${.CURDIR}/lib/libpam; \
1118 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1119 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1120 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1121 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1123 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1124 _startup_libs: ${_startup_libs:S/$/__L/}
1125 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1126 _generic_libs: ${_generic_libs:S/$/__L/}
1128 .for __target in all clean cleandepend cleandir depend includes obj
1129 .for entry in ${SUBDIR}
1130 ${entry}.${__target}__D: .PHONY
1131 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1132 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1133 edir=${entry}.${MACHINE_ARCH}; \
1134 cd ${.CURDIR}/$${edir}; \
1136 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1138 cd ${.CURDIR}/$${edir}; \
1140 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1142 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1145 .include <bsd.subdir.mk>
1147 .if make(check-old) || make(check-old-dirs) || \
1148 make(check-old-files) || make(check-old-libs) || \
1149 make(delete-old) || make(delete-old-dirs) || \
1150 make(delete-old-files) || make(delete-old-libs)
1153 # check for / delete old files section
1156 .include "ObsoleteFiles.inc"
1158 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1159 else you can not start such an application. Consult UPDATING for more \
1160 information regarding how to cope with the removal/revision bump of a \
1163 .if !defined(BATCH_DELETE_OLD_FILES)
1170 @echo ">>> Removing old files (only deletes safe to delete libs)"
1171 # Ask for every old file if the user really wants to remove it.
1172 # It's annoying, but better safe than sorry.
1173 @for file in ${OLD_FILES}; do \
1174 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1175 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1176 rm ${RM_I} "${DESTDIR}/$${file}"; \
1179 # Remove catpages without corresponding manpages.
1181 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1182 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1183 while read catpage; do \
1185 if [ ! -e "$${manpage}" ]; then \
1186 rm ${RM_I} $${catpage} <&3 ; \
1189 @echo ">>> Old files removed"
1192 @echo ">>> Checking for old files"
1193 @for file in ${OLD_FILES}; do \
1194 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1195 echo "${DESTDIR}/$${file}"; \
1198 # Check for catpages without corresponding manpages.
1199 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1200 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1201 while read catpage; do \
1203 if [ ! -e "$${manpage}" ]; then \
1204 echo $${catpage} ; \
1209 @echo ">>> Removing old libraries"
1210 @echo "${OLD_LIBS_MESSAGE}" | fmt
1211 @for file in ${OLD_LIBS}; do \
1212 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1213 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1214 rm ${RM_I} "${DESTDIR}/$${file}"; \
1217 @echo ">>> Old libraries removed"
1220 @echo ">>> Checking for old libraries"
1221 @for file in ${OLD_LIBS}; do \
1222 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1223 echo "${DESTDIR}/$${file}"; \
1228 @echo ">>> Removing old directories"
1229 @for dir in ${OLD_DIRS}; do \
1230 if [ -d "${DESTDIR}/$${dir}" ]; then \
1231 rmdir -v "${DESTDIR}/$${dir}" || true; \
1232 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1233 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1236 @echo ">>> Old directories removed"
1239 @echo ">>> Checking for old directories"
1240 @for dir in ${OLD_DIRS}; do \
1241 if [ -d "${DESTDIR}/$${dir}" ]; then \
1242 echo "${DESTDIR}/$${dir}"; \
1243 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1244 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1248 delete-old: delete-old-files delete-old-dirs
1249 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1251 check-old: check-old-files check-old-libs check-old-dirs
1252 @echo "To remove old files and directories run '${MAKE} delete-old'."
1253 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1258 # showconfig - show build configuration.
1261 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort