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 # -DNO_CTF do not run the DTrace CTF conversion tools on built objects
14 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
15 # TARGET="machine" to crossbuild world for a different machine type
18 # The intended user-driven targets are:
19 # buildworld - rebuild *everything*, including glue to help do upgrades
20 # installworld- install everything built by "buildworld"
21 # doxygen - build API documentation of the kernel
22 # update - convenient way to update your source tree (eg: cvsup/cvs)
24 # Standard targets (not defined here) are documented in the makefiles in
25 # /usr/share/mk. These include:
26 # obj depend all install clean cleandepend cleanobj
30 # We must do share/info early so that installation of info `dir'
31 # entries works correctly. Do it first since it is less likely to
32 # grow dependencies on include and lib than vice versa.
34 # We must do lib/ and libexec/ before bin/, because if installworld
35 # installs a new /bin/sh, the 'make' command will *immediately*
36 # use that new version. And the new (dynamically-linked) /bin/sh
37 # will expect to find appropriate libraries in /lib and /libexec.
39 SUBDIR= share/info lib libexec
41 .if ${MK_GAMES} != "no"
44 .if ${MK_CDDL} != "no"
50 .if ${MK_KERBEROS} != "no"
53 .if ${MK_RESCUE} != "no"
57 .if ${MK_CRYPT} != "no"
60 .if !defined(NO_SHARE)
63 SUBDIR+=sys usr.bin usr.sbin
65 # We must do etc/ last for install/distribute to work.
69 # These are last, since it is nice to at least get the base system
70 # rebuilt before you do them.
71 .for _DIR in ${LOCAL_DIRS}
72 .if exists(${.CURDIR}/${_DIR}/Makefile)
77 .if defined(SUBDIR_OVERRIDE)
78 SUBDIR= ${SUBDIR_OVERRIDE}
84 .if defined(NO_CLEANDIR)
85 CLEANDIR= clean cleandepend
91 CVSFLAGS?= -r RELENG_7 -P -d -I!
95 SUPFLAGS+= -h ${SUPHOST}
98 MAKEOBJDIRPREFIX?= /usr/obj
99 .if !defined(OSRELDATE)
100 .if exists(/usr/include/osreldate.h)
101 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
102 /usr/include/osreldate.h
108 .if !defined(VERSION)
110 VERSION+= ${OSRELDATE}
113 # Guess machine architecture from machine type, and vice versa.
114 .if !defined(TARGET_ARCH) && defined(TARGET)
115 TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
116 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
117 ${TARGET_ARCH} != ${MACHINE_ARCH}
118 TARGET= ${TARGET_ARCH}
120 # Otherwise, default to current machine type and architecture.
122 TARGET_ARCH?= ${MACHINE_ARCH}
124 KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
125 .if ${TARGET} == ${TARGET_ARCH}
128 _t= ${TARGET_ARCH}/${TARGET}
131 .if empty(KNOWN_ARCHES:M${_t})
132 .error Unknown target ${TARGET_ARCH}:${TARGET}.
136 .if ${TARGET} == ${MACHINE}
137 TARGET_CPUTYPE?=${CPUTYPE}
142 .if !empty(TARGET_CPUTYPE)
143 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
145 _TARGET_CPUTYPE=dummy
147 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
148 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
149 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
150 .error CPUTYPE global should be set with ?=.
153 BUILD_ARCH!= uname -p
154 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
155 .error To cross-build, set TARGET_ARCH.
158 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
159 OBJTREE= ${MAKEOBJDIRPREFIX}
161 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
163 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
164 # /usr/games added for fortune which depend on strfile
165 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
166 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
167 STRICTTMPPATH= ${BPATH}:${XPATH}
168 TMPPATH= ${STRICTTMPPATH}:${PATH}
170 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
173 # Building a world goes through the following stages
175 # 1. legacy stage [BMAKE]
176 # This stage is responsible for creating compatibility
177 # shims that are needed by the bootstrap-tools,
178 # build-tools and cross-tools stages.
179 # 1. bootstrap-tools stage [BMAKE]
180 # This stage is responsible for creating programs that
181 # are needed for backward compatibility reasons. They
182 # are not built as cross-tools.
183 # 2. build-tools stage [TMAKE]
184 # This stage is responsible for creating the object
185 # tree and building any tools that are needed during
187 # 3. cross-tools stage [XMAKE]
188 # This stage is responsible for creating any tools that
189 # are needed for cross-builds. A cross-compiler is one
191 # 4. world stage [WMAKE]
192 # This stage actually builds the world.
193 # 5. install stage (optional) [IMAKE]
194 # This stage installs a previously built world.
199 # Common environment for world related stages
200 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
201 MACHINE_ARCH=${TARGET_ARCH} \
203 CPUTYPE=${TARGET_CPUTYPE} \
204 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
205 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
206 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
208 # bootstrap-tools stage
209 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
210 PATH=${BPATH}:${PATH} \
211 WORLDTMP=${WORLDTMP} \
212 VERSION="${VERSION}" \
213 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
214 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
215 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
217 BOOTSTRAPPING=${OSRELDATE} \
218 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
219 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
220 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
223 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
224 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
225 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
227 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
231 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
232 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
236 WMAKEENV= ${CROSSENV} \
237 _SHLIBDIRPREFIX=${WORLDTMP} \
238 VERSION="${VERSION}" \
239 INSTALL="sh ${.CURDIR}/tools/install.sh" \
241 .if ${MK_CDDL} == "no" || defined(NO_CTF)
244 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
246 .if ${TARGET_ARCH} == "amd64"
248 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
250 .if empty(TARGET_CPUTYPE)
251 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
253 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
255 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -mfancy-math-387 -DCOMPAT_32BIT \
256 -iprefix ${LIB32TMP}/usr/ \
257 -L${LIB32TMP}/usr/lib32 \
258 -B${LIB32TMP}/usr/lib32
260 # Yes, the flags are redundant.
261 LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
262 _SHLIBDIRPREFIX=${LIB32TMP} \
263 VERSION="${VERSION}" \
266 INSTALL="sh ${.CURDIR}/tools/install.sh" \
268 CC="${CC} ${LIB32FLAGS}" \
269 CXX="${CXX} ${LIB32FLAGS}" \
270 OBJC="${OBJC} ${LIB32FLAGS}" \
271 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
276 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
277 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
278 -DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
279 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
283 .if empty(.MAKEFLAGS:M-n)
284 IMAKEENV= ${CROSSENV} \
285 PATH=${STRICTTMPPATH}:${INSTALLTMP}
287 IMAKEENV= ${CROSSENV} \
288 PATH=${TMPPATH}:${INSTALLTMP}
290 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
293 KMAKEENV= ${WMAKEENV}
294 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
299 # Attempt to rebuild the entire system, with reasonable chance of
300 # success, regardless of how old your existing system is.
303 .if ${.CURDIR:C/[^,]//g} != ""
304 # The m4 build of sendmail files doesn't like it if ',' is used
305 # anywhere in the path of it's files.
307 @echo "*** Error: path to source tree contains a comma ','"
312 @echo "--------------------------------------------------------------"
313 @echo ">>> Rebuilding the temporary build tree"
314 @echo "--------------------------------------------------------------"
315 .if !defined(NO_CLEAN)
317 .if ${TARGET_ARCH} == "amd64"
321 rm -rf ${WORLDTMP}/legacy/usr/include
322 # XXX - These three can depend on any header file.
323 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
324 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
325 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
328 usr/bin usr/games usr/include/sys usr/lib \
329 usr/libexec usr/sbin usr/share/dict \
330 usr/share/groff_font/devX100 \
331 usr/share/groff_font/devX100-12 \
332 usr/share/groff_font/devX75 \
333 usr/share/groff_font/devX75-12 \
334 usr/share/groff_font/devascii \
335 usr/share/groff_font/devcp1047 \
336 usr/share/groff_font/devdvi \
337 usr/share/groff_font/devhtml \
338 usr/share/groff_font/devkoi8-r \
339 usr/share/groff_font/devlatin1 \
340 usr/share/groff_font/devlbp \
341 usr/share/groff_font/devlj4 \
342 usr/share/groff_font/devps \
343 usr/share/groff_font/devutf8 \
344 usr/share/tmac/mdoc usr/share/tmac/mm
345 mkdir -p ${WORLDTMP}/legacy/${_dir}
348 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
349 usr/libexec usr/sbin usr/share/misc
350 mkdir -p ${WORLDTMP}/${_dir}
352 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
353 -p ${WORLDTMP}/usr/include >/dev/null
354 ln -sf ${.CURDIR}/sys ${WORLDTMP}
355 .if ${MK_BIND_LIBS} != "no"
356 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
357 -p ${WORLDTMP}/usr/include >/dev/null
361 @echo "--------------------------------------------------------------"
362 @echo ">>> stage 1.1: legacy release compatibility shims"
363 @echo "--------------------------------------------------------------"
364 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
367 @echo "--------------------------------------------------------------"
368 @echo ">>> stage 1.2: bootstrap tools"
369 @echo "--------------------------------------------------------------"
370 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
372 .if !defined(NO_CLEAN)
374 @echo "--------------------------------------------------------------"
375 @echo ">>> stage 2.1: cleaning up the object tree"
376 @echo "--------------------------------------------------------------"
377 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
378 .if ${TARGET_ARCH} == "amd64"
379 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
384 @echo "--------------------------------------------------------------"
385 @echo ">>> stage 2.2: rebuilding the object tree"
386 @echo "--------------------------------------------------------------"
387 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
390 @echo "--------------------------------------------------------------"
391 @echo ">>> stage 2.3: build tools"
392 @echo "--------------------------------------------------------------"
393 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
396 @echo "--------------------------------------------------------------"
397 @echo ">>> stage 3: cross tools"
398 @echo "--------------------------------------------------------------"
399 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
402 @echo "--------------------------------------------------------------"
403 @echo ">>> stage 4.1: building includes"
404 @echo "--------------------------------------------------------------"
405 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
408 @echo "--------------------------------------------------------------"
409 @echo ">>> stage 4.2: building libraries"
410 @echo "--------------------------------------------------------------"
411 ${_+_}cd ${.CURDIR}; \
412 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
413 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
416 @echo "--------------------------------------------------------------"
417 @echo ">>> stage 4.3: make dependencies"
418 @echo "--------------------------------------------------------------"
419 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
422 @echo "--------------------------------------------------------------"
423 @echo ">>> stage 4.4: building everything"
424 @echo "--------------------------------------------------------------"
425 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
426 .if ${TARGET_ARCH} == "amd64"
429 @echo "--------------------------------------------------------------"
430 @echo ">>> stage 5.1: building 32 bit shim libraries"
431 @echo "--------------------------------------------------------------"
433 usr/include usr/lib32 usr/share/misc
434 mkdir -p ${LIB32TMP}/${_dir}
436 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
437 -p ${LIB32TMP}/usr/include >/dev/null
439 ln -sf ${.CURDIR}/sys ${WORLDTMP}
440 .if ${MK_KERBEROS} != "no"
441 .for _t in obj depend all
442 cd ${.CURDIR}/kerberos5/tools; \
443 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
446 .for _t in obj includes
447 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
448 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
449 .if ${MK_CDDL} != "no"
450 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
452 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
453 .if ${MK_CRYPT} != "no"
454 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
456 .if ${MK_KERBEROS} != "no"
457 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
460 .for _dir in usr.bin/lex/lib
461 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
463 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
464 cd ${.CURDIR}/${_dir}; \
465 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
468 ${LIB32WMAKE} -f Makefile.inc1 libraries
469 .for _t in obj depend all
470 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
471 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
474 distribute32 install32:
475 .if make(distribute32)
476 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
477 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace # XXX add to mtree
479 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
480 mkdir -p ${DESTDIR}/usr/lib32/dtrace # XXX add to mtree
482 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
483 .if ${MK_CDDL} != "no"
484 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
486 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
487 .if ${MK_CRYPT} != "no"
488 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
490 cd ${.CURDIR}/libexec/rtld-elf; \
491 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
492 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
496 .if !defined(SUBDIR_OVERRIDE)
497 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
499 WMAKE_TGTS+= _cleanobj _obj _build-tools
500 .if !defined(SUBDIR_OVERRIDE)
501 WMAKE_TGTS+= _cross-tools
503 WMAKE_TGTS+= _includes _libraries _depend everything
504 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
508 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
509 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
512 @echo "--------------------------------------------------------------"
513 @echo ">>> World build started on `LC_ALL=C date`"
514 @echo "--------------------------------------------------------------"
518 @echo "--------------------------------------------------------------"
519 @echo ">>> World build completed on `LC_ALL=C date`"
520 @echo "--------------------------------------------------------------"
523 # We need to have this as a target because the indirection between Makefile
524 # and Makefile.inc1 causes the correct PATH to be used, rather than a
525 # modification of the current environment's PATH. In addition, we need
526 # to quote multiword values.
532 @echo Entering world for ${TARGET_ARCH}:${TARGET}
533 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
535 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
536 toolchain: ${TOOLCHAIN_TGTS}
537 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
542 # Checks to be sure system is ready for installworld/installkernel.
547 # Require DESTDIR to be set if installing for a different architecture.
549 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
550 .if !make(distributeworld)
551 installcheck: installcheck_DESTDIR
552 installcheck_DESTDIR:
553 .if !defined(DESTDIR) || empty(DESTDIR)
554 @echo "ERROR: Please set DESTDIR!"; \
561 # Check for missing UIDs/GIDs.
565 .if ${MK_SENDMAIL} != "no"
571 CHECK_GIDS+= proxy authpf
573 installcheck: installcheck_UGID
575 .for uid in ${CHECK_UIDS}
576 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
577 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
581 .for gid in ${CHECK_GIDS}
582 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
583 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
591 # Distributes everything compiled by a `buildworld'.
595 # Installs everything compiled by a 'buildworld'.
597 distributeworld installworld: installcheck
598 mkdir -p ${INSTALLTMP}
599 for prog in [ awk cap_mkdb cat chflags chmod chown \
600 date echo egrep find grep install-info \
601 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
602 test true uname wc zic; do \
603 cp `which $$prog` ${INSTALLTMP}; \
605 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
611 # If you have a build server, you can NFS mount the source and obj directories
612 # and do a 'make reinstall' on the *client* to install new binaries from the
613 # most recent server build.
616 @echo "--------------------------------------------------------------"
617 @echo ">>> Making hierarchy"
618 @echo "--------------------------------------------------------------"
619 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
621 @echo "--------------------------------------------------------------"
622 @echo ">>> Installing everything"
623 @echo "--------------------------------------------------------------"
624 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
625 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
626 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
630 @echo "--------------------------------------------------------------"
631 @echo ">>> Distributing everything"
632 @echo "--------------------------------------------------------------"
633 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
634 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
635 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
639 distrib-dirs distribution:
640 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
643 # buildkernel and installkernel
645 # Which kernels to build and/or install is specified by setting
646 # KERNCONF. If not defined a GENERIC kernel is built/installed.
647 # Only the existing (depending TARGET) config files are used
648 # for building kernels and only the first of these is designated
649 # as the one being installed.
651 # Note that we have to use TARGET instead of TARGET_ARCH when
652 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
653 # be set to cross-build, we have to make sure TARGET is set
656 .if !defined(KERNCONF) && defined(KERNEL)
662 INSTKERNNAME?= kernel
664 KERNSRCDIR?= ${.CURDIR}/sys
665 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
666 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
667 KERNCONFDIR?= ${KRNLCONFDIR}
671 .for _kernel in ${KERNCONF}
672 .if exists(${KERNCONFDIR}/${_kernel})
673 BUILDKERNELS+= ${_kernel}
674 .if empty(INSTALLKERNEL)
675 INSTALLKERNEL= ${_kernel}
683 # Builds all kernels defined by BUILDKERNELS.
686 .if empty(BUILDKERNELS)
687 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
690 .if defined(KERNWARN)
691 @echo "--------------------------------------------------------------"
692 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
693 @echo "--------------------------------------------------------------"
697 .for _kernel in ${BUILDKERNELS}
698 @echo "--------------------------------------------------------------"
699 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
700 @echo "--------------------------------------------------------------"
701 @echo "===> ${_kernel}"
702 mkdir -p ${KRNLOBJDIR}
703 .if !defined(NO_KERNELCONFIG)
705 @echo "--------------------------------------------------------------"
706 @echo ">>> stage 1: configuring the kernel"
707 @echo "--------------------------------------------------------------"
710 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
711 ${KERNCONFDIR}/${_kernel}
713 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
715 @echo "--------------------------------------------------------------"
716 @echo ">>> stage 2.1: cleaning up the object tree"
717 @echo "--------------------------------------------------------------"
718 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
721 @echo "--------------------------------------------------------------"
722 @echo ">>> stage 2.2: rebuilding the object tree"
723 @echo "--------------------------------------------------------------"
724 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
726 @echo "--------------------------------------------------------------"
727 @echo ">>> stage 2.3: build tools"
728 @echo "--------------------------------------------------------------"
729 cd ${KRNLOBJDIR}/${_kernel}; \
730 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
731 ${MAKE} -DNO_CPU_CFLAGS -DNO_CTF \
732 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
733 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
734 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
735 .for target in obj depend all
736 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
737 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
738 ${MAKE} -DNO_CPU_CFLAGS -DNO_CTF ${target}
741 .if !defined(NO_KERNELDEPEND)
743 @echo "--------------------------------------------------------------"
744 @echo ">>> stage 3.1: making dependencies"
745 @echo "--------------------------------------------------------------"
746 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
749 @echo "--------------------------------------------------------------"
750 @echo ">>> stage 3.2: building everything"
751 @echo "--------------------------------------------------------------"
752 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
753 @echo "--------------------------------------------------------------"
754 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
755 @echo "--------------------------------------------------------------"
759 # installkernel, etc.
761 # Install the kernel defined by INSTALLKERNEL
763 installkernel installkernel.debug \
764 reinstallkernel reinstallkernel.debug: installcheck
765 .if empty(INSTALLKERNEL)
766 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
769 @echo "--------------------------------------------------------------"
770 @echo ">>> Installing kernel"
771 @echo "--------------------------------------------------------------"
772 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
773 ${CROSSENV} PATH=${TMPPATH} \
774 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
779 # Build the API documentation with doxygen
782 @if [ ! -x `/usr/bin/which doxygen` ]; then \
783 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
786 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
791 # Update the source tree, by running cvsup and/or running cvs to update to the
795 .if defined(SUP_UPDATE)
796 @echo "--------------------------------------------------------------"
797 @echo ">>> Running ${SUP}"
798 @echo "--------------------------------------------------------------"
800 @${SUP} ${SUPFLAGS} ${SUPFILE}
802 .if defined(SUPFILE1)
803 @${SUP} ${SUPFLAGS} ${SUPFILE1}
805 .if defined(SUPFILE2)
806 @${SUP} ${SUPFLAGS} ${SUPFILE2}
808 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
809 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
811 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
812 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
815 .if defined(CVS_UPDATE)
816 @echo "--------------------------------------------------------------"
817 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
818 @echo "--------------------------------------------------------------"
819 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
823 # ------------------------------------------------------------------------
825 # From here onwards are utility targets used by the 'make world' and
826 # related targets. If your 'world' breaks, you may like to try to fix
827 # the problem and manually run the following targets to attempt to
828 # complete the build. Beware, this is *not* guaranteed to work, you
829 # need to have a pretty good grip on the current state of the system
830 # to attempt to manually finish it. If in doubt, 'make world' again.
834 # legacy: Build compatibility shims for the next three targets
837 .if ${BOOTSTRAPPING} < 503000
838 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
841 .for _tool in tools/build
842 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
843 cd ${.CURDIR}/${_tool}; \
844 ${MAKE} DIRPRFX=${_tool}/ obj; \
845 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
846 ${MAKE} DIRPRFX=${_tool}/ depend; \
847 ${MAKE} DIRPRFX=${_tool}/ all; \
848 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
852 # bootstrap-tools: Build tools needed for compatibility
854 .if ${MK_GAMES} != "no"
855 _strfile= games/fortune/strfile
858 .if ${MK_CXX} != "no"
859 _gperf= gnu/usr.bin/gperf
860 .if ${BOOTSTRAPPING} < 700004
861 _groff= gnu/usr.bin/groff
863 _groff= gnu/usr.bin/groff/tmac
867 .if ${BOOTSTRAPPING} < 600029
868 _texinfo= gnu/usr.bin/texinfo
871 .if ${BOOTSTRAPPING} < 600015
872 _cap_mkdb= usr.bin/cap_mkdb
875 .if ${BOOTSTRAPPING} < 600018
876 _colldef= usr.bin/colldef
879 .if ${BOOTSTRAPPING} < 600017
880 _gencat= usr.bin/gencat
883 .if ${BOOTSTRAPPING} < 600016
884 _mklocale= usr.bin/mklocale
887 .if ${BOOTSTRAPPING} < 700018
888 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
891 .if ${MK_RESCUE} != "no" && \
892 ${BOOTSTRAPPING} < 700026
893 _crunchgen= usr.sbin/crunch/crunchgen
896 .if ${BOOTSTRAPPING} < 600020
897 _pwd_mkdb= usr.sbin/pwd_mkdb
900 #.if ${MK_CDDL} != "no"
901 #_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
902 # lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
924 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
925 cd ${.CURDIR}/${_tool}; \
926 ${MAKE} DIRPRFX=${_tool}/ obj; \
927 ${MAKE} DIRPRFX=${_tool}/ depend; \
928 ${MAKE} DIRPRFX=${_tool}/ all; \
929 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
933 # build-tools: Build special purpose build tools
935 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
936 _aicasm= sys/modules/aic7xxx/aicasm
939 .if !defined(NO_SHARE)
940 _share= share/syscons/scrnmaps
943 .if ${MK_KERBEROS} != "no"
944 _kerberos5_tools= kerberos5/tools
947 .if ${MK_RESCUE} != "no"
948 _rescue= rescue/rescue
956 lib/ncurses/ncurses \
957 lib/ncurses/ncursesw \
963 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
964 cd ${.CURDIR}/${_tool}; \
965 ${MAKE} DIRPRFX=${_tool}/ obj; \
966 ${MAKE} DIRPRFX=${_tool}/ build-tools
969 gnu/usr.bin/cc/cc_tools \
971 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
972 cd ${.CURDIR}/${_tool}; \
973 ${MAKE} DIRPRFX=${_tool}/ obj; \
974 ${MAKE} DIRPRFX=${_tool}/ depend; \
975 ${MAKE} DIRPRFX=${_tool}/ all
979 # cross-tools: Build cross-building tools
981 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
982 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
983 _btxld= usr.sbin/btxld
985 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
986 _crunchide= usr.sbin/crunch/crunchide
988 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
989 _kgzip= usr.sbin/kgzip
995 gnu/usr.bin/binutils \
998 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1002 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1003 cd ${.CURDIR}/${_tool}; \
1004 ${MAKE} DIRPRFX=${_tool}/ obj; \
1005 ${MAKE} DIRPRFX=${_tool}/ depend; \
1006 ${MAKE} DIRPRFX=${_tool}/ all; \
1007 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1011 # hierarchy - ensure that all the needed directories are present
1014 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
1017 # libraries - build all libraries, and install them under ${DESTDIR}.
1019 # The list of libraries with dependents (${_prebuild_libs}) and their
1020 # interdependencies (__L) are built automatically by the
1021 # ${.CURDIR}/tools/make_libdeps.sh script.
1025 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1026 ${MAKE} -f Makefile.inc1 _startup_libs; \
1027 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1028 ${MAKE} -f Makefile.inc1 _generic_libs;
1031 # static libgcc.a prerequisite for shared libc
1033 _prereq_libs= gnu/lib/libgcc
1035 # These dependencies are not automatically generated:
1037 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1038 # all shared libraries for ELF.
1040 _startup_libs= gnu/lib/csu
1041 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1042 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1044 _startup_libs+= lib/csu/${MACHINE_ARCH}
1046 _startup_libs+= gnu/lib/libgcc
1047 _startup_libs+= lib/libc
1049 gnu/lib/libgcc__L: lib/libc__L
1051 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1052 ${_kerberos5_lib_libroken} \
1053 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1054 ${_lib_libgssapi} ${_lib_libipx} \
1055 lib/libkiconv lib/libkvm lib/libmd \
1056 lib/ncurses/ncurses lib/ncurses/ncursesw \
1057 lib/libopie lib/libpam ${_default_thread_lib} \
1058 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1059 ${_lib_libypclnt} lib/libz lib/msun \
1060 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1061 ${_secure_lib_libssl} lib/libdwarf lib/libproc
1063 .if ${MK_LIBTHR} != "no" && ${MK_LIBKSE} != "no"
1064 _default_thread_lib= lib/${DEFAULT_THREAD_LIB}
1065 .elif ${MK_LIBTHR} != "no"
1066 _default_thread_lib= lib/libthr
1067 .elif ${MK_LIBKSE} != "no"
1068 _default_thread_lib= lib/libkse
1071 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1073 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1075 .if ${MK_CDDL} != "no"
1079 .if ${MK_CRYPT} != "no"
1080 .if ${MK_OPENSSL} != "no"
1081 _secure_lib_libcrypto= secure/lib/libcrypto
1082 _secure_lib_libssl= secure/lib/libssl
1083 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1084 .if ${MK_OPENSSH} != "no"
1085 _secure_lib_libssh= secure/lib/libssh
1086 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1087 .if ${MK_KERBEROS} != "no"
1088 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1089 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1090 kerberos5/lib/libroken__L
1094 _secure_lib= secure/lib
1097 .if ${MK_IPX} != "no"
1098 _lib_libipx= lib/libipx
1101 .if ${MK_KERBEROS} != "no"
1102 _kerberos5_lib= kerberos5/lib
1103 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1104 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1105 _kerberos5_lib_libroken= kerberos5/lib/libroken
1106 _lib_libgssapi= lib/libgssapi
1109 .if ${MK_NIS} != "no"
1110 _lib_libypclnt= lib/libypclnt
1113 .if ${MK_OPENSSL} == "no"
1114 lib/libradius__L: lib/libmd__L
1117 .for _lib in ${_prereq_libs}
1119 .if exists(${.CURDIR}/${_lib})
1120 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1121 cd ${.CURDIR}/${_lib}; \
1122 ${MAKE} DIRPRFX=${_lib}/ obj; \
1123 ${MAKE} DIRPRFX=${_lib}/ depend; \
1124 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1125 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1129 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1131 .if exists(${.CURDIR}/${_lib})
1132 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1133 cd ${.CURDIR}/${_lib}; \
1134 ${MAKE} DIRPRFX=${_lib}/ obj; \
1135 ${MAKE} DIRPRFX=${_lib}/ depend; \
1136 ${MAKE} DIRPRFX=${_lib}/ all; \
1137 ${MAKE} DIRPRFX=${_lib}/ install
1141 # libpam is special: we need to build static PAM modules before
1142 # static PAM library, and dynamic PAM library before dynamic PAM
1144 lib/libpam__L: .PHONY
1145 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1146 cd ${.CURDIR}/lib/libpam; \
1147 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1148 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1149 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1150 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1152 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1153 _startup_libs: ${_startup_libs:S/$/__L/}
1154 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1155 _generic_libs: ${_generic_libs:S/$/__L/}
1157 .for __target in all clean cleandepend cleandir depend includes obj
1158 .for entry in ${SUBDIR}
1159 ${entry}.${__target}__D: .PHONY
1160 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1161 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1162 edir=${entry}.${MACHINE_ARCH}; \
1163 cd ${.CURDIR}/$${edir}; \
1165 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1167 cd ${.CURDIR}/$${edir}; \
1169 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1171 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1174 .include <bsd.subdir.mk>
1176 .if make(check-old) || make(check-old-dirs) || \
1177 make(check-old-files) || make(check-old-libs) || \
1178 make(delete-old) || make(delete-old-dirs) || \
1179 make(delete-old-files) || make(delete-old-libs)
1182 # check for / delete old files section
1185 .include "ObsoleteFiles.inc"
1187 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1188 else you can not start such an application. Consult UPDATING for more \
1189 information regarding how to cope with the removal/revision bump of a \
1192 .if !defined(BATCH_DELETE_OLD_FILES)
1199 @echo ">>> Removing old files (only deletes safe to delete libs)"
1200 # Ask for every old file if the user really wants to remove it.
1201 # It's annoying, but better safe than sorry.
1202 @for file in ${OLD_FILES}; do \
1203 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1204 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1205 rm ${RM_I} "${DESTDIR}/$${file}"; \
1208 # Remove catpages without corresponding manpages.
1210 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1211 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1212 while read catpage; do \
1214 if [ ! -e "$${manpage}" ]; then \
1215 rm ${RM_I} $${catpage} <&3 ; \
1218 @echo ">>> Old files removed"
1221 @echo ">>> Checking for old files"
1222 @for file in ${OLD_FILES}; do \
1223 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1224 echo "${DESTDIR}/$${file}"; \
1227 # Check for catpages without corresponding manpages.
1228 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1229 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1230 while read catpage; do \
1232 if [ ! -e "$${manpage}" ]; then \
1233 echo $${catpage} ; \
1238 @echo ">>> Removing old libraries"
1239 @echo "${OLD_LIBS_MESSAGE}" | fmt
1240 @for file in ${OLD_LIBS}; do \
1241 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1242 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1243 rm ${RM_I} "${DESTDIR}/$${file}"; \
1246 @echo ">>> Old libraries removed"
1249 @echo ">>> Checking for old libraries"
1250 @for file in ${OLD_LIBS}; do \
1251 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1252 echo "${DESTDIR}/$${file}"; \
1257 @echo ">>> Removing old directories"
1258 @for dir in ${OLD_DIRS}; do \
1259 if [ -d "${DESTDIR}/$${dir}" ]; then \
1260 rmdir -v "${DESTDIR}/$${dir}" || true; \
1261 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1262 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1265 @echo ">>> Old directories removed"
1268 @echo ">>> Checking for old directories"
1269 @for dir in ${OLD_DIRS}; do \
1270 if [ -d "${DESTDIR}/$${dir}" ]; then \
1271 echo "${DESTDIR}/$${dir}"; \
1272 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1273 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1277 delete-old: delete-old-files delete-old-dirs
1278 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1280 check-old: check-old-files check-old-libs check-old-dirs
1281 @echo "To remove old files and directories run '${MAKE} delete-old'."
1282 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1287 # showconfig - show build configuration.
1290 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort