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 LIB32PREFLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
239 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
240 -L${LIB32TMP}/usr/lib32 \
241 -B${LIB32TMP}/usr/lib32
242 LIB32CC= ${LIB32PREFLAGS} \
244 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
246 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
249 # Yes, the flags are redundant.
250 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
251 _SHLIBDIRPREFIX=${LIB32TMP} \
254 INSTALL="sh ${.CURDIR}/tools/install.sh" \
256 CC="${CC} ${LIB32CC}" \
257 CXX="${CXX} ${LIB32CXX}" \
258 OBJC="${OBJC} ${LIB32OBJC}" \
259 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
264 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
265 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
267 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -DNO_INCS
271 .if empty(.MAKEFLAGS:M-n)
272 IMAKEENV= ${CROSSENV} \
273 PATH=${STRICTTMPPATH}:${INSTALLTMP}
275 IMAKEENV= ${CROSSENV} \
276 PATH=${TMPPATH}:${INSTALLTMP}
278 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
281 KMAKEENV= ${WMAKEENV}
282 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
287 # Attempt to rebuild the entire system, with reasonable chance of
288 # success, regardless of how old your existing system is.
291 .if ${.CURDIR:C/[^,]//g} != ""
292 # The m4 build of sendmail files doesn't like it if ',' is used
293 # anywhere in the path of it's files.
295 @echo "*** Error: path to source tree contains a comma ','"
300 @echo "--------------------------------------------------------------"
301 @echo ">>> Rebuilding the temporary build tree"
302 @echo "--------------------------------------------------------------"
303 .if !defined(NO_CLEAN)
305 .if ${TARGET_ARCH} == "amd64"
309 rm -rf ${WORLDTMP}/legacy/usr/include
310 # XXX - These two can depend on any header file.
311 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
312 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
315 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
316 usr/libexec usr/sbin usr/share/dict \
317 usr/share/groff_font/devX100 \
318 usr/share/groff_font/devX100-12 \
319 usr/share/groff_font/devX75 \
320 usr/share/groff_font/devX75-12 \
321 usr/share/groff_font/devascii \
322 usr/share/groff_font/devcp1047 \
323 usr/share/groff_font/devdvi \
324 usr/share/groff_font/devhtml \
325 usr/share/groff_font/devkoi8-r \
326 usr/share/groff_font/devlatin1 \
327 usr/share/groff_font/devlbp \
328 usr/share/groff_font/devlj4 \
329 usr/share/groff_font/devps \
330 usr/share/groff_font/devutf8 \
331 usr/share/tmac/mdoc usr/share/tmac/mm
332 mkdir -p ${WORLDTMP}/legacy/${_dir}
335 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
336 usr/libexec usr/sbin usr/share/misc \
337 usr/share/snmp/defs usr/share/snmp/mibs
338 mkdir -p ${WORLDTMP}/${_dir}
340 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
341 -p ${WORLDTMP}/usr/include >/dev/null
342 ln -sf ${.CURDIR}/sys ${WORLDTMP}
343 .if ${MK_BIND_LIBS} != "no"
344 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
345 -p ${WORLDTMP}/usr/include >/dev/null
349 @echo "--------------------------------------------------------------"
350 @echo ">>> stage 1.1: legacy release compatibility shims"
351 @echo "--------------------------------------------------------------"
352 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
355 @echo "--------------------------------------------------------------"
356 @echo ">>> stage 1.2: bootstrap tools"
357 @echo "--------------------------------------------------------------"
358 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
360 .if !defined(NO_CLEAN)
362 @echo "--------------------------------------------------------------"
363 @echo ">>> stage 2.1: cleaning up the object tree"
364 @echo "--------------------------------------------------------------"
365 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
366 .if ${TARGET_ARCH} == "amd64"
367 rm -rf ${OBJTREE}/lib32
372 @echo "--------------------------------------------------------------"
373 @echo ">>> stage 2.2: rebuilding the object tree"
374 @echo "--------------------------------------------------------------"
375 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
378 @echo "--------------------------------------------------------------"
379 @echo ">>> stage 2.3: build tools"
380 @echo "--------------------------------------------------------------"
381 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
384 @echo "--------------------------------------------------------------"
385 @echo ">>> stage 3: cross tools"
386 @echo "--------------------------------------------------------------"
387 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
390 @echo "--------------------------------------------------------------"
391 @echo ">>> stage 4.1: building includes"
392 @echo "--------------------------------------------------------------"
393 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
396 @echo "--------------------------------------------------------------"
397 @echo ">>> stage 4.2: building libraries"
398 @echo "--------------------------------------------------------------"
399 ${_+_}cd ${.CURDIR}; \
400 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
401 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
404 @echo "--------------------------------------------------------------"
405 @echo ">>> stage 4.3: make dependencies"
406 @echo "--------------------------------------------------------------"
407 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
410 @echo "--------------------------------------------------------------"
411 @echo ">>> stage 4.4: building everything"
412 @echo "--------------------------------------------------------------"
413 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
414 .if ${TARGET_ARCH} == "amd64"
417 @echo "--------------------------------------------------------------"
418 @echo ">>> stage 5.1: building 32 bit shim libraries"
419 @echo "--------------------------------------------------------------"
421 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
422 usr/libexec usr/sbin usr/share/misc \
423 usr/share/snmp/defs usr/share/snmp/mibs
424 mkdir -p ${LIB32TMP}/${_dir}
426 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
427 -p ${LIB32TMP}/usr/include >/dev/null
429 ln -sf ${.CURDIR}/sys ${WORLDTMP}
430 .if ${MK_KERBEROS} != "no"
431 .for _t in obj depend all
432 cd ${.CURDIR}/kerberos5/tools; \
433 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
436 .for _t in obj includes
437 cd ${.CURDIR}/include; \
438 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
440 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
441 cd ${.CURDIR}/gnu/lib; \
442 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
443 .if ${MK_CRYPT} != "no"
444 cd ${.CURDIR}/secure/lib; \
445 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
447 .if ${MK_KERBEROS} != "no"
448 cd ${.CURDIR}/kerberos5/lib; \
449 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
452 .for _dir in usr.bin/lex/lib
453 cd ${.CURDIR}/${_dir}; \
454 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
456 .for _dir in lib/libncurses lib/libmagic
457 cd ${.CURDIR}/${_dir}; \
458 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
461 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
462 .for _t in obj depend all
463 cd ${.CURDIR}/libexec/rtld-elf; \
464 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
467 distribute32 install32:
468 .if make(distribute32)
469 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
471 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
473 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
474 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
475 .if ${MK_CRYPT} != "no"
476 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
478 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
483 .if !defined(SUBDIR_OVERRIDE)
484 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
486 WMAKE_TGTS+= _cleanobj _obj _build-tools
487 .if !defined(SUBDIR_OVERRIDE)
488 WMAKE_TGTS+= _cross-tools
490 WMAKE_TGTS+= _includes _libraries _depend everything
491 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
495 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
496 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
499 @echo "--------------------------------------------------------------"
500 @echo ">>> World build started on `LC_ALL=C date`"
501 @echo "--------------------------------------------------------------"
505 @echo "--------------------------------------------------------------"
506 @echo ">>> World build completed on `LC_ALL=C date`"
507 @echo "--------------------------------------------------------------"
510 # We need to have this as a target because the indirection between Makefile
511 # and Makefile.inc1 causes the correct PATH to be used, rather than a
512 # modification of the current environment's PATH. In addition, we need
513 # to quote multiword values.
519 @echo Entering world for ${TARGET_ARCH}:${TARGET}
520 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
522 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
523 toolchain: ${TOOLCHAIN_TGTS}
524 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
529 # Checks to be sure system is ready for installworld/installkernel.
534 # Require DESTDIR to be set if installing for a different architecture.
536 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
537 .if !make(distributeworld)
538 installcheck: installcheck_DESTDIR
539 installcheck_DESTDIR:
540 .if !defined(DESTDIR) || empty(DESTDIR)
541 @echo "ERROR: Please set DESTDIR!"; \
548 # Check for missing UIDs/GIDs.
552 .if ${MK_SENDMAIL} != "no"
558 CHECK_GIDS+= proxy authpf
560 installcheck: installcheck_UGID
562 .for uid in ${CHECK_UIDS}
563 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
564 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
568 .for gid in ${CHECK_GIDS}
569 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
570 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
578 # Distributes everything compiled by a `buildworld'.
582 # Installs everything compiled by a 'buildworld'.
584 distributeworld installworld: installcheck
585 mkdir -p ${INSTALLTMP}
586 for prog in [ awk cap_mkdb cat chflags chmod chown \
587 date echo egrep find grep install-info \
588 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
589 test true uname wc zic; do \
590 cp `which $$prog` ${INSTALLTMP}; \
592 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
598 # If you have a build server, you can NFS mount the source and obj directories
599 # and do a 'make reinstall' on the *client* to install new binaries from the
600 # most recent server build.
603 @echo "--------------------------------------------------------------"
604 @echo ">>> Making hierarchy"
605 @echo "--------------------------------------------------------------"
606 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
608 @echo "--------------------------------------------------------------"
609 @echo ">>> Installing everything"
610 @echo "--------------------------------------------------------------"
611 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
612 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
613 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
617 @echo "--------------------------------------------------------------"
618 @echo ">>> Distributing everything"
619 @echo "--------------------------------------------------------------"
620 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
621 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
622 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
625 distrib-dirs distribution:
626 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
629 # buildkernel and installkernel
631 # Which kernels to build and/or install is specified by setting
632 # KERNCONF. If not defined a GENERIC kernel is built/installed.
633 # Only the existing (depending TARGET) config files are used
634 # for building kernels and only the first of these is designated
635 # as the one being installed.
637 # Note that we have to use TARGET instead of TARGET_ARCH when
638 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
639 # be set to cross-build, we have to make sure TARGET is set
642 .if !defined(KERNCONF) && defined(KERNEL)
648 INSTKERNNAME?= kernel
650 KERNSRCDIR?= ${.CURDIR}/sys
651 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
652 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
653 KERNCONFDIR?= ${KRNLCONFDIR}
657 .for _kernel in ${KERNCONF}
658 .if exists(${KERNCONFDIR}/${_kernel})
659 BUILDKERNELS+= ${_kernel}
660 .if empty(INSTALLKERNEL)
661 INSTALLKERNEL= ${_kernel}
669 # Builds all kernels defined by BUILDKERNELS.
672 .if empty(BUILDKERNELS)
673 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
676 .if defined(KERNWARN)
677 @echo "--------------------------------------------------------------"
678 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
679 @echo "--------------------------------------------------------------"
683 .for _kernel in ${BUILDKERNELS}
684 @echo "--------------------------------------------------------------"
685 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
686 @echo "--------------------------------------------------------------"
687 @echo "===> ${_kernel}"
688 mkdir -p ${KRNLOBJDIR}
689 .if !defined(NO_KERNELCONFIG)
691 @echo "--------------------------------------------------------------"
692 @echo ">>> stage 1: configuring the kernel"
693 @echo "--------------------------------------------------------------"
696 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
697 ${KERNCONFDIR}/${_kernel}
699 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
701 @echo "--------------------------------------------------------------"
702 @echo ">>> stage 2.1: cleaning up the object tree"
703 @echo "--------------------------------------------------------------"
704 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
707 @echo "--------------------------------------------------------------"
708 @echo ">>> stage 2.2: rebuilding the object tree"
709 @echo "--------------------------------------------------------------"
710 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
712 @echo "--------------------------------------------------------------"
713 @echo ">>> stage 2.3: build tools"
714 @echo "--------------------------------------------------------------"
715 cd ${KRNLOBJDIR}/${_kernel}; \
716 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
717 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
718 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
719 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
720 .for target in obj depend all
721 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
722 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
723 ${MAKE} -DNO_CPU_CFLAGS ${target}
726 .if !defined(NO_KERNELDEPEND)
728 @echo "--------------------------------------------------------------"
729 @echo ">>> stage 3.1: making dependencies"
730 @echo "--------------------------------------------------------------"
731 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
734 @echo "--------------------------------------------------------------"
735 @echo ">>> stage 3.2: building everything"
736 @echo "--------------------------------------------------------------"
737 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
738 @echo "--------------------------------------------------------------"
739 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
740 @echo "--------------------------------------------------------------"
744 # installkernel, etc.
746 # Install the kernel defined by INSTALLKERNEL
748 installkernel installkernel.debug \
749 reinstallkernel reinstallkernel.debug: installcheck
750 .if empty(INSTALLKERNEL)
751 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
754 @echo "--------------------------------------------------------------"
755 @echo ">>> Installing kernel"
756 @echo "--------------------------------------------------------------"
757 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
758 ${CROSSENV} PATH=${TMPPATH} \
759 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
764 # Build the API documentation with doxygen
767 @if [ ! -x `/usr/bin/which doxygen` ]; then \
768 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
771 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
776 # Update the source tree, by running cvsup and/or running cvs to update to the
780 .if defined(SUP_UPDATE)
781 @echo "--------------------------------------------------------------"
782 @echo ">>> Running ${SUP}"
783 @echo "--------------------------------------------------------------"
785 @${SUP} ${SUPFLAGS} ${SUPFILE}
787 .if defined(SUPFILE1)
788 @${SUP} ${SUPFLAGS} ${SUPFILE1}
790 .if defined(SUPFILE2)
791 @${SUP} ${SUPFLAGS} ${SUPFILE2}
793 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
794 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
796 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
797 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
800 .if defined(CVS_UPDATE)
801 @echo "--------------------------------------------------------------"
802 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
803 @echo "--------------------------------------------------------------"
804 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
808 # ------------------------------------------------------------------------
810 # From here onwards are utility targets used by the 'make world' and
811 # related targets. If your 'world' breaks, you may like to try to fix
812 # the problem and manually run the following targets to attempt to
813 # complete the build. Beware, this is *not* guaranteed to work, you
814 # need to have a pretty good grip on the current state of the system
815 # to attempt to manually finish it. If in doubt, 'make world' again.
819 # legacy: Build compatibility shims for the next three targets
822 .if ${BOOTSTRAPPING} < 503000
823 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
826 .for _tool in tools/build
827 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
828 cd ${.CURDIR}/${_tool}; \
829 ${MAKE} DIRPRFX=${_tool}/ obj; \
830 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
831 ${MAKE} DIRPRFX=${_tool}/ depend; \
832 ${MAKE} DIRPRFX=${_tool}/ all; \
833 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
837 # bootstrap-tools: Build tools needed for compatibility
839 .if ${MK_GAMES} != "no"
840 _strfile= games/fortune/strfile
843 .if ${MK_CXX} != "no"
844 _gperf= gnu/usr.bin/gperf
845 .if ${BOOTSTRAPPING} < 700004
846 _groff= gnu/usr.bin/groff
848 _groff= gnu/usr.bin/groff/tmac
852 .if ${BOOTSTRAPPING} < 600029
853 _texinfo= gnu/usr.bin/texinfo
856 .if ${BOOTSTRAPPING} < 600015
857 _cap_mkdb= usr.bin/cap_mkdb
860 .if ${BOOTSTRAPPING} < 600018
861 _colldef= usr.bin/colldef
864 .if ${BOOTSTRAPPING} < 600017
865 _gencat= usr.bin/gencat
868 .if ${BOOTSTRAPPING} < 600016
869 _mklocale= usr.bin/mklocale
872 .if ${BOOTSTRAPPING} < 700015
873 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
876 .if ${MK_RESCUE} != "no" && \
877 ${BOOTSTRAPPING} < 600008
878 _crunchgen= usr.sbin/crunch/crunchgen
881 .if ${BOOTSTRAPPING} < 600020
882 _pwd_mkdb= usr.sbin/pwd_mkdb
903 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
904 cd ${.CURDIR}/${_tool}; \
905 ${MAKE} DIRPRFX=${_tool}/ obj; \
906 ${MAKE} DIRPRFX=${_tool}/ depend; \
907 ${MAKE} DIRPRFX=${_tool}/ all; \
908 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
912 # build-tools: Build special purpose build tools
914 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
915 _aicasm= sys/modules/aic7xxx/aicasm
918 .if !defined(NO_SHARE)
919 _share= share/syscons/scrnmaps
922 .if ${MK_KERBEROS} != "no"
923 _kerberos5_tools= kerberos5/tools
926 .if ${MK_RESCUE} != "no"
927 _rescue= rescue/rescue
941 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
942 cd ${.CURDIR}/${_tool}; \
943 ${MAKE} DIRPRFX=${_tool}/ obj; \
944 ${MAKE} DIRPRFX=${_tool}/ build-tools
947 gnu/usr.bin/cc/cc_tools \
949 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
950 cd ${.CURDIR}/${_tool}; \
951 ${MAKE} DIRPRFX=${_tool}/ obj; \
952 ${MAKE} DIRPRFX=${_tool}/ depend; \
953 ${MAKE} DIRPRFX=${_tool}/ all
957 # cross-tools: Build cross-building tools
959 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
960 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
961 _btxld= usr.sbin/btxld
963 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
964 _crunchide= usr.sbin/crunch/crunchide
966 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
967 _kgzip= usr.sbin/kgzip
973 gnu/usr.bin/binutils \
975 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
979 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
980 cd ${.CURDIR}/${_tool}; \
981 ${MAKE} DIRPRFX=${_tool}/ obj; \
982 ${MAKE} DIRPRFX=${_tool}/ depend; \
983 ${MAKE} DIRPRFX=${_tool}/ all; \
984 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
988 # hierarchy - ensure that all the needed directories are present
991 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
994 # libraries - build all libraries, and install them under ${DESTDIR}.
996 # The list of libraries with dependents (${_prebuild_libs}) and their
997 # interdependencies (__L) are built automatically by the
998 # ${.CURDIR}/tools/make_libdeps.sh script.
1002 ${MAKE} -f Makefile.inc1 _startup_libs; \
1003 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1004 ${MAKE} -f Makefile.inc1 _generic_libs;
1006 # These dependencies are not automatically generated:
1008 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
1009 # shared libraries for ELF.
1011 _startup_libs= gnu/lib/csu gnu/lib/libgcc
1012 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1013 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1015 _startup_libs+= lib/csu/${MACHINE_ARCH}
1018 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1019 ${_kerberos5_lib_libroken} \
1020 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1021 ${_lib_libgssapi} ${_lib_libipx} \
1022 lib/libkiconv lib/libkvm lib/libmd \
1023 lib/libncurses lib/libopie lib/libpam \
1024 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1025 ${_lib_libypclnt} lib/libz lib/msun \
1026 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1027 ${_secure_lib_libssl}
1029 _generic_libs= gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1031 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1033 .if ${MK_CRYPT} != "no"
1034 .if ${MK_OPENSSL} != "no"
1035 _secure_lib_libcrypto= secure/lib/libcrypto
1036 _secure_lib_libssl= secure/lib/libssl
1037 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1038 .if ${MK_OPENSSH} != "no"
1039 _secure_lib_libssh= secure/lib/libssh
1040 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1041 .if ${MK_KERBEROS} != "no"
1042 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1043 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1044 kerberos5/lib/libroken__L
1048 _secure_lib= secure/lib
1051 .if ${MK_IPX} != "no"
1052 _lib_libipx= lib/libipx
1055 .if ${MK_KERBEROS} != "no"
1056 _kerberos5_lib= kerberos5/lib
1057 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1058 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1059 _kerberos5_lib_libroken= kerberos5/lib/libroken
1060 _lib_libgssapi= lib/libgssapi
1063 .if ${MK_NIS} != "no"
1064 _lib_libypclnt= lib/libypclnt
1067 .if ${MK_OPENSSL} == "no"
1068 lib/libradius__L: lib/libmd__L
1071 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1073 .if exists(${.CURDIR}/${_lib})
1074 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1075 cd ${.CURDIR}/${_lib}; \
1076 ${MAKE} DIRPRFX=${_lib}/ obj; \
1077 ${MAKE} DIRPRFX=${_lib}/ depend; \
1078 ${MAKE} DIRPRFX=${_lib}/ all; \
1079 ${MAKE} DIRPRFX=${_lib}/ install
1083 # libpam is special: we need to build static PAM modules before
1084 # static PAM library, and dynamic PAM library before dynamic PAM
1086 lib/libpam__L: .PHONY
1087 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1088 cd ${.CURDIR}/lib/libpam; \
1089 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1090 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1091 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1092 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1094 _startup_libs: ${_startup_libs:S/$/__L/}
1095 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1096 _generic_libs: ${_generic_libs:S/$/__L/}
1098 .for __target in all clean cleandepend cleandir depend includes obj
1099 .for entry in ${SUBDIR}
1100 ${entry}.${__target}__D: .PHONY
1101 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1102 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1103 edir=${entry}.${MACHINE_ARCH}; \
1104 cd ${.CURDIR}/$${edir}; \
1106 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1108 cd ${.CURDIR}/$${edir}; \
1110 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1112 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1115 .include <bsd.subdir.mk>
1117 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1120 # check for / delete old files section
1123 .include "ObsoleteFiles.inc"
1125 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1126 else you can not start such an application. Consult UPDATING for more \
1127 information regarding how to cope with the removal/revision bump of a \
1130 .if !defined(BATCH_DELETE_OLD_FILES)
1137 @echo ">>> Removing old files (only deletes safe to delete libs)"
1138 .for file in ${OLD_FILES}
1139 # Ask for every old file if the user really wants to remove it.
1140 # It's annoying, but better safe than sorry.
1141 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1142 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1143 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1144 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1145 chflags noschg "${DESTDIR}/${file}"; \
1146 rm ${RM_I} "${DESTDIR}/${file}"; \
1150 # Remove catpages without corresponding manpages.
1152 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1153 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1154 while read catpage; do \
1156 if [ ! -e "$${manpage}" ]; then \
1157 rm ${RM_I} $${catpage} <&3 ; \
1160 @echo ">>> Old files removed"
1163 @echo ">>> Checking for old files"
1164 .for file in ${OLD_FILES}
1165 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1166 echo "${DESTDIR}/${file}"; \
1169 # Check for catpages without corresponding manpages.
1170 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1171 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1172 while read catpage; do \
1174 if [ ! -e "$${manpage}" ]; then \
1175 echo $${catpage} ; \
1180 @echo ">>> Removing old libraries"
1181 @echo "${OLD_LIBS_MESSAGE}" | fmt
1182 .for file in ${OLD_LIBS}
1183 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1184 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1185 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1186 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1187 chflags noschg "${DESTDIR}/${file}"; \
1188 rm ${RM_I} "${DESTDIR}/${file}"; \
1192 @echo ">>> Old libraries removed"
1195 @echo ">>> Checking for old libraries"
1196 .for file in ${OLD_LIBS}
1197 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1198 echo "${DESTDIR}/${file}"; \
1203 @echo ">>> Removing old directories"
1204 .for dir in ${OLD_DIRS}
1205 # Don't fail if an old directory isn't empty.
1206 @if [ -d "${DESTDIR}/${dir}" ]; then \
1207 rmdir -v "${DESTDIR}/${dir}" || true; \
1209 if [ -L "${DESTDIR}/${dir}" ]; then \
1210 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1214 @echo ">>> Old directories removed"
1217 @echo ">>> Checking for old directories"
1218 .for dir in ${OLD_DIRS}
1219 @if [ -d "${DESTDIR}/${dir}" ]; then \
1220 echo "${DESTDIR}/${dir}"; \
1222 if [ -L "${DESTDIR}/${dir}" ]; then \
1223 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1228 delete-old: delete-old-files delete-old-dirs
1229 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1231 check-old: check-old-files check-old-libs check-old-dirs
1232 @echo "To remove old files and directories run '${MAKE} delete-old'."
1233 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1238 # showconfig - show build configuration.
1241 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort