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 # We must do etc last for install/distribute to work.
40 SUBDIR= share/info include lib libexec bin
41 .if ${MK_GAMES} != "no"
45 .if ${MK_KERBEROS} != "no"
48 .if ${MK_RESCUE} != "no"
52 .if ${MK_CRYPT} != "no"
55 .if !defined(NO_SHARE)
58 SUBDIR+=sys usr.bin usr.sbin etc
60 # These are last, since it is nice to at least get the base system
61 # rebuilt before you do them.
62 .for _DIR in ${LOCAL_DIRS}
63 .if exists(${.CURDIR}/${_DIR}/Makefile)
68 .if defined(SUBDIR_OVERRIDE)
69 SUBDIR= ${SUBDIR_OVERRIDE}
75 .if defined(NO_CLEANDIR)
76 CLEANDIR= clean cleandepend
82 CVSFLAGS?= -A -P -d -I!
86 SUPFLAGS+= -h ${SUPHOST}
89 MAKEOBJDIRPREFIX?= /usr/obj
90 .if !defined(OSRELDATE)
91 .if exists(/usr/include/osreldate.h)
92 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
93 /usr/include/osreldate.h
99 # Guess machine architecture from machine type, and vice versa.
100 .if !defined(TARGET_ARCH) && defined(TARGET)
101 TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
102 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
103 ${TARGET_ARCH} != ${MACHINE_ARCH}
104 TARGET= ${TARGET_ARCH}
106 # Otherwise, default to current machine type and architecture.
108 TARGET_ARCH?= ${MACHINE_ARCH}
110 KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
111 .if ${TARGET} == ${TARGET_ARCH}
114 _t= ${TARGET_ARCH}/${TARGET}
117 .if empty(KNOWN_ARCHES:M${_t})
118 .error Unknown target ${TARGET_ARCH}:${TARGET}.
122 .if ${TARGET} == ${MACHINE}
123 TARGET_CPUTYPE?=${CPUTYPE}
128 .if !empty(TARGET_CPUTYPE)
129 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
131 _TARGET_CPUTYPE=dummy
133 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
134 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
135 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
136 .error CPUTYPE global should be set with ?=.
139 BUILD_ARCH!= uname -p
140 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
141 .error To cross-build, set TARGET_ARCH.
144 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
145 OBJTREE= ${MAKEOBJDIRPREFIX}
147 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
149 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
150 # /usr/games added for fortune which depend on strfile
151 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
152 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
153 STRICTTMPPATH= ${BPATH}:${XPATH}
154 TMPPATH= ${STRICTTMPPATH}:${PATH}
156 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
159 # Building a world goes through the following stages
161 # 1. legacy stage [BMAKE]
162 # This stage is responsible for creating compatibility
163 # shims that are needed by the bootstrap-tools,
164 # build-tools and cross-tools stages.
165 # 1. bootstrap-tools stage [BMAKE]
166 # This stage is responsible for creating programs that
167 # are needed for backward compatibility reasons. They
168 # are not built as cross-tools.
169 # 2. build-tools stage [TMAKE]
170 # This stage is responsible for creating the object
171 # tree and building any tools that are needed during
173 # 3. cross-tools stage [XMAKE]
174 # This stage is responsible for creating any tools that
175 # are needed for cross-builds. A cross-compiler is one
177 # 4. world stage [WMAKE]
178 # This stage actually builds the world.
179 # 5. install stage (optional) [IMAKE]
180 # This stage installs a previously built world.
185 # Common environment for world related stages
186 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
187 MACHINE_ARCH=${TARGET_ARCH} \
189 CPUTYPE=${TARGET_CPUTYPE} \
190 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
191 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
192 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
194 # bootstrap-tools stage
195 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
196 PATH=${BPATH}:${PATH} \
197 WORLDTMP=${WORLDTMP} \
198 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
199 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
200 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
202 BOOTSTRAPPING=${OSRELDATE} \
203 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
204 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
205 -DNO_CPU_CFLAGS -DNO_WARNS
208 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
209 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
210 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
212 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
215 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
216 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
217 -DWITHOUT_FORTRAN -DWITHOUT_GDB
220 WMAKEENV= ${CROSSENV} \
221 _SHLIBDIRPREFIX=${WORLDTMP} \
222 INSTALL="sh ${.CURDIR}/tools/install.sh" \
224 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
226 .if ${TARGET_ARCH} == "amd64"
228 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
230 .if empty(TARGET_CPUTYPE)
233 LIB32CPUTYPE= ${TARGET_CPUTYPE}
235 LIB32PREFLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
236 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
237 -L${LIB32TMP}/usr/lib32 \
238 -B${LIB32TMP}/usr/lib32
239 LIB32CC= ${LIB32PREFLAGS} \
241 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
243 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
246 # Yes, the flags are redundant.
247 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
248 _SHLIBDIRPREFIX=${LIB32TMP} \
251 INSTALL="sh ${.CURDIR}/tools/install.sh" \
253 CC="${CC} ${LIB32CC}" \
254 CXX="${CXX} ${LIB32CXX}" \
255 OBJC="${OBJC} ${LIB32OBJC}" \
256 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
261 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
262 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
264 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -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 two can depend on any header file.
308 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
309 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
312 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
313 usr/libexec usr/sbin usr/share/dict \
314 usr/share/groff_font/devX100 \
315 usr/share/groff_font/devX100-12 \
316 usr/share/groff_font/devX75 \
317 usr/share/groff_font/devX75-12 \
318 usr/share/groff_font/devascii \
319 usr/share/groff_font/devcp1047 \
320 usr/share/groff_font/devdvi \
321 usr/share/groff_font/devhtml \
322 usr/share/groff_font/devkoi8-r \
323 usr/share/groff_font/devlatin1 \
324 usr/share/groff_font/devlbp \
325 usr/share/groff_font/devlj4 \
326 usr/share/groff_font/devps \
327 usr/share/groff_font/devutf8 \
328 usr/share/tmac/mdoc usr/share/tmac/mm
329 mkdir -p ${WORLDTMP}/legacy/${_dir}
332 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
333 usr/libexec usr/sbin usr/share/misc \
334 usr/share/snmp/defs usr/share/snmp/mibs
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 rm -rf ${OBJTREE}/lib32
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 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
419 usr/libexec usr/sbin usr/share/misc \
420 usr/share/snmp/defs usr/share/snmp/mibs
421 mkdir -p ${LIB32TMP}/${_dir}
423 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
424 -p ${LIB32TMP}/usr/include >/dev/null
426 ln -sf ${.CURDIR}/sys ${WORLDTMP}
427 .if ${MK_KERBEROS} != "no"
428 .for _t in obj depend all
429 cd ${.CURDIR}/kerberos5/tools; \
430 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
433 .for _t in obj includes
434 cd ${.CURDIR}/include; \
435 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
437 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
438 cd ${.CURDIR}/gnu/lib; \
439 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
440 .if ${MK_CRYPT} != "no"
441 cd ${.CURDIR}/secure/lib; \
442 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
444 .if ${MK_KERBEROS} != "no"
445 cd ${.CURDIR}/kerberos5/lib; \
446 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
449 .for _dir in usr.bin/lex/lib
450 cd ${.CURDIR}/${_dir}; \
451 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
453 .for _dir in lib/libncurses lib/libmagic
454 cd ${.CURDIR}/${_dir}; \
455 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
458 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
459 .for _t in obj depend all
460 cd ${.CURDIR}/libexec/rtld-elf; \
461 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
464 distribute32 install32:
465 .if make(distribute32)
466 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
468 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
470 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
471 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
472 .if ${MK_CRYPT} != "no"
473 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
475 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
480 .if !defined(SUBDIR_OVERRIDE)
481 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
483 WMAKE_TGTS+= _cleanobj _obj _build-tools
484 .if !defined(SUBDIR_OVERRIDE)
485 WMAKE_TGTS+= _cross-tools
487 WMAKE_TGTS+= _includes _libraries _depend everything
488 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
492 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
493 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
496 @echo "--------------------------------------------------------------"
497 @echo ">>> World build started on `LC_ALL=C date`"
498 @echo "--------------------------------------------------------------"
502 @echo "--------------------------------------------------------------"
503 @echo ">>> World build completed on `LC_ALL=C date`"
504 @echo "--------------------------------------------------------------"
507 # We need to have this as a target because the indirection between Makefile
508 # and Makefile.inc1 causes the correct PATH to be used, rather than a
509 # modification of the current environment's PATH. In addition, we need
510 # to quote multiword values.
516 @echo Entering world for ${TARGET_ARCH}:${TARGET}
517 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
519 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
520 toolchain: ${TOOLCHAIN_TGTS}
521 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
526 # Checks to be sure system is ready for installworld/installkernel.
531 # Require DESTDIR to be set if installing for a different architecture.
533 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
534 .if !make(distributeworld)
535 installcheck: installcheck_DESTDIR
536 installcheck_DESTDIR:
537 .if !defined(DESTDIR) || empty(DESTDIR)
538 @echo "ERROR: Please set DESTDIR!"; \
545 # Check for missing UIDs/GIDs.
549 .if ${MK_SENDMAIL} != "no"
555 CHECK_GIDS+= proxy authpf
557 installcheck: installcheck_UGID
559 .for uid in ${CHECK_UIDS}
560 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
561 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
565 .for gid in ${CHECK_GIDS}
566 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
567 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
575 # Distributes everything compiled by a `buildworld'.
579 # Installs everything compiled by a 'buildworld'.
581 distributeworld installworld: installcheck
582 mkdir -p ${INSTALLTMP}
583 for prog in [ awk cap_mkdb cat chflags chmod chown \
584 date echo egrep find grep install-info \
585 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
586 test true uname wc zic; do \
587 cp `which $$prog` ${INSTALLTMP}; \
589 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
595 # If you have a build server, you can NFS mount the source and obj directories
596 # and do a 'make reinstall' on the *client* to install new binaries from the
597 # most recent server build.
600 @echo "--------------------------------------------------------------"
601 @echo ">>> Making hierarchy"
602 @echo "--------------------------------------------------------------"
603 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
605 @echo "--------------------------------------------------------------"
606 @echo ">>> Installing everything"
607 @echo "--------------------------------------------------------------"
608 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
609 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
610 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
614 @echo "--------------------------------------------------------------"
615 @echo ">>> Distributing everything"
616 @echo "--------------------------------------------------------------"
617 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
618 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
619 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
622 distrib-dirs distribution:
623 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
626 # buildkernel and installkernel
628 # Which kernels to build and/or install is specified by setting
629 # KERNCONF. If not defined a GENERIC kernel is built/installed.
630 # Only the existing (depending TARGET) config files are used
631 # for building kernels and only the first of these is designated
632 # as the one being installed.
634 # Note that we have to use TARGET instead of TARGET_ARCH when
635 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
636 # be set to cross-build, we have to make sure TARGET is set
639 .if !defined(KERNCONF) && defined(KERNEL)
645 INSTKERNNAME?= kernel
647 KERNSRCDIR?= ${.CURDIR}/sys
648 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
649 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
650 KERNCONFDIR?= ${KRNLCONFDIR}
654 .for _kernel in ${KERNCONF}
655 .if exists(${KERNCONFDIR}/${_kernel})
656 BUILDKERNELS+= ${_kernel}
657 .if empty(INSTALLKERNEL)
658 INSTALLKERNEL= ${_kernel}
666 # Builds all kernels defined by BUILDKERNELS.
669 .if empty(BUILDKERNELS)
670 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
673 .if defined(KERNWARN)
674 @echo "--------------------------------------------------------------"
675 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
676 @echo "--------------------------------------------------------------"
680 .for _kernel in ${BUILDKERNELS}
681 @echo "--------------------------------------------------------------"
682 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
683 @echo "--------------------------------------------------------------"
684 @echo "===> ${_kernel}"
685 mkdir -p ${KRNLOBJDIR}
686 .if !defined(NO_KERNELCONFIG)
688 @echo "--------------------------------------------------------------"
689 @echo ">>> stage 1: configuring the kernel"
690 @echo "--------------------------------------------------------------"
693 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
694 ${KERNCONFDIR}/${_kernel}
696 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
698 @echo "--------------------------------------------------------------"
699 @echo ">>> stage 2.1: cleaning up the object tree"
700 @echo "--------------------------------------------------------------"
701 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
704 @echo "--------------------------------------------------------------"
705 @echo ">>> stage 2.2: rebuilding the object tree"
706 @echo "--------------------------------------------------------------"
707 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
709 @echo "--------------------------------------------------------------"
710 @echo ">>> stage 2.3: build tools"
711 @echo "--------------------------------------------------------------"
712 cd ${KRNLOBJDIR}/${_kernel}; \
713 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
714 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
715 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
716 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
717 .for target in obj depend all
718 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
719 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
720 ${MAKE} -DNO_CPU_CFLAGS ${target}
723 .if !defined(NO_KERNELDEPEND)
725 @echo "--------------------------------------------------------------"
726 @echo ">>> stage 3.1: making dependencies"
727 @echo "--------------------------------------------------------------"
728 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
731 @echo "--------------------------------------------------------------"
732 @echo ">>> stage 3.2: building everything"
733 @echo "--------------------------------------------------------------"
734 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
735 @echo "--------------------------------------------------------------"
736 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
737 @echo "--------------------------------------------------------------"
741 # installkernel, etc.
743 # Install the kernel defined by INSTALLKERNEL
745 installkernel installkernel.debug \
746 reinstallkernel reinstallkernel.debug: installcheck
747 .if empty(INSTALLKERNEL)
748 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
751 @echo "--------------------------------------------------------------"
752 @echo ">>> Installing kernel"
753 @echo "--------------------------------------------------------------"
754 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
755 ${CROSSENV} PATH=${TMPPATH} \
756 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
761 # Build the API documentation with doxygen
764 @if [ ! -x `/usr/bin/which doxygen` ]; then \
765 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
768 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
773 # Update the source tree, by running cvsup and/or running cvs to update to the
777 .if defined(SUP_UPDATE)
778 @echo "--------------------------------------------------------------"
779 @echo ">>> Running ${SUP}"
780 @echo "--------------------------------------------------------------"
782 @${SUP} ${SUPFLAGS} ${SUPFILE}
784 .if defined(SUPFILE1)
785 @${SUP} ${SUPFLAGS} ${SUPFILE1}
787 .if defined(SUPFILE2)
788 @${SUP} ${SUPFLAGS} ${SUPFILE2}
790 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
791 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
793 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
794 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
797 .if defined(CVS_UPDATE)
798 @echo "--------------------------------------------------------------"
799 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
800 @echo "--------------------------------------------------------------"
801 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
805 # ------------------------------------------------------------------------
807 # From here onwards are utility targets used by the 'make world' and
808 # related targets. If your 'world' breaks, you may like to try to fix
809 # the problem and manually run the following targets to attempt to
810 # complete the build. Beware, this is *not* guaranteed to work, you
811 # need to have a pretty good grip on the current state of the system
812 # to attempt to manually finish it. If in doubt, 'make world' again.
816 # legacy: Build compatibility shims for the next three targets
819 .if ${BOOTSTRAPPING} < 503000
820 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
823 .for _tool in tools/build
824 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
825 cd ${.CURDIR}/${_tool}; \
826 ${MAKE} DIRPRFX=${_tool}/ obj; \
827 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
828 ${MAKE} DIRPRFX=${_tool}/ depend; \
829 ${MAKE} DIRPRFX=${_tool}/ all; \
830 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
834 # bootstrap-tools: Build tools needed for compatibility
836 .if ${MK_GAMES} != "no"
837 _strfile= games/fortune/strfile
840 .if ${MK_CXX} != "no"
841 _gperf= gnu/usr.bin/gperf
842 .if ${BOOTSTRAPPING} < 700004
843 _groff= gnu/usr.bin/groff
845 _groff= gnu/usr.bin/groff/tmac
849 .if ${BOOTSTRAPPING} < 600029
850 _texinfo= gnu/usr.bin/texinfo
853 .if ${BOOTSTRAPPING} < 600015
854 _cap_mkdb= usr.bin/cap_mkdb
857 .if ${BOOTSTRAPPING} < 600018
858 _colldef= usr.bin/colldef
861 .if ${BOOTSTRAPPING} < 600017
862 _gencat= usr.bin/gencat
865 .if ${BOOTSTRAPPING} < 600016
866 _mklocale= usr.bin/mklocale
869 .if ${BOOTSTRAPPING} < 700015
870 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
873 .if ${MK_RESCUE} != "no" && \
874 ${BOOTSTRAPPING} < 600008
875 _crunchgen= usr.sbin/crunch/crunchgen
878 .if ${BOOTSTRAPPING} < 600020
879 _pwd_mkdb= usr.sbin/pwd_mkdb
900 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
901 cd ${.CURDIR}/${_tool}; \
902 ${MAKE} DIRPRFX=${_tool}/ obj; \
903 ${MAKE} DIRPRFX=${_tool}/ depend; \
904 ${MAKE} DIRPRFX=${_tool}/ all; \
905 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
909 # build-tools: Build special purpose build tools
911 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
912 _aicasm= sys/modules/aic7xxx/aicasm
915 .if !defined(NO_SHARE)
916 _share= share/syscons/scrnmaps
919 .if ${MK_KERBEROS} != "no"
920 _kerberos5_tools= kerberos5/tools
923 .if ${MK_RESCUE} != "no"
924 _rescue= rescue/rescue
938 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
939 cd ${.CURDIR}/${_tool}; \
940 ${MAKE} DIRPRFX=${_tool}/ obj; \
941 ${MAKE} DIRPRFX=${_tool}/ build-tools
944 gnu/usr.bin/cc/cc_tools \
946 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
947 cd ${.CURDIR}/${_tool}; \
948 ${MAKE} DIRPRFX=${_tool}/ obj; \
949 ${MAKE} DIRPRFX=${_tool}/ depend; \
950 ${MAKE} DIRPRFX=${_tool}/ all
954 # cross-tools: Build cross-building tools
956 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
957 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
958 _btxld= usr.sbin/btxld
960 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
961 _crunchide= usr.sbin/crunch/crunchide
963 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
964 _kgzip= usr.sbin/kgzip
970 gnu/usr.bin/binutils \
972 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
976 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
977 cd ${.CURDIR}/${_tool}; \
978 ${MAKE} DIRPRFX=${_tool}/ obj; \
979 ${MAKE} DIRPRFX=${_tool}/ depend; \
980 ${MAKE} DIRPRFX=${_tool}/ all; \
981 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
985 # hierarchy - ensure that all the needed directories are present
988 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
991 # libraries - build all libraries, and install them under ${DESTDIR}.
993 # The list of libraries with dependents (${_prebuild_libs}) and their
994 # interdependencies (__L) are built automatically by the
995 # ${.CURDIR}/tools/make_libdeps.sh script.
999 ${MAKE} -f Makefile.inc1 _startup_libs; \
1000 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1001 ${MAKE} -f Makefile.inc1 _generic_libs;
1003 # These dependencies are not automatically generated:
1005 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
1006 # shared libraries for ELF.
1008 _startup_libs= gnu/lib/csu gnu/lib/libgcc
1009 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1010 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1012 _startup_libs+= lib/csu/${MACHINE_ARCH}
1015 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1016 ${_kerberos5_lib_libroken} \
1017 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1018 ${_lib_libgssapi} ${_lib_libipx} \
1019 lib/libkiconv lib/libkvm lib/libmd \
1020 lib/libncurses lib/libopie lib/libpam \
1021 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1022 ${_lib_libypclnt} lib/libz lib/msun \
1023 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1024 ${_secure_lib_libssl}
1026 _generic_libs= gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1028 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1030 .if ${MK_CRYPT} != "no"
1031 .if ${MK_OPENSSL} != "no"
1032 _secure_lib_libcrypto= secure/lib/libcrypto
1033 _secure_lib_libssl= secure/lib/libssl
1034 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1035 .if ${MK_OPENSSH} != "no"
1036 _secure_lib_libssh= secure/lib/libssh
1037 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1038 .if ${MK_KERBEROS} != "no"
1039 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1040 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1041 kerberos5/lib/libroken__L
1045 _secure_lib= secure/lib
1048 .if ${MK_IPX} != "no"
1049 _lib_libipx= lib/libipx
1052 .if ${MK_KERBEROS} != "no"
1053 _kerberos5_lib= kerberos5/lib
1054 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1055 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1056 _kerberos5_lib_libroken= kerberos5/lib/libroken
1057 _lib_libgssapi= lib/libgssapi
1060 .if ${MK_NIS} != "no"
1061 _lib_libypclnt= lib/libypclnt
1064 .if ${MK_OPENSSL} == "no"
1065 lib/libradius__L: lib/libmd__L
1068 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1070 .if exists(${.CURDIR}/${_lib})
1071 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1072 cd ${.CURDIR}/${_lib}; \
1073 ${MAKE} DIRPRFX=${_lib}/ obj; \
1074 ${MAKE} DIRPRFX=${_lib}/ depend; \
1075 ${MAKE} DIRPRFX=${_lib}/ all; \
1076 ${MAKE} DIRPRFX=${_lib}/ install
1080 # libpam is special: we need to build static PAM modules before
1081 # static PAM library, and dynamic PAM library before dynamic PAM
1083 lib/libpam__L: .PHONY
1084 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1085 cd ${.CURDIR}/lib/libpam; \
1086 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1087 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1088 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1089 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1091 _startup_libs: ${_startup_libs:S/$/__L/}
1092 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1093 _generic_libs: ${_generic_libs:S/$/__L/}
1095 .for __target in all clean cleandepend cleandir depend includes obj
1096 .for entry in ${SUBDIR}
1097 ${entry}.${__target}__D: .PHONY
1098 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1099 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1100 edir=${entry}.${MACHINE_ARCH}; \
1101 cd ${.CURDIR}/$${edir}; \
1103 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1105 cd ${.CURDIR}/$${edir}; \
1107 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1109 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1112 .include <bsd.subdir.mk>
1114 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1117 # check for / delete old files section
1120 .include "ObsoleteFiles.inc"
1122 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1123 else you can not start such an application. Consult UPDATING for more \
1124 information regarding how to cope with the removal/revision bump of a \
1127 .if !defined(BATCH_DELETE_OLD_FILES)
1134 @echo ">>> Removing old files (only deletes safe to delete libs)"
1135 .for file in ${OLD_FILES}
1136 # Ask for every old file if the user really wants to remove it.
1137 # It's annoying, but better safe than sorry.
1138 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1139 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1140 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1141 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1142 chflags noschg "${DESTDIR}/${file}"; \
1143 rm ${RM_I} "${DESTDIR}/${file}"; \
1147 # Remove catpages without corresponding manpages.
1149 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1150 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1151 while read catpage; do \
1153 if [ ! -e "$${manpage}" ]; then \
1154 rm ${RM_I} $${catpage} <&3 ; \
1157 @echo ">>> Old files removed"
1160 @echo ">>> Checking for old files"
1161 .for file in ${OLD_FILES}
1162 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1163 echo "${DESTDIR}/${file}"; \
1166 # Check for catpages without corresponding manpages.
1167 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1168 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1169 while read catpage; do \
1171 if [ ! -e "$${manpage}" ]; then \
1172 echo $${catpage} ; \
1177 @echo ">>> Removing old libraries"
1178 @echo "${OLD_LIBS_MESSAGE}" | fmt
1179 .for file in ${OLD_LIBS}
1180 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1181 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1182 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1183 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1184 chflags noschg "${DESTDIR}/${file}"; \
1185 rm ${RM_I} "${DESTDIR}/${file}"; \
1189 @echo ">>> Old libraries removed"
1192 @echo ">>> Checking for old libraries"
1193 .for file in ${OLD_LIBS}
1194 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1195 echo "${DESTDIR}/${file}"; \
1200 @echo ">>> Removing old directories"
1201 .for dir in ${OLD_DIRS}
1202 # Don't fail if an old directory isn't empty.
1203 @if [ -d "${DESTDIR}/${dir}" ]; then \
1204 rmdir -v "${DESTDIR}/${dir}" || true; \
1206 if [ -L "${DESTDIR}/${dir}" ]; then \
1207 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1211 @echo ">>> Old directories removed"
1214 @echo ">>> Checking for old directories"
1215 .for dir in ${OLD_DIRS}
1216 @if [ -d "${DESTDIR}/${dir}" ]; then \
1217 echo "${DESTDIR}/${dir}"; \
1219 if [ -L "${DESTDIR}/${dir}" ]; then \
1220 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1225 delete-old: delete-old-files delete-old-dirs
1226 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1228 check-old: check-old-files check-old-libs check-old-dirs
1229 @echo "To remove old files and directories run '${MAKE} delete-old'."
1230 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1235 # showconfig - show build configuration.
1238 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort