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"
44 .if ${MK_KERBEROS} != "no"
47 .if ${MK_RESCUE} != "no"
51 .if ${MK_CRYPT} != "no"
54 .if !defined(NO_SHARE)
57 SUBDIR+=sys usr.bin usr.sbin
59 # We must do etc/ last for install/distribute to work.
63 # These are last, since it is nice to at least get the base system
64 # rebuilt before you do them.
65 .for _DIR in ${LOCAL_DIRS}
66 .if exists(${.CURDIR}/${_DIR}/Makefile)
71 .if defined(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
78 .if defined(NO_CLEANDIR)
79 CLEANDIR= clean cleandepend
85 CVSFLAGS?= -A -P -d -I!
89 SUPFLAGS+= -h ${SUPHOST}
92 MAKEOBJDIRPREFIX?= /usr/obj
93 .if !defined(OSRELDATE)
94 .if exists(/usr/include/osreldate.h)
95 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
96 /usr/include/osreldate.h
102 # Guess machine architecture from machine type, and vice versa.
103 .if !defined(TARGET_ARCH) && defined(TARGET)
104 TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
105 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
106 ${TARGET_ARCH} != ${MACHINE_ARCH}
107 TARGET= ${TARGET_ARCH}
109 # Otherwise, default to current machine type and architecture.
111 TARGET_ARCH?= ${MACHINE_ARCH}
113 KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
114 .if ${TARGET} == ${TARGET_ARCH}
117 _t= ${TARGET_ARCH}/${TARGET}
120 .if empty(KNOWN_ARCHES:M${_t})
121 .error Unknown target ${TARGET_ARCH}:${TARGET}.
125 .if ${TARGET} == ${MACHINE}
126 TARGET_CPUTYPE?=${CPUTYPE}
131 .if !empty(TARGET_CPUTYPE)
132 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
134 _TARGET_CPUTYPE=dummy
136 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
137 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
138 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
139 .error CPUTYPE global should be set with ?=.
142 BUILD_ARCH!= uname -p
143 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
144 .error To cross-build, set TARGET_ARCH.
147 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
148 OBJTREE= ${MAKEOBJDIRPREFIX}
150 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
152 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
153 # /usr/games added for fortune which depend on strfile
154 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
155 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
156 STRICTTMPPATH= ${BPATH}:${XPATH}
157 TMPPATH= ${STRICTTMPPATH}:${PATH}
159 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
162 # Building a world goes through the following stages
164 # 1. legacy stage [BMAKE]
165 # This stage is responsible for creating compatibility
166 # shims that are needed by the bootstrap-tools,
167 # build-tools and cross-tools stages.
168 # 1. bootstrap-tools stage [BMAKE]
169 # This stage is responsible for creating programs that
170 # are needed for backward compatibility reasons. They
171 # are not built as cross-tools.
172 # 2. build-tools stage [TMAKE]
173 # This stage is responsible for creating the object
174 # tree and building any tools that are needed during
176 # 3. cross-tools stage [XMAKE]
177 # This stage is responsible for creating any tools that
178 # are needed for cross-builds. A cross-compiler is one
180 # 4. world stage [WMAKE]
181 # This stage actually builds the world.
182 # 5. install stage (optional) [IMAKE]
183 # This stage installs a previously built world.
188 # Common environment for world related stages
189 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
190 MACHINE_ARCH=${TARGET_ARCH} \
192 CPUTYPE=${TARGET_CPUTYPE} \
193 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
194 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
195 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
197 # bootstrap-tools stage
198 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
199 PATH=${BPATH}:${PATH} \
200 WORLDTMP=${WORLDTMP} \
201 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
202 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
203 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
205 BOOTSTRAPPING=${OSRELDATE} \
206 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
207 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
208 -DNO_CPU_CFLAGS -DNO_WARNS
211 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
212 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
213 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
215 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
218 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
219 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
220 -DWITHOUT_FORTRAN -DWITHOUT_GDB
223 WMAKEENV= ${CROSSENV} \
224 _SHLIBDIRPREFIX=${WORLDTMP} \
225 INSTALL="sh ${.CURDIR}/tools/install.sh" \
227 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
229 .if ${TARGET_ARCH} == "amd64"
231 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
233 .if empty(TARGET_CPUTYPE)
236 LIB32CPUTYPE= ${TARGET_CPUTYPE}
238 LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
239 -iprefix ${LIB32TMP}/usr/ \
240 -L${LIB32TMP}/usr/lib32 \
241 -B${LIB32TMP}/usr/lib32
243 # Yes, the flags are redundant.
244 LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
245 _SHLIBDIRPREFIX=${LIB32TMP} \
248 INSTALL="sh ${.CURDIR}/tools/install.sh" \
250 CC="${CC} ${LIB32FLAGS}" \
251 CXX="${CXX} ${LIB32FLAGS}" \
252 OBJC="${OBJC} ${LIB32FLAGS}" \
253 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
258 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
259 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
260 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
261 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
265 .if empty(.MAKEFLAGS:M-n)
266 IMAKEENV= ${CROSSENV} \
267 PATH=${STRICTTMPPATH}:${INSTALLTMP}
269 IMAKEENV= ${CROSSENV} \
270 PATH=${TMPPATH}:${INSTALLTMP}
272 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
275 KMAKEENV= ${WMAKEENV}
276 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
281 # Attempt to rebuild the entire system, with reasonable chance of
282 # success, regardless of how old your existing system is.
285 .if ${.CURDIR:C/[^,]//g} != ""
286 # The m4 build of sendmail files doesn't like it if ',' is used
287 # anywhere in the path of it's files.
289 @echo "*** Error: path to source tree contains a comma ','"
294 @echo "--------------------------------------------------------------"
295 @echo ">>> Rebuilding the temporary build tree"
296 @echo "--------------------------------------------------------------"
297 .if !defined(NO_CLEAN)
299 .if ${TARGET_ARCH} == "amd64"
303 rm -rf ${WORLDTMP}/legacy/usr/include
304 # XXX - These two can depend on any header file.
305 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
306 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
309 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
310 usr/libexec usr/sbin usr/share/dict \
311 usr/share/groff_font/devX100 \
312 usr/share/groff_font/devX100-12 \
313 usr/share/groff_font/devX75 \
314 usr/share/groff_font/devX75-12 \
315 usr/share/groff_font/devascii \
316 usr/share/groff_font/devcp1047 \
317 usr/share/groff_font/devdvi \
318 usr/share/groff_font/devhtml \
319 usr/share/groff_font/devkoi8-r \
320 usr/share/groff_font/devlatin1 \
321 usr/share/groff_font/devlbp \
322 usr/share/groff_font/devlj4 \
323 usr/share/groff_font/devps \
324 usr/share/groff_font/devutf8 \
325 usr/share/tmac/mdoc usr/share/tmac/mm
326 mkdir -p ${WORLDTMP}/legacy/${_dir}
329 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
330 usr/libexec usr/sbin usr/share/misc \
331 usr/share/snmp/defs usr/share/snmp/mibs
332 mkdir -p ${WORLDTMP}/${_dir}
334 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
335 -p ${WORLDTMP}/usr/include >/dev/null
336 ln -sf ${.CURDIR}/sys ${WORLDTMP}
337 .if ${MK_BIND_LIBS} != "no"
338 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
339 -p ${WORLDTMP}/usr/include >/dev/null
343 @echo "--------------------------------------------------------------"
344 @echo ">>> stage 1.1: legacy release compatibility shims"
345 @echo "--------------------------------------------------------------"
346 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
349 @echo "--------------------------------------------------------------"
350 @echo ">>> stage 1.2: bootstrap tools"
351 @echo "--------------------------------------------------------------"
352 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
354 .if !defined(NO_CLEAN)
356 @echo "--------------------------------------------------------------"
357 @echo ">>> stage 2.1: cleaning up the object tree"
358 @echo "--------------------------------------------------------------"
359 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
360 .if ${TARGET_ARCH} == "amd64"
361 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
366 @echo "--------------------------------------------------------------"
367 @echo ">>> stage 2.2: rebuilding the object tree"
368 @echo "--------------------------------------------------------------"
369 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
372 @echo "--------------------------------------------------------------"
373 @echo ">>> stage 2.3: build tools"
374 @echo "--------------------------------------------------------------"
375 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
378 @echo "--------------------------------------------------------------"
379 @echo ">>> stage 3: cross tools"
380 @echo "--------------------------------------------------------------"
381 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
384 @echo "--------------------------------------------------------------"
385 @echo ">>> stage 4.1: building includes"
386 @echo "--------------------------------------------------------------"
387 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
390 @echo "--------------------------------------------------------------"
391 @echo ">>> stage 4.2: building libraries"
392 @echo "--------------------------------------------------------------"
393 ${_+_}cd ${.CURDIR}; \
394 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
395 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
398 @echo "--------------------------------------------------------------"
399 @echo ">>> stage 4.3: make dependencies"
400 @echo "--------------------------------------------------------------"
401 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
404 @echo "--------------------------------------------------------------"
405 @echo ">>> stage 4.4: building everything"
406 @echo "--------------------------------------------------------------"
407 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
408 .if ${TARGET_ARCH} == "amd64"
411 @echo "--------------------------------------------------------------"
412 @echo ">>> stage 5.1: building 32 bit shim libraries"
413 @echo "--------------------------------------------------------------"
415 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
416 usr/libexec usr/sbin usr/share/misc \
417 usr/share/snmp/defs usr/share/snmp/mibs
418 mkdir -p ${LIB32TMP}/${_dir}
420 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
421 -p ${LIB32TMP}/usr/include >/dev/null
423 ln -sf ${.CURDIR}/sys ${WORLDTMP}
424 .if ${MK_KERBEROS} != "no"
425 .for _t in obj depend all
426 cd ${.CURDIR}/kerberos5/tools; \
427 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
430 .for _t in obj includes
431 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
432 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
433 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
434 .if ${MK_CRYPT} != "no"
435 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
437 .if ${MK_KERBEROS} != "no"
438 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
441 .for _dir in usr.bin/lex/lib
442 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
444 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
445 cd ${.CURDIR}/${_dir}; \
446 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
449 ${LIB32WMAKE} -f Makefile.inc1 libraries
450 .for _t in obj depend all
451 cd ${.CURDIR}/libexec/rtld-elf; \
452 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
455 distribute32 install32:
456 .if make(distribute32)
457 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
459 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
461 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
462 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
463 .if ${MK_CRYPT} != "no"
464 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
466 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
471 .if !defined(SUBDIR_OVERRIDE)
472 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
474 WMAKE_TGTS+= _cleanobj _obj _build-tools
475 .if !defined(SUBDIR_OVERRIDE)
476 WMAKE_TGTS+= _cross-tools
478 WMAKE_TGTS+= _includes _libraries _depend everything
479 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
483 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
484 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
487 @echo "--------------------------------------------------------------"
488 @echo ">>> World build started on `LC_ALL=C date`"
489 @echo "--------------------------------------------------------------"
493 @echo "--------------------------------------------------------------"
494 @echo ">>> World build completed on `LC_ALL=C date`"
495 @echo "--------------------------------------------------------------"
498 # We need to have this as a target because the indirection between Makefile
499 # and Makefile.inc1 causes the correct PATH to be used, rather than a
500 # modification of the current environment's PATH. In addition, we need
501 # to quote multiword values.
507 @echo Entering world for ${TARGET_ARCH}:${TARGET}
508 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
510 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
511 toolchain: ${TOOLCHAIN_TGTS}
512 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
517 # Checks to be sure system is ready for installworld/installkernel.
522 # Require DESTDIR to be set if installing for a different architecture.
524 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
525 .if !make(distributeworld)
526 installcheck: installcheck_DESTDIR
527 installcheck_DESTDIR:
528 .if !defined(DESTDIR) || empty(DESTDIR)
529 @echo "ERROR: Please set DESTDIR!"; \
536 # Check for missing UIDs/GIDs.
540 .if ${MK_SENDMAIL} != "no"
546 CHECK_GIDS+= proxy authpf
548 installcheck: installcheck_UGID
550 .for uid in ${CHECK_UIDS}
551 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
552 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
556 .for gid in ${CHECK_GIDS}
557 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
558 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
566 # Distributes everything compiled by a `buildworld'.
570 # Installs everything compiled by a 'buildworld'.
572 distributeworld installworld: installcheck
573 mkdir -p ${INSTALLTMP}
574 for prog in [ awk cap_mkdb cat chflags chmod chown \
575 date echo egrep find grep install-info \
576 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
577 test true uname wc zic; do \
578 cp `which $$prog` ${INSTALLTMP}; \
580 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
586 # If you have a build server, you can NFS mount the source and obj directories
587 # and do a 'make reinstall' on the *client* to install new binaries from the
588 # most recent server build.
591 @echo "--------------------------------------------------------------"
592 @echo ">>> Making hierarchy"
593 @echo "--------------------------------------------------------------"
594 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
596 @echo "--------------------------------------------------------------"
597 @echo ">>> Installing everything"
598 @echo "--------------------------------------------------------------"
599 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
600 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
601 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
605 @echo "--------------------------------------------------------------"
606 @echo ">>> Distributing everything"
607 @echo "--------------------------------------------------------------"
608 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
609 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
610 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
613 distrib-dirs distribution:
614 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
617 # buildkernel and installkernel
619 # Which kernels to build and/or install is specified by setting
620 # KERNCONF. If not defined a GENERIC kernel is built/installed.
621 # Only the existing (depending TARGET) config files are used
622 # for building kernels and only the first of these is designated
623 # as the one being installed.
625 # Note that we have to use TARGET instead of TARGET_ARCH when
626 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
627 # be set to cross-build, we have to make sure TARGET is set
630 .if !defined(KERNCONF) && defined(KERNEL)
636 INSTKERNNAME?= kernel
638 KERNSRCDIR?= ${.CURDIR}/sys
639 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
640 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
641 KERNCONFDIR?= ${KRNLCONFDIR}
645 .for _kernel in ${KERNCONF}
646 .if exists(${KERNCONFDIR}/${_kernel})
647 BUILDKERNELS+= ${_kernel}
648 .if empty(INSTALLKERNEL)
649 INSTALLKERNEL= ${_kernel}
657 # Builds all kernels defined by BUILDKERNELS.
660 .if empty(BUILDKERNELS)
661 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
664 .if defined(KERNWARN)
665 @echo "--------------------------------------------------------------"
666 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
667 @echo "--------------------------------------------------------------"
671 .for _kernel in ${BUILDKERNELS}
672 @echo "--------------------------------------------------------------"
673 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
674 @echo "--------------------------------------------------------------"
675 @echo "===> ${_kernel}"
676 mkdir -p ${KRNLOBJDIR}
677 .if !defined(NO_KERNELCONFIG)
679 @echo "--------------------------------------------------------------"
680 @echo ">>> stage 1: configuring the kernel"
681 @echo "--------------------------------------------------------------"
684 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
685 ${KERNCONFDIR}/${_kernel}
687 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
689 @echo "--------------------------------------------------------------"
690 @echo ">>> stage 2.1: cleaning up the object tree"
691 @echo "--------------------------------------------------------------"
692 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
695 @echo "--------------------------------------------------------------"
696 @echo ">>> stage 2.2: rebuilding the object tree"
697 @echo "--------------------------------------------------------------"
698 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
700 @echo "--------------------------------------------------------------"
701 @echo ">>> stage 2.3: build tools"
702 @echo "--------------------------------------------------------------"
703 cd ${KRNLOBJDIR}/${_kernel}; \
704 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
705 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
706 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
707 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
708 .for target in obj depend all
709 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
710 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
711 ${MAKE} -DNO_CPU_CFLAGS ${target}
714 .if !defined(NO_KERNELDEPEND)
716 @echo "--------------------------------------------------------------"
717 @echo ">>> stage 3.1: making dependencies"
718 @echo "--------------------------------------------------------------"
719 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
722 @echo "--------------------------------------------------------------"
723 @echo ">>> stage 3.2: building everything"
724 @echo "--------------------------------------------------------------"
725 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
726 @echo "--------------------------------------------------------------"
727 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
728 @echo "--------------------------------------------------------------"
732 # installkernel, etc.
734 # Install the kernel defined by INSTALLKERNEL
736 installkernel installkernel.debug \
737 reinstallkernel reinstallkernel.debug: installcheck
738 .if empty(INSTALLKERNEL)
739 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
742 @echo "--------------------------------------------------------------"
743 @echo ">>> Installing kernel"
744 @echo "--------------------------------------------------------------"
745 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
746 ${CROSSENV} PATH=${TMPPATH} \
747 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
752 # Build the API documentation with doxygen
755 @if [ ! -x `/usr/bin/which doxygen` ]; then \
756 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
759 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
764 # Update the source tree, by running cvsup and/or running cvs to update to the
768 .if defined(SUP_UPDATE)
769 @echo "--------------------------------------------------------------"
770 @echo ">>> Running ${SUP}"
771 @echo "--------------------------------------------------------------"
773 @${SUP} ${SUPFLAGS} ${SUPFILE}
775 .if defined(SUPFILE1)
776 @${SUP} ${SUPFLAGS} ${SUPFILE1}
778 .if defined(SUPFILE2)
779 @${SUP} ${SUPFLAGS} ${SUPFILE2}
781 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
782 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
784 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
785 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
788 .if defined(CVS_UPDATE)
789 @echo "--------------------------------------------------------------"
790 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
791 @echo "--------------------------------------------------------------"
792 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
796 # ------------------------------------------------------------------------
798 # From here onwards are utility targets used by the 'make world' and
799 # related targets. If your 'world' breaks, you may like to try to fix
800 # the problem and manually run the following targets to attempt to
801 # complete the build. Beware, this is *not* guaranteed to work, you
802 # need to have a pretty good grip on the current state of the system
803 # to attempt to manually finish it. If in doubt, 'make world' again.
807 # legacy: Build compatibility shims for the next three targets
810 .if ${BOOTSTRAPPING} < 503000
811 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
814 .for _tool in tools/build
815 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
816 cd ${.CURDIR}/${_tool}; \
817 ${MAKE} DIRPRFX=${_tool}/ obj; \
818 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
819 ${MAKE} DIRPRFX=${_tool}/ depend; \
820 ${MAKE} DIRPRFX=${_tool}/ all; \
821 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
825 # bootstrap-tools: Build tools needed for compatibility
827 .if ${MK_GAMES} != "no"
828 _strfile= games/fortune/strfile
831 .if ${MK_CXX} != "no"
832 _gperf= gnu/usr.bin/gperf
833 .if ${BOOTSTRAPPING} < 700004
834 _groff= gnu/usr.bin/groff
836 _groff= gnu/usr.bin/groff/tmac
840 .if ${BOOTSTRAPPING} < 600029
841 _texinfo= gnu/usr.bin/texinfo
844 .if ${BOOTSTRAPPING} < 600015
845 _cap_mkdb= usr.bin/cap_mkdb
848 .if ${BOOTSTRAPPING} < 600018
849 _colldef= usr.bin/colldef
852 .if ${BOOTSTRAPPING} < 600017
853 _gencat= usr.bin/gencat
856 .if ${BOOTSTRAPPING} < 600016
857 _mklocale= usr.bin/mklocale
860 .if ${BOOTSTRAPPING} < 700018
861 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
864 .if ${MK_RESCUE} != "no" && \
865 ${BOOTSTRAPPING} < 700026
866 _crunchgen= usr.sbin/crunch/crunchgen
869 .if ${BOOTSTRAPPING} < 600020
870 _pwd_mkdb= usr.sbin/pwd_mkdb
891 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
892 cd ${.CURDIR}/${_tool}; \
893 ${MAKE} DIRPRFX=${_tool}/ obj; \
894 ${MAKE} DIRPRFX=${_tool}/ depend; \
895 ${MAKE} DIRPRFX=${_tool}/ all; \
896 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
900 # build-tools: Build special purpose build tools
902 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
903 _aicasm= sys/modules/aic7xxx/aicasm
906 .if !defined(NO_SHARE)
907 _share= share/syscons/scrnmaps
910 .if ${MK_KERBEROS} != "no"
911 _kerberos5_tools= kerberos5/tools
914 .if ${MK_RESCUE} != "no"
915 _rescue= rescue/rescue
923 lib/ncurses/ncurses \
924 lib/ncurses/ncursesw \
930 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
931 cd ${.CURDIR}/${_tool}; \
932 ${MAKE} DIRPRFX=${_tool}/ obj; \
933 ${MAKE} DIRPRFX=${_tool}/ build-tools
936 gnu/usr.bin/cc/cc_tools \
938 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
939 cd ${.CURDIR}/${_tool}; \
940 ${MAKE} DIRPRFX=${_tool}/ obj; \
941 ${MAKE} DIRPRFX=${_tool}/ depend; \
942 ${MAKE} DIRPRFX=${_tool}/ all
946 # cross-tools: Build cross-building tools
948 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
949 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
950 _btxld= usr.sbin/btxld
952 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
953 _crunchide= usr.sbin/crunch/crunchide
955 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
956 _kgzip= usr.sbin/kgzip
962 gnu/usr.bin/binutils \
964 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
968 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
969 cd ${.CURDIR}/${_tool}; \
970 ${MAKE} DIRPRFX=${_tool}/ obj; \
971 ${MAKE} DIRPRFX=${_tool}/ depend; \
972 ${MAKE} DIRPRFX=${_tool}/ all; \
973 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
977 # hierarchy - ensure that all the needed directories are present
980 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
983 # libraries - build all libraries, and install them under ${DESTDIR}.
985 # The list of libraries with dependents (${_prebuild_libs}) and their
986 # interdependencies (__L) are built automatically by the
987 # ${.CURDIR}/tools/make_libdeps.sh script.
991 ${MAKE} -f Makefile.inc1 _startup_libs; \
992 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
993 ${MAKE} -f Makefile.inc1 _generic_libs;
995 # These dependencies are not automatically generated:
997 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
998 # shared libraries for ELF.
1000 _startup_libs= gnu/lib/csu gnu/lib/libgcc
1001 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1002 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1004 _startup_libs+= lib/csu/${MACHINE_ARCH}
1007 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1008 ${_kerberos5_lib_libroken} \
1009 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1010 ${_lib_libgssapi} ${_lib_libipx} \
1011 lib/libkiconv lib/libkvm lib/libmd \
1012 lib/ncurses/ncurses lib/ncurses/ncursesw \
1013 lib/libopie lib/libpam \
1014 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1015 ${_lib_libypclnt} lib/libz lib/msun \
1016 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1017 ${_secure_lib_libssl}
1019 _generic_libs= gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1021 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1023 .if ${MK_CRYPT} != "no"
1024 .if ${MK_OPENSSL} != "no"
1025 _secure_lib_libcrypto= secure/lib/libcrypto
1026 _secure_lib_libssl= secure/lib/libssl
1027 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1028 .if ${MK_OPENSSH} != "no"
1029 _secure_lib_libssh= secure/lib/libssh
1030 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1031 .if ${MK_KERBEROS} != "no"
1032 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1033 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1034 kerberos5/lib/libroken__L
1038 _secure_lib= secure/lib
1041 .if ${MK_IPX} != "no"
1042 _lib_libipx= lib/libipx
1045 .if ${MK_KERBEROS} != "no"
1046 _kerberos5_lib= kerberos5/lib
1047 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1048 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1049 _kerberos5_lib_libroken= kerberos5/lib/libroken
1050 _lib_libgssapi= lib/libgssapi
1053 .if ${MK_NIS} != "no"
1054 _lib_libypclnt= lib/libypclnt
1057 .if ${MK_OPENSSL} == "no"
1058 lib/libradius__L: lib/libmd__L
1061 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1063 .if exists(${.CURDIR}/${_lib})
1064 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1065 cd ${.CURDIR}/${_lib}; \
1066 ${MAKE} DIRPRFX=${_lib}/ obj; \
1067 ${MAKE} DIRPRFX=${_lib}/ depend; \
1068 ${MAKE} DIRPRFX=${_lib}/ all; \
1069 ${MAKE} DIRPRFX=${_lib}/ install
1073 # libpam is special: we need to build static PAM modules before
1074 # static PAM library, and dynamic PAM library before dynamic PAM
1076 lib/libpam__L: .PHONY
1077 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1078 cd ${.CURDIR}/lib/libpam; \
1079 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1080 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1081 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1082 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1084 _startup_libs: ${_startup_libs:S/$/__L/}
1085 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1086 _generic_libs: ${_generic_libs:S/$/__L/}
1088 .for __target in all clean cleandepend cleandir depend includes obj
1089 .for entry in ${SUBDIR}
1090 ${entry}.${__target}__D: .PHONY
1091 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1092 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1093 edir=${entry}.${MACHINE_ARCH}; \
1094 cd ${.CURDIR}/$${edir}; \
1096 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1098 cd ${.CURDIR}/$${edir}; \
1100 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1102 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1105 .include <bsd.subdir.mk>
1107 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1110 # check for / delete old files section
1113 .include "ObsoleteFiles.inc"
1115 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1116 else you can not start such an application. Consult UPDATING for more \
1117 information regarding how to cope with the removal/revision bump of a \
1120 .if !defined(BATCH_DELETE_OLD_FILES)
1127 @echo ">>> Removing old files (only deletes safe to delete libs)"
1128 .for file in ${OLD_FILES}
1129 # Ask for every old file if the user really wants to remove it.
1130 # It's annoying, but better safe than sorry.
1131 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1132 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1133 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1134 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1135 chflags noschg "${DESTDIR}/${file}"; \
1136 rm ${RM_I} "${DESTDIR}/${file}"; \
1140 # Remove catpages without corresponding manpages.
1142 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1143 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1144 while read catpage; do \
1146 if [ ! -e "$${manpage}" ]; then \
1147 rm ${RM_I} $${catpage} <&3 ; \
1150 @echo ">>> Old files removed"
1153 @echo ">>> Checking for old files"
1154 .for file in ${OLD_FILES}
1155 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1156 echo "${DESTDIR}/${file}"; \
1159 # Check for catpages without corresponding manpages.
1160 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1161 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1162 while read catpage; do \
1164 if [ ! -e "$${manpage}" ]; then \
1165 echo $${catpage} ; \
1170 @echo ">>> Removing old libraries"
1171 @echo "${OLD_LIBS_MESSAGE}" | fmt
1172 .for file in ${OLD_LIBS}
1173 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1174 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1175 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1176 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1177 chflags noschg "${DESTDIR}/${file}"; \
1178 rm ${RM_I} "${DESTDIR}/${file}"; \
1182 @echo ">>> Old libraries removed"
1185 @echo ">>> Checking for old libraries"
1186 .for file in ${OLD_LIBS}
1187 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1188 echo "${DESTDIR}/${file}"; \
1193 @echo ">>> Removing old directories"
1194 .for dir in ${OLD_DIRS}
1195 # Don't fail if an old directory isn't empty.
1196 @if [ -d "${DESTDIR}/${dir}" ]; then \
1197 rmdir -v "${DESTDIR}/${dir}" || true; \
1199 if [ -L "${DESTDIR}/${dir}" ]; then \
1200 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1204 @echo ">>> Old directories removed"
1207 @echo ">>> Checking for old directories"
1208 .for dir in ${OLD_DIRS}
1209 @if [ -d "${DESTDIR}/${dir}" ]; then \
1210 echo "${DESTDIR}/${dir}"; \
1212 if [ -L "${DESTDIR}/${dir}" ]; then \
1213 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1218 delete-old: delete-old-files delete-old-dirs
1219 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1221 check-old: check-old-files check-old-libs check-old-dirs
1222 @echo "To remove old files and directories run '${MAKE} delete-old'."
1223 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1228 # showconfig - show build configuration.
1231 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort