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="arch" to crossbuild world to a different arch
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
98 .if defined(TARGET) && !defined(TARGET_ARCH)
99 TARGET_ARCH=${TARGET:S/pc98/i386/}
101 TARGET_ARCH?= ${MACHINE_ARCH}
102 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
104 TARGET_CPUTYPE?=${CPUTYPE}
106 TARGET?= ${TARGET_ARCH}
109 .if !empty(TARGET_CPUTYPE)
110 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
112 _TARGET_CPUTYPE=dummy
114 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
115 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
116 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
117 .error CPUTYPE global should be set with ?=.
120 BUILD_ARCH!= uname -p
121 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
122 .error To cross-build, set TARGET_ARCH.
125 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
126 OBJTREE= ${MAKEOBJDIRPREFIX}
128 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
130 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
131 # /usr/games added for fortune which depend on strfile
132 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
133 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
134 STRICTTMPPATH= ${BPATH}:${XPATH}
135 TMPPATH= ${STRICTTMPPATH}:${PATH}
137 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
140 # Building a world goes through the following stages
142 # 1. legacy stage [BMAKE]
143 # This stage is responsible for creating compatibility
144 # shims that are needed by the bootstrap-tools,
145 # build-tools and cross-tools stages.
146 # 1. bootstrap-tools stage [BMAKE]
147 # This stage is responsible for creating programs that
148 # are needed for backward compatibility reasons. They
149 # are not built as cross-tools.
150 # 2. build-tools stage [TMAKE]
151 # This stage is responsible for creating the object
152 # tree and building any tools that are needed during
154 # 3. cross-tools stage [XMAKE]
155 # This stage is responsible for creating any tools that
156 # are needed for cross-builds. A cross-compiler is one
158 # 4. world stage [WMAKE]
159 # This stage actually builds the world.
160 # 5. install stage (optional) [IMAKE]
161 # This stage installs a previously built world.
166 # Common environment for world related stages
167 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
168 MACHINE_ARCH=${TARGET_ARCH} \
170 CPUTYPE=${TARGET_CPUTYPE} \
171 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
172 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
173 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
175 # bootstrap-tools stage
176 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
177 PATH=${BPATH}:${PATH} \
178 WORLDTMP=${WORLDTMP} \
179 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
180 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
181 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
183 BOOTSTRAPPING=${OSRELDATE} \
184 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
185 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
186 -DNO_CPU_CFLAGS -DNO_WARNS
189 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
190 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
192 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
195 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
196 -DWITHOUT_FORTRAN -DWITHOUT_GDB
199 WMAKEENV= ${CROSSENV} \
200 _SHLIBDIRPREFIX=${WORLDTMP} \
201 INSTALL="sh ${.CURDIR}/tools/install.sh" \
203 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
205 .if ${TARGET_ARCH} == "amd64"
207 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
209 .if empty(TARGET_CPUTYPE)
212 LIB32CPUTYPE= ${TARGET_CPUTYPE}
214 LIB32PREFLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
215 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
216 -L${LIB32TMP}/usr/lib32 \
217 -B${LIB32TMP}/usr/lib32
218 LIB32CC= ${LIB32PREFLAGS} \
220 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
222 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
225 # Yes, the flags are redundant.
226 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
227 _SHLIBDIRPREFIX=${LIB32TMP} \
230 INSTALL="sh ${.CURDIR}/tools/install.sh" \
232 CC="${CC} ${LIB32CC}" \
233 CXX="${CXX} ${LIB32CXX}" \
234 OBJC="${OBJC} ${LIB32OBJC}" \
235 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
240 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
241 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
243 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -DNO_INCS
247 .if empty(.MAKEFLAGS:M-n)
248 IMAKEENV= ${CROSSENV} \
249 PATH=${STRICTTMPPATH}:${INSTALLTMP}
251 IMAKEENV= ${CROSSENV} \
252 PATH=${TMPPATH}:${INSTALLTMP}
254 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
257 KMAKEENV= ${WMAKEENV}
258 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
263 # Attempt to rebuild the entire system, with reasonable chance of
264 # success, regardless of how old your existing system is.
267 .if ${.CURDIR:C/[^,]//g} != ""
268 # The m4 build of sendmail files doesn't like it if ',' is used
269 # anywhere in the path of it's files.
271 @echo "*** Error: path to source tree contains a comma ','"
276 @echo "--------------------------------------------------------------"
277 @echo ">>> Rebuilding the temporary build tree"
278 @echo "--------------------------------------------------------------"
279 .if !defined(NO_CLEAN)
281 .if ${TARGET_ARCH} == "amd64"
285 rm -rf ${WORLDTMP}/legacy/usr/include
286 # XXX - These two can depend on any header file.
287 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
288 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
291 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
292 usr/libexec usr/sbin usr/share/dict \
293 usr/share/groff_font/devX100 \
294 usr/share/groff_font/devX100-12 \
295 usr/share/groff_font/devX75 \
296 usr/share/groff_font/devX75-12 \
297 usr/share/groff_font/devascii \
298 usr/share/groff_font/devcp1047 \
299 usr/share/groff_font/devdvi \
300 usr/share/groff_font/devhtml \
301 usr/share/groff_font/devkoi8-r \
302 usr/share/groff_font/devlatin1 \
303 usr/share/groff_font/devlbp \
304 usr/share/groff_font/devlj4 \
305 usr/share/groff_font/devps \
306 usr/share/groff_font/devutf8 \
307 usr/share/tmac/mdoc usr/share/tmac/mm
308 mkdir -p ${WORLDTMP}/legacy/${_dir}
311 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
312 usr/libexec usr/sbin usr/share/misc \
313 usr/share/snmp/defs usr/share/snmp/mibs
314 mkdir -p ${WORLDTMP}/${_dir}
316 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
317 -p ${WORLDTMP}/usr/include >/dev/null
318 ln -sf ${.CURDIR}/sys ${WORLDTMP}
319 .if ${MK_BIND_LIBS} != "no"
320 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
321 -p ${WORLDTMP}/usr/include >/dev/null
325 @echo "--------------------------------------------------------------"
326 @echo ">>> stage 1.1: legacy release compatibility shims"
327 @echo "--------------------------------------------------------------"
328 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
331 @echo "--------------------------------------------------------------"
332 @echo ">>> stage 1.2: bootstrap tools"
333 @echo "--------------------------------------------------------------"
334 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
336 .if !defined(NO_CLEAN)
338 @echo "--------------------------------------------------------------"
339 @echo ">>> stage 2.1: cleaning up the object tree"
340 @echo "--------------------------------------------------------------"
341 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
342 .if ${TARGET_ARCH} == "amd64"
343 rm -rf ${OBJTREE}/lib32
348 @echo "--------------------------------------------------------------"
349 @echo ">>> stage 2.2: rebuilding the object tree"
350 @echo "--------------------------------------------------------------"
351 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
354 @echo "--------------------------------------------------------------"
355 @echo ">>> stage 2.3: build tools"
356 @echo "--------------------------------------------------------------"
357 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
360 @echo "--------------------------------------------------------------"
361 @echo ">>> stage 3: cross tools"
362 @echo "--------------------------------------------------------------"
363 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
366 @echo "--------------------------------------------------------------"
367 @echo ">>> stage 4.1: building includes"
368 @echo "--------------------------------------------------------------"
369 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
372 @echo "--------------------------------------------------------------"
373 @echo ">>> stage 4.2: building libraries"
374 @echo "--------------------------------------------------------------"
375 ${_+_}cd ${.CURDIR}; \
376 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
377 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
380 @echo "--------------------------------------------------------------"
381 @echo ">>> stage 4.3: make dependencies"
382 @echo "--------------------------------------------------------------"
383 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
386 @echo "--------------------------------------------------------------"
387 @echo ">>> stage 4.4: building everything"
388 @echo "--------------------------------------------------------------"
389 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
390 .if ${TARGET_ARCH} == "amd64"
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 5.1: building 32 bit shim libraries"
395 @echo "--------------------------------------------------------------"
397 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
398 usr/libexec usr/sbin usr/share/misc \
399 usr/share/snmp/defs usr/share/snmp/mibs
400 mkdir -p ${LIB32TMP}/${_dir}
402 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
403 -p ${LIB32TMP}/usr/include >/dev/null
405 ln -sf ${.CURDIR}/sys ${WORLDTMP}
406 .if ${MK_KERBEROS} != "no"
407 .for _t in obj depend all
408 cd ${.CURDIR}/kerberos5/tools; \
409 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
412 .for _t in obj includes
413 cd ${.CURDIR}/include; \
414 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
417 cd ${.CURDIR}/gnu/lib; \
418 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419 .if ${MK_CRYPT} != "no"
420 cd ${.CURDIR}/secure/lib; \
421 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
423 .if ${MK_KERBEROS} != "no"
424 cd ${.CURDIR}/kerberos5/lib; \
425 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
428 .for _dir in usr.bin/lex/lib
429 cd ${.CURDIR}/${_dir}; \
430 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
432 .for _dir in lib/libncurses lib/libmagic
433 cd ${.CURDIR}/${_dir}; \
434 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
437 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
438 .for _t in obj depend all
439 cd ${.CURDIR}/libexec/rtld-elf; \
440 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
443 distribute32 install32:
444 .if make(distribute32)
445 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
447 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
449 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
450 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
451 .if ${MK_CRYPT} != "no"
452 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
454 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
459 .if !defined(SUBDIR_OVERRIDE)
460 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
462 WMAKE_TGTS+= _cleanobj _obj _build-tools
463 .if !defined(SUBDIR_OVERRIDE)
464 WMAKE_TGTS+= _cross-tools
466 WMAKE_TGTS+= _includes _libraries _depend everything
467 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
471 buildworld: ${WMAKE_TGTS}
472 .ORDER: ${WMAKE_TGTS}
476 # We need to have this as a target because the indirection between Makefile
477 # and Makefile.inc1 causes the correct PATH to be used, rather than a
478 # modification of the current environment's PATH. In addition, we need
479 # to quote multiword values.
485 @echo Entering world for ${TARGET_ARCH}:${TARGET}
486 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
488 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
489 toolchain: ${TOOLCHAIN_TGTS}
490 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
495 # Checks to be sure system is ready for installworld/installkernel.
500 # Require DESTDIR to be set if installing for a different architecture.
502 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
503 .if !make(distributeworld)
504 installcheck: installcheck_DESTDIR
505 installcheck_DESTDIR:
506 .if !defined(DESTDIR) || empty(DESTDIR)
507 @echo "ERROR: Please set DESTDIR!"; \
514 # Check for missing UIDs/GIDs.
518 .if ${MK_SENDMAIL} != "no"
524 CHECK_GIDS+= proxy authpf
526 installcheck: installcheck_UGID
528 .for uid in ${CHECK_UIDS}
529 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
530 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
534 .for gid in ${CHECK_GIDS}
535 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
536 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
544 # Distributes everything compiled by a `buildworld'.
548 # Installs everything compiled by a 'buildworld'.
550 distributeworld installworld: installcheck
551 mkdir -p ${INSTALLTMP}
552 for prog in [ awk cap_mkdb cat chflags chmod chown \
553 date echo egrep find grep install-info \
554 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
555 test true uname wc zic; do \
556 cp `which $$prog` ${INSTALLTMP}; \
558 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
564 # If you have a build server, you can NFS mount the source and obj directories
565 # and do a 'make reinstall' on the *client* to install new binaries from the
566 # most recent server build.
569 @echo "--------------------------------------------------------------"
570 @echo ">>> Making hierarchy"
571 @echo "--------------------------------------------------------------"
572 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
574 @echo "--------------------------------------------------------------"
575 @echo ">>> Installing everything"
576 @echo "--------------------------------------------------------------"
577 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
578 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
579 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
583 @echo "--------------------------------------------------------------"
584 @echo ">>> Distributing everything"
585 @echo "--------------------------------------------------------------"
586 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
587 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
588 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
591 distrib-dirs distribution:
592 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
595 # buildkernel and installkernel
597 # Which kernels to build and/or install is specified by setting
598 # KERNCONF. If not defined a GENERIC kernel is built/installed.
599 # Only the existing (depending TARGET) config files are used
600 # for building kernels and only the first of these is designated
601 # as the one being installed.
603 # Note that we have to use TARGET instead of TARGET_ARCH when
604 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
605 # be set to cross-build, we have to make sure TARGET is set
608 .if !defined(KERNCONF) && defined(KERNEL)
614 INSTKERNNAME?= kernel
616 KERNSRCDIR?= ${.CURDIR}/sys
617 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
618 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
619 KERNCONFDIR?= ${KRNLCONFDIR}
623 .for _kernel in ${KERNCONF}
624 .if exists(${KERNCONFDIR}/${_kernel})
625 BUILDKERNELS+= ${_kernel}
626 .if empty(INSTALLKERNEL)
627 INSTALLKERNEL= ${_kernel}
635 # Builds all kernels defined by BUILDKERNELS.
638 .if empty(BUILDKERNELS)
639 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
642 .if defined(KERNWARN)
643 @echo "--------------------------------------------------------------"
644 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
645 @echo "--------------------------------------------------------------"
649 .for _kernel in ${BUILDKERNELS}
650 @echo "--------------------------------------------------------------"
651 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
652 @echo "--------------------------------------------------------------"
653 @echo "===> ${_kernel}"
654 mkdir -p ${KRNLOBJDIR}
655 .if !defined(NO_KERNELCONFIG)
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 1: configuring the kernel"
659 @echo "--------------------------------------------------------------"
662 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
663 ${KERNCONFDIR}/${_kernel}
665 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
667 @echo "--------------------------------------------------------------"
668 @echo ">>> stage 2.1: cleaning up the object tree"
669 @echo "--------------------------------------------------------------"
670 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
673 @echo "--------------------------------------------------------------"
674 @echo ">>> stage 2.2: rebuilding the object tree"
675 @echo "--------------------------------------------------------------"
676 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
678 @echo "--------------------------------------------------------------"
679 @echo ">>> stage 2.3: build tools"
680 @echo "--------------------------------------------------------------"
681 cd ${KRNLOBJDIR}/${_kernel}; \
682 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
683 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
684 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
685 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
686 .for target in obj depend all
687 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
688 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
689 ${MAKE} -DNO_CPU_CFLAGS ${target}
692 .if !defined(NO_KERNELDEPEND)
694 @echo "--------------------------------------------------------------"
695 @echo ">>> stage 3.1: making dependencies"
696 @echo "--------------------------------------------------------------"
697 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
700 @echo "--------------------------------------------------------------"
701 @echo ">>> stage 3.2: building everything"
702 @echo "--------------------------------------------------------------"
703 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
704 @echo "--------------------------------------------------------------"
705 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
706 @echo "--------------------------------------------------------------"
710 # installkernel, etc.
712 # Install the kernel defined by INSTALLKERNEL
714 installkernel installkernel.debug \
715 reinstallkernel reinstallkernel.debug: installcheck
716 .if empty(INSTALLKERNEL)
717 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
720 @echo "--------------------------------------------------------------"
721 @echo ">>> Installing kernel"
722 @echo "--------------------------------------------------------------"
723 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
724 ${CROSSENV} PATH=${TMPPATH} \
725 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
730 # Build the API documentation with doxygen
733 @if [ ! -x `/usr/bin/which doxygen` ]; then \
734 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
737 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
742 # Update the source tree, by running cvsup and/or running cvs to update to the
746 .if defined(SUP_UPDATE)
747 @echo "--------------------------------------------------------------"
748 @echo ">>> Running ${SUP}"
749 @echo "--------------------------------------------------------------"
751 @${SUP} ${SUPFLAGS} ${SUPFILE}
753 .if defined(SUPFILE1)
754 @${SUP} ${SUPFLAGS} ${SUPFILE1}
756 .if defined(SUPFILE2)
757 @${SUP} ${SUPFLAGS} ${SUPFILE2}
759 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
760 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
762 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
763 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
766 .if defined(CVS_UPDATE)
767 @echo "--------------------------------------------------------------"
768 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
769 @echo "--------------------------------------------------------------"
770 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
774 # ------------------------------------------------------------------------
776 # From here onwards are utility targets used by the 'make world' and
777 # related targets. If your 'world' breaks, you may like to try to fix
778 # the problem and manually run the following targets to attempt to
779 # complete the build. Beware, this is *not* guaranteed to work, you
780 # need to have a pretty good grip on the current state of the system
781 # to attempt to manually finish it. If in doubt, 'make world' again.
785 # legacy: Build compatibility shims for the next three targets
788 .if ${BOOTSTRAPPING} < 503000
789 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
792 .for _tool in tools/build
793 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
794 cd ${.CURDIR}/${_tool}; \
795 ${MAKE} DIRPRFX=${_tool}/ obj; \
796 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
797 ${MAKE} DIRPRFX=${_tool}/ depend; \
798 ${MAKE} DIRPRFX=${_tool}/ all; \
799 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
803 # bootstrap-tools: Build tools needed for compatibility
805 .if ${MK_GAMES} != "no"
806 _strfile= games/fortune/strfile
809 .if ${MK_CXX} != "no"
810 _gperf= gnu/usr.bin/gperf
811 .if ${BOOTSTRAPPING} < 700004
812 _groff= gnu/usr.bin/groff
814 _groff= gnu/usr.bin/groff/tmac
818 .if ${BOOTSTRAPPING} < 600029
819 _texinfo= gnu/usr.bin/texinfo
822 .if ${BOOTSTRAPPING} < 600015
823 _cap_mkdb= usr.bin/cap_mkdb
826 .if ${BOOTSTRAPPING} < 600018
827 _colldef= usr.bin/colldef
830 .if ${BOOTSTRAPPING} < 600017
831 _gencat= usr.bin/gencat
834 .if ${BOOTSTRAPPING} < 600016
835 _mklocale= usr.bin/mklocale
838 .if ${BOOTSTRAPPING} < 700015
839 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
842 .if ${MK_RESCUE} != "no" && \
843 ${BOOTSTRAPPING} < 600008
844 _crunchgen= usr.sbin/crunch/crunchgen
847 .if ${BOOTSTRAPPING} < 600020
848 _pwd_mkdb= usr.sbin/pwd_mkdb
869 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
870 cd ${.CURDIR}/${_tool}; \
871 ${MAKE} DIRPRFX=${_tool}/ obj; \
872 ${MAKE} DIRPRFX=${_tool}/ depend; \
873 ${MAKE} DIRPRFX=${_tool}/ all; \
874 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
878 # build-tools: Build special purpose build tools
880 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
881 _aicasm= sys/modules/aic7xxx/aicasm
884 .if !defined(NO_SHARE)
885 _share= share/syscons/scrnmaps
888 .if ${MK_KERBEROS} != "no"
889 _kerberos5_tools= kerberos5/tools
892 .if ${MK_RESCUE} != "no"
893 _rescue= rescue/rescue
907 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
908 cd ${.CURDIR}/${_tool}; \
909 ${MAKE} DIRPRFX=${_tool}/ obj; \
910 ${MAKE} DIRPRFX=${_tool}/ build-tools
913 gnu/usr.bin/cc/cc_tools \
915 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
916 cd ${.CURDIR}/${_tool}; \
917 ${MAKE} DIRPRFX=${_tool}/ obj; \
918 ${MAKE} DIRPRFX=${_tool}/ depend; \
919 ${MAKE} DIRPRFX=${_tool}/ all
923 # cross-tools: Build cross-building tools
925 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
926 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
927 _btxld= usr.sbin/btxld
929 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
930 _crunchide= usr.sbin/crunch/crunchide
932 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
933 _kgzip= usr.sbin/kgzip
939 gnu/usr.bin/binutils \
941 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
945 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
946 cd ${.CURDIR}/${_tool}; \
947 ${MAKE} DIRPRFX=${_tool}/ obj; \
948 ${MAKE} DIRPRFX=${_tool}/ depend; \
949 ${MAKE} DIRPRFX=${_tool}/ all; \
950 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
954 # hierarchy - ensure that all the needed directories are present
957 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
960 # libraries - build all libraries, and install them under ${DESTDIR}.
962 # The list of libraries with dependents (${_prebuild_libs}) and their
963 # interdependencies (__L) are built automatically by the
964 # ${.CURDIR}/tools/make_libdeps.sh script.
968 ${MAKE} -f Makefile.inc1 _startup_libs; \
969 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
970 ${MAKE} -f Makefile.inc1 _generic_libs;
972 # These dependencies are not automatically generated:
974 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
975 # shared libraries for ELF.
977 _startup_libs= gnu/lib/csu gnu/lib/libgcc
978 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
979 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
981 _startup_libs+= lib/csu/${MACHINE_ARCH}
986 _generic_libs= gnu/lib
988 .if ${MK_IPX} != "no"
989 _prebuild_libs+= lib/libipx
992 .if ${MK_KERBEROS} != "no"
993 _prebuild_libs+= kerberos5/lib/libasn1
994 _prebuild_libs+= kerberos5/lib/libkrb5
995 _prebuild_libs+= kerberos5/lib/libroken
996 _generic_libs+= kerberos5/lib
999 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1000 lib/libkiconv lib/libkvm lib/libmd \
1001 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1003 lib/libsbuf lib/libtacplus lib/libutil \
1004 lib/libz lib/msun lib/libgssapi
1006 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1010 .if ${MK_CRYPT} != "no"
1011 .if ${MK_OPENSSL} != "no"
1012 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
1013 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1014 .if ${MK_OPENSSH} != "no"
1015 _prebuild_libs+= secure/lib/libssh
1016 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1017 .if ${MK_KERBEROS} != "no"
1018 secure/lib/libssh__L: lib/libgssapi__L
1022 _generic_libs+= secure/lib
1025 .if ${MK_OPENSSL} == "no"
1026 lib/libradius__L: lib/libmd__L
1029 .if ${MK_NIS} != "no"
1030 _prebuild_libs+= lib/libypclnt
1033 _generic_libs+= usr.bin/lex/lib
1035 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1037 .if exists(${.CURDIR}/${_lib})
1038 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1039 cd ${.CURDIR}/${_lib}; \
1040 ${MAKE} DIRPRFX=${_lib}/ obj; \
1041 ${MAKE} DIRPRFX=${_lib}/ depend; \
1042 ${MAKE} DIRPRFX=${_lib}/ all; \
1043 ${MAKE} DIRPRFX=${_lib}/ install
1047 # libpam is special: we need to build static PAM modules before
1048 # static PAM library, and dynamic PAM library before dynamic PAM
1050 lib/libpam__L: .PHONY
1051 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1052 cd ${.CURDIR}/lib/libpam; \
1053 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1054 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1055 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1056 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1058 _startup_libs: ${_startup_libs:S/$/__L/}
1059 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1060 _generic_libs: ${_generic_libs:S/$/__L/}
1062 .for __target in all clean cleandepend cleandir depend includes obj
1063 .for entry in ${SUBDIR}
1064 ${entry}.${__target}__D: .PHONY
1065 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1066 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1067 edir=${entry}.${MACHINE_ARCH}; \
1068 cd ${.CURDIR}/$${edir}; \
1070 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1072 cd ${.CURDIR}/$${edir}; \
1074 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1076 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1079 .include <bsd.subdir.mk>
1081 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1084 # check for / delete old files section
1087 .include "ObsoleteFiles.inc"
1089 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1090 else you can not start such an application. Consult UPDATING for more \
1091 information regarding how to cope with the removal/revision bump of a \
1094 .if !defined(BATCH_DELETE_OLD_FILES)
1101 @echo ">>> Removing old files (only deletes safe to delete libs)"
1102 .for file in ${OLD_FILES}
1103 # Ask for every old file if the user really wants to remove it.
1104 # It's annoying, but better safe than sorry.
1105 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1106 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1107 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1108 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1109 chflags noschg "${DESTDIR}/${file}"; \
1110 rm ${RM_I} "${DESTDIR}/${file}"; \
1114 # Remove catpages without corresponding manpages.
1116 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1117 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1118 while read catpage; do \
1120 if [ ! -e "$${manpage}" ]; then \
1121 rm ${RM_I} $${catpage} <&3 ; \
1124 @echo ">>> Old files removed"
1127 @echo ">>> Checking for old files"
1128 .for file in ${OLD_FILES}
1129 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1130 echo "${DESTDIR}/${file}"; \
1133 # Check for catpages without corresponding manpages.
1134 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1135 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1136 while read catpage; do \
1138 if [ ! -e "$${manpage}" ]; then \
1139 echo $${catpage} ; \
1144 @echo ">>> Removing old libraries"
1145 @echo "${OLD_LIBS_MESSAGE}" | fmt
1146 .for file in ${OLD_LIBS}
1147 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1148 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1149 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1150 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1151 chflags noschg "${DESTDIR}/${file}"; \
1152 rm ${RM_I} "${DESTDIR}/${file}"; \
1156 @echo ">>> Old libraries removed"
1159 @echo ">>> Checking for old libraries"
1160 .for file in ${OLD_LIBS}
1161 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1162 echo "${DESTDIR}/${file}"; \
1167 @echo ">>> Removing old directories"
1168 .for dir in ${OLD_DIRS}
1169 # Don't fail if an old directory isn't empty.
1170 @if [ -d "${DESTDIR}/${dir}" ]; then \
1171 rmdir -v "${DESTDIR}/${dir}" || true; \
1173 if [ -L "${DESTDIR}/${dir}" ]; then \
1174 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1178 @echo ">>> Old directories removed"
1181 @echo ">>> Checking for old directories"
1182 .for dir in ${OLD_DIRS}
1183 @if [ -d "${DESTDIR}/${dir}" ]; then \
1184 echo "${DESTDIR}/${dir}"; \
1186 if [ -L "${DESTDIR}/${dir}" ]; then \
1187 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1192 delete-old: delete-old-files delete-old-dirs
1193 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1195 check-old: check-old-files check-old-libs check-old-dirs
1196 @echo "To remove old files and directories run '${MAKE} delete-old'."
1197 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1202 # showconfig - show build configuration.
1205 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort