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="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 # update - convenient way to update your source tree (eg: cvsup/cvs)
22 # Standard targets (not defined here) are documented in the makefiles in
23 # /usr/share/mk. These include:
24 # obj depend all install clean cleandepend cleanobj
28 # We must do share/info early so that installation of info `dir'
29 # entries works correctly. Do it first since it is less likely to
30 # grow dependencies on include and lib than vice versa.
32 # We must do lib and libexec before bin, because if installworld
33 # installs a new /bin/sh, the 'make' command will *immediately*
34 # use that new version. And the new (dynamically-linked) /bin/sh
35 # will expect to find appropriate libraries in /lib and /libexec.
37 # We must do etc last for install/distribute to work.
39 SUBDIR= share/info include lib libexec bin
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 etc
59 # These are last, since it is nice to at least get the base system
60 # rebuilt before you do them.
61 .for _DIR in ${LOCAL_DIRS}
62 .if exists(${.CURDIR}/${_DIR}/Makefile)
67 .if defined(SUBDIR_OVERRIDE)
68 SUBDIR= ${SUBDIR_OVERRIDE}
74 .if defined(NO_CLEANDIR)
75 CLEANDIR= clean cleandepend
81 CVSFLAGS?= -A -P -d -I!
85 SUPFLAGS+= -h ${SUPHOST}
88 MAKEOBJDIRPREFIX?= /usr/obj
89 .if !defined(OSRELDATE)
90 .if exists(/usr/include/osreldate.h)
91 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
92 /usr/include/osreldate.h
97 TARGET_ARCH?= ${MACHINE_ARCH}
98 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
100 TARGET_CPUTYPE?=${CPUTYPE}
102 TARGET?= ${TARGET_ARCH}
105 .if !empty(TARGET_CPUTYPE)
106 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
108 _TARGET_CPUTYPE=dummy
110 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
111 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
112 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
113 .error CPUTYPE global should be set with ?=.
116 BUILD_ARCH!= uname -p
117 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
118 .error To cross-build, set TARGET_ARCH.
121 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
122 OBJTREE= ${MAKEOBJDIRPREFIX}
124 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
126 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
127 # /usr/games added for fortune which depend on strfile
128 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
129 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
130 STRICTTMPPATH= ${BPATH}:${XPATH}
131 TMPPATH= ${STRICTTMPPATH}:${PATH}
133 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
136 # Building a world goes through the following stages
138 # 1. legacy stage [BMAKE]
139 # This stage is responsible for creating compatibility
140 # shims that are needed by the bootstrap-tools,
141 # build-tools and cross-tools stages.
142 # 1. bootstrap-tools stage [BMAKE]
143 # This stage is responsible for creating programs that
144 # are needed for backward compatibility reasons. They
145 # are not built as cross-tools.
146 # 2. build-tools stage [TMAKE]
147 # This stage is responsible for creating the object
148 # tree and building any tools that are needed during
150 # 3. cross-tools stage [XMAKE]
151 # This stage is responsible for creating any tools that
152 # are needed for cross-builds. A cross-compiler is one
154 # 4. world stage [WMAKE]
155 # This stage actually builds the world.
156 # 5. install stage (optional) [IMAKE]
157 # This stage installs a previously built world.
162 # Common environment for world related stages
163 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
164 MACHINE_ARCH=${TARGET_ARCH} \
166 CPUTYPE=${TARGET_CPUTYPE} \
167 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
168 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
169 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
171 # bootstrap-tools stage
172 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
173 PATH=${BPATH}:${PATH} \
174 WORLDTMP=${WORLDTMP} \
175 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
176 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
177 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
179 BOOTSTRAPPING=${OSRELDATE} \
180 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
181 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
182 -DNO_CPU_CFLAGS -DNO_WARNS
185 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
186 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
188 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
191 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
192 -DWITHOUT_FORTRAN -DWITHOUT_GDB
195 WMAKEENV= ${CROSSENV} \
196 _SHLIBDIRPREFIX=${WORLDTMP} \
197 INSTALL="sh ${.CURDIR}/tools/install.sh" \
199 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
201 .if ${TARGET_ARCH} == "amd64"
203 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
205 .if empty(TARGET_CPUTYPE)
208 LIB32CPUTYPE= ${TARGET_CPUTYPE}
210 LIB32PREFLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
211 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
212 -L${LIB32TMP}/usr/lib32 \
213 -B${LIB32TMP}/usr/lib32
214 LIB32CC= ${LIB32PREFLAGS} \
216 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
218 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
221 # Yes, the flags are redundant.
222 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
223 _SHLIBDIRPREFIX=${LIB32TMP} \
226 INSTALL="sh ${.CURDIR}/tools/install.sh" \
228 CC="${CC} ${LIB32CC}" \
229 CXX="${CXX} ${LIB32CXX}" \
230 OBJC="${OBJC} ${LIB32OBJC}" \
231 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
236 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
237 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
239 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -DNO_INCS
243 .if empty(.MAKEFLAGS:M-n)
244 IMAKEENV= ${CROSSENV} \
245 PATH=${STRICTTMPPATH}:${INSTALLTMP}
247 IMAKEENV= ${CROSSENV} \
248 PATH=${TMPPATH}:${INSTALLTMP}
250 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
253 KMAKEENV= ${WMAKEENV}
254 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
259 # Attempt to rebuild the entire system, with reasonable chance of
260 # success, regardless of how old your existing system is.
263 .if ${.CURDIR:C/[^,]//g} != ""
264 # The m4 build of sendmail files doesn't like it if ',' is used
265 # anywhere in the path of it's files.
267 @echo "*** Error: path to source tree contains a comma ','"
272 @echo "--------------------------------------------------------------"
273 @echo ">>> Rebuilding the temporary build tree"
274 @echo "--------------------------------------------------------------"
275 .if !defined(NO_CLEAN)
277 .if ${TARGET_ARCH} == "amd64"
281 rm -rf ${WORLDTMP}/legacy/usr/include
282 # XXX - These two can depend on any header file.
283 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
284 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
287 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
288 usr/libexec usr/sbin usr/share/dict \
289 usr/share/groff_font/devX100 \
290 usr/share/groff_font/devX100-12 \
291 usr/share/groff_font/devX75 \
292 usr/share/groff_font/devX75-12 \
293 usr/share/groff_font/devascii \
294 usr/share/groff_font/devcp1047 \
295 usr/share/groff_font/devdvi \
296 usr/share/groff_font/devhtml \
297 usr/share/groff_font/devkoi8-r \
298 usr/share/groff_font/devlatin1 \
299 usr/share/groff_font/devlbp \
300 usr/share/groff_font/devlj4 \
301 usr/share/groff_font/devps \
302 usr/share/groff_font/devutf8 \
303 usr/share/tmac/mdoc usr/share/tmac/mm
304 mkdir -p ${WORLDTMP}/legacy/${_dir}
307 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
308 usr/libexec usr/sbin usr/share/misc \
309 usr/share/snmp/defs usr/share/snmp/mibs
310 mkdir -p ${WORLDTMP}/${_dir}
312 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
313 -p ${WORLDTMP}/usr/include >/dev/null
314 ln -sf ${.CURDIR}/sys ${WORLDTMP}
315 .if ${MK_BIND_LIBS} != "no"
316 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
317 -p ${WORLDTMP}/usr/include >/dev/null
321 @echo "--------------------------------------------------------------"
322 @echo ">>> stage 1.1: legacy release compatibility shims"
323 @echo "--------------------------------------------------------------"
324 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
327 @echo "--------------------------------------------------------------"
328 @echo ">>> stage 1.2: bootstrap tools"
329 @echo "--------------------------------------------------------------"
330 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
332 .if !defined(NO_CLEAN)
334 @echo "--------------------------------------------------------------"
335 @echo ">>> stage 2.1: cleaning up the object tree"
336 @echo "--------------------------------------------------------------"
337 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
338 .if ${TARGET_ARCH} == "amd64"
339 rm -rf ${OBJTREE}/lib32
344 @echo "--------------------------------------------------------------"
345 @echo ">>> stage 2.2: rebuilding the object tree"
346 @echo "--------------------------------------------------------------"
347 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
350 @echo "--------------------------------------------------------------"
351 @echo ">>> stage 2.3: build tools"
352 @echo "--------------------------------------------------------------"
353 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
356 @echo "--------------------------------------------------------------"
357 @echo ">>> stage 3: cross tools"
358 @echo "--------------------------------------------------------------"
359 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
362 @echo "--------------------------------------------------------------"
363 @echo ">>> stage 4.1: building includes"
364 @echo "--------------------------------------------------------------"
365 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
368 @echo "--------------------------------------------------------------"
369 @echo ">>> stage 4.2: building libraries"
370 @echo "--------------------------------------------------------------"
371 ${_+_}cd ${.CURDIR}; \
372 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
373 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
376 @echo "--------------------------------------------------------------"
377 @echo ">>> stage 4.3: make dependencies"
378 @echo "--------------------------------------------------------------"
379 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
382 @echo "--------------------------------------------------------------"
383 @echo ">>> stage 4.4: building everything"
384 @echo "--------------------------------------------------------------"
385 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
386 .if ${TARGET_ARCH} == "amd64"
389 @echo "--------------------------------------------------------------"
390 @echo ">>> stage 5.1: building 32 bit shim libraries"
391 @echo "--------------------------------------------------------------"
393 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
394 usr/libexec usr/sbin usr/share/misc \
395 usr/share/snmp/defs usr/share/snmp/mibs
396 mkdir -p ${LIB32TMP}/${_dir}
398 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
399 -p ${LIB32TMP}/usr/include >/dev/null
401 ln -sf ${.CURDIR}/sys ${WORLDTMP}
402 .if ${MK_KERBEROS} != "no"
403 .for _t in obj depend all
404 cd ${.CURDIR}/kerberos5/tools; \
405 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
408 .for _t in obj includes
409 cd ${.CURDIR}/include; \
410 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
413 cd ${.CURDIR}/gnu/lib; \
414 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
415 .if ${MK_CRYPT} != "no"
416 cd ${.CURDIR}/secure/lib; \
417 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419 .if ${MK_KERBEROS} != "no"
420 cd ${.CURDIR}/kerberos5/lib; \
421 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
424 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
425 cd ${.CURDIR}/${_dir}; \
426 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
428 .for _dir in lib/libncurses lib/libmagic
429 cd ${.CURDIR}/${_dir}; \
430 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
433 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
434 .for _t in obj depend all
435 cd ${.CURDIR}/libexec/rtld-elf; \
436 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
439 distribute32 install32:
440 .if make(distribute32)
441 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
443 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
445 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
446 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
447 .if ${MK_CRYPT} != "no"
448 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
450 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
455 .if !defined(SUBDIR_OVERRIDE)
456 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
458 WMAKE_TGTS+= _cleanobj _obj _build-tools
459 .if !defined(SUBDIR_OVERRIDE)
460 WMAKE_TGTS+= _cross-tools
462 WMAKE_TGTS+= _includes _libraries _depend everything
463 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
467 buildworld: ${WMAKE_TGTS}
468 .ORDER: ${WMAKE_TGTS}
471 @echo Entering world for ${TARGET_ARCH}:${TARGET}
472 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
474 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
475 toolchain: ${TOOLCHAIN_TGTS}
476 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
481 # Checks to be sure system is ready for installworld/installkernel.
486 # Require DESTDIR to be set if installing for a different architecture.
488 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
489 .if !make(distributeworld)
490 installcheck: installcheck_DESTDIR
491 installcheck_DESTDIR:
492 .if !defined(DESTDIR) || empty(DESTDIR)
493 @echo "ERROR: Please set DESTDIR!"; \
500 # Check for missing UIDs/GIDs.
504 .if ${MK_SENDMAIL} != "no"
510 CHECK_GIDS+= proxy authpf
512 installcheck: installcheck_UGID
514 .for uid in ${CHECK_UIDS}
515 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
516 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
520 .for gid in ${CHECK_GIDS}
521 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
522 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
530 # Distributes everything compiled by a `buildworld'.
534 # Installs everything compiled by a 'buildworld'.
536 distributeworld installworld: installcheck
537 mkdir -p ${INSTALLTMP}
538 for prog in [ awk cap_mkdb cat chflags chmod chown \
539 date echo egrep find grep install-info \
540 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
541 test true uname wc zic; do \
542 cp `which $$prog` ${INSTALLTMP}; \
544 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
550 # If you have a build server, you can NFS mount the source and obj directories
551 # and do a 'make reinstall' on the *client* to install new binaries from the
552 # most recent server build.
555 @echo "--------------------------------------------------------------"
556 @echo ">>> Making hierarchy"
557 @echo "--------------------------------------------------------------"
558 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
560 @echo "--------------------------------------------------------------"
561 @echo ">>> Installing everything"
562 @echo "--------------------------------------------------------------"
563 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
564 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
565 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
569 @echo "--------------------------------------------------------------"
570 @echo ">>> Distributing everything"
571 @echo "--------------------------------------------------------------"
572 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
573 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
574 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
577 distrib-dirs distribution:
578 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
581 # buildkernel and installkernel
583 # Which kernels to build and/or install is specified by setting
584 # KERNCONF. If not defined a GENERIC kernel is built/installed.
585 # Only the existing (depending TARGET) config files are used
586 # for building kernels and only the first of these is designated
587 # as the one being installed.
589 # Note that we have to use TARGET instead of TARGET_ARCH when
590 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
591 # be set to cross-build, we have to make sure TARGET is set
594 .if !defined(KERNCONF) && defined(KERNEL)
600 INSTKERNNAME?= kernel
602 KERNSRCDIR?= ${.CURDIR}/sys
603 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
604 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
605 KERNCONFDIR?= ${KRNLCONFDIR}
609 .for _kernel in ${KERNCONF}
610 .if exists(${KERNCONFDIR}/${_kernel})
611 BUILDKERNELS+= ${_kernel}
612 .if empty(INSTALLKERNEL)
613 INSTALLKERNEL= ${_kernel}
621 # Builds all kernels defined by BUILDKERNELS.
624 .if empty(BUILDKERNELS)
625 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
628 .if defined(KERNWARN)
629 @echo "--------------------------------------------------------------"
630 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
631 @echo "--------------------------------------------------------------"
635 .for _kernel in ${BUILDKERNELS}
636 @echo "--------------------------------------------------------------"
637 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
638 @echo "--------------------------------------------------------------"
639 @echo "===> ${_kernel}"
640 mkdir -p ${KRNLOBJDIR}
641 .if !defined(NO_KERNELCONFIG)
643 @echo "--------------------------------------------------------------"
644 @echo ">>> stage 1: configuring the kernel"
645 @echo "--------------------------------------------------------------"
648 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
649 ${KERNCONFDIR}/${_kernel}
651 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
653 @echo "--------------------------------------------------------------"
654 @echo ">>> stage 2.1: cleaning up the object tree"
655 @echo "--------------------------------------------------------------"
656 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
659 @echo "--------------------------------------------------------------"
660 @echo ">>> stage 2.2: rebuilding the object tree"
661 @echo "--------------------------------------------------------------"
662 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
664 @echo "--------------------------------------------------------------"
665 @echo ">>> stage 2.3: build tools"
666 @echo "--------------------------------------------------------------"
667 cd ${KRNLOBJDIR}/${_kernel}; \
668 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
669 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
670 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
671 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
672 .for target in obj depend all
673 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
674 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
675 ${MAKE} -DNO_CPU_CFLAGS ${target}
678 .if !defined(NO_KERNELDEPEND)
680 @echo "--------------------------------------------------------------"
681 @echo ">>> stage 3.1: making dependencies"
682 @echo "--------------------------------------------------------------"
683 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
686 @echo "--------------------------------------------------------------"
687 @echo ">>> stage 3.2: building everything"
688 @echo "--------------------------------------------------------------"
689 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
690 @echo "--------------------------------------------------------------"
691 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
692 @echo "--------------------------------------------------------------"
696 # installkernel, etc.
698 # Install the kernel defined by INSTALLKERNEL
700 installkernel installkernel.debug \
701 reinstallkernel reinstallkernel.debug: installcheck
702 .if empty(INSTALLKERNEL)
703 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
706 @echo "--------------------------------------------------------------"
707 @echo ">>> Installing kernel"
708 @echo "--------------------------------------------------------------"
709 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
710 ${CROSSENV} PATH=${TMPPATH} \
711 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
716 # Update the source tree, by running cvsup and/or running cvs to update to the
720 .if defined(SUP_UPDATE)
721 @echo "--------------------------------------------------------------"
722 @echo ">>> Running ${SUP}"
723 @echo "--------------------------------------------------------------"
725 @${SUP} ${SUPFLAGS} ${SUPFILE}
727 .if defined(SUPFILE1)
728 @${SUP} ${SUPFLAGS} ${SUPFILE1}
730 .if defined(SUPFILE2)
731 @${SUP} ${SUPFLAGS} ${SUPFILE2}
733 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
734 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
736 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
737 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
740 .if defined(CVS_UPDATE)
741 @echo "--------------------------------------------------------------"
742 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
743 @echo "--------------------------------------------------------------"
744 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
748 # ------------------------------------------------------------------------
750 # From here onwards are utility targets used by the 'make world' and
751 # related targets. If your 'world' breaks, you may like to try to fix
752 # the problem and manually run the following targets to attempt to
753 # complete the build. Beware, this is *not* guaranteed to work, you
754 # need to have a pretty good grip on the current state of the system
755 # to attempt to manually finish it. If in doubt, 'make world' again.
759 # legacy: Build compatibility shims for the next three targets
762 .if ${BOOTSTRAPPING} < 503000
763 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
766 .for _tool in tools/build
767 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
768 cd ${.CURDIR}/${_tool}; \
769 ${MAKE} DIRPRFX=${_tool}/ obj; \
770 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
771 ${MAKE} DIRPRFX=${_tool}/ depend; \
772 ${MAKE} DIRPRFX=${_tool}/ all; \
773 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
777 # bootstrap-tools: Build tools needed for compatibility
779 .if ${MK_GAMES} != "no"
780 _strfile= games/fortune/strfile
783 .if ${MK_CXX} != "no"
784 _gperf= gnu/usr.bin/gperf
785 .if ${BOOTSTRAPPING} < 700004
786 _groff= gnu/usr.bin/groff
788 _groff= gnu/usr.bin/groff/tmac
792 .if ${BOOTSTRAPPING} < 600029
793 _texinfo= gnu/usr.bin/texinfo
796 .if ${BOOTSTRAPPING} < 600015
797 _cap_mkdb= usr.bin/cap_mkdb
800 .if ${BOOTSTRAPPING} < 600018
801 _colldef= usr.bin/colldef
804 .if ${BOOTSTRAPPING} < 600017
805 _gencat= usr.bin/gencat
808 .if ${BOOTSTRAPPING} < 600016
809 _mklocale= usr.bin/mklocale
812 .if ${MK_RESCUE} != "no" && \
813 ${BOOTSTRAPPING} < 600008
814 _crunchgen= usr.sbin/crunch/crunchgen
817 .if ${BOOTSTRAPPING} < 600020
818 _pwd_mkdb= usr.sbin/pwd_mkdb
821 .if ${BOOTSTRAPPING} < 700014
822 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
843 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
844 cd ${.CURDIR}/${_tool}; \
845 ${MAKE} DIRPRFX=${_tool}/ obj; \
846 ${MAKE} DIRPRFX=${_tool}/ depend; \
847 ${MAKE} DIRPRFX=${_tool}/ all; \
848 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
852 # build-tools: Build special purpose build tools
854 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
855 _aicasm= sys/modules/aic7xxx/aicasm
858 .if !defined(NO_SHARE)
859 _share= share/syscons/scrnmaps
862 .if ${MK_KERBEROS} != "no"
863 _kerberos5_tools= kerberos5/tools
866 .if ${MK_RESCUE} != "no"
867 _rescue= rescue/rescue
881 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
882 cd ${.CURDIR}/${_tool}; \
883 ${MAKE} DIRPRFX=${_tool}/ obj; \
884 ${MAKE} DIRPRFX=${_tool}/ build-tools
887 gnu/usr.bin/cc/cc_tools \
889 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
890 cd ${.CURDIR}/${_tool}; \
891 ${MAKE} DIRPRFX=${_tool}/ obj; \
892 ${MAKE} DIRPRFX=${_tool}/ depend; \
893 ${MAKE} DIRPRFX=${_tool}/ all
897 # cross-tools: Build cross-building tools
899 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
900 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
901 _btxld= usr.sbin/btxld
903 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
904 _crunchide= usr.sbin/crunch/crunchide
906 .if ${TARGET_ARCH} == "alpha"
907 _elf2exe= usr.sbin/elf2exe
909 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
910 _kgzip= usr.sbin/kgzip
916 gnu/usr.bin/binutils \
918 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
923 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
924 cd ${.CURDIR}/${_tool}; \
925 ${MAKE} DIRPRFX=${_tool}/ obj; \
926 ${MAKE} DIRPRFX=${_tool}/ depend; \
927 ${MAKE} DIRPRFX=${_tool}/ all; \
928 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
932 # hierarchy - ensure that all the needed directories are present
935 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
938 # libraries - build all libraries, and install them under ${DESTDIR}.
940 # The list of libraries with dependents (${_prebuild_libs}) and their
941 # interdependencies (__L) are built automatically by the
942 # ${.CURDIR}/tools/make_libdeps.sh script.
946 ${MAKE} -f Makefile.inc1 _startup_libs; \
947 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
948 ${MAKE} -f Makefile.inc1 _generic_libs;
950 # These dependencies are not automatically generated:
952 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
953 # shared libraries for ELF.
955 _startup_libs= gnu/lib/csu gnu/lib/libgcc
956 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
957 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
959 _startup_libs+= lib/csu/${MACHINE_ARCH}
964 _generic_libs= gnu/lib
966 .if ${MK_IPX} != "no"
967 _prebuild_libs+= lib/libipx
970 .if ${MK_KERBEROS} != "no"
971 _prebuild_libs+= kerberos5/lib/libasn1
972 _prebuild_libs+= kerberos5/lib/libkrb5
973 _prebuild_libs+= kerberos5/lib/libroken
974 _generic_libs+= kerberos5/lib
977 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
978 lib/libkiconv lib/libkvm lib/libmd \
979 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
981 lib/libsbuf lib/libtacplus lib/libutil \
982 lib/libz lib/msun lib/libgssapi
984 lib/libopie__L lib/libtacplus__L: lib/libmd__L
988 .if ${MK_CRYPT} != "no"
989 .if ${MK_OPENSSL} != "no"
990 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
991 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
992 .if ${MK_OPENSSH} != "no"
993 _prebuild_libs+= secure/lib/libssh
994 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
995 .if ${MK_KERBEROS} != "no"
996 secure/lib/libssh__L: lib/libgssapi__L
1000 _generic_libs+= secure/lib
1003 .if ${MK_OPENSSL} == "no"
1004 lib/libradius__L: lib/libmd__L
1007 .if ${MK_NIS} != "no"
1008 _prebuild_libs+= lib/libypclnt
1011 _generic_libs+= usr.bin/lex/lib
1013 .if ${MACHINE} == "i386"
1014 _generic_libs+= usr.sbin/pcvt/keycap
1017 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1019 .if exists(${.CURDIR}/${_lib})
1020 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1021 cd ${.CURDIR}/${_lib}; \
1022 ${MAKE} DIRPRFX=${_lib}/ depend; \
1023 ${MAKE} DIRPRFX=${_lib}/ all; \
1024 ${MAKE} DIRPRFX=${_lib}/ install
1028 # libpam is special: we need to build static PAM modules before
1029 # static PAM library, and dynamic PAM library before dynamic PAM
1031 lib/libpam__L: .PHONY
1032 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1033 cd ${.CURDIR}/lib/libpam; \
1034 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1035 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1036 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1038 _startup_libs: ${_startup_libs:S/$/__L/}
1039 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1040 _generic_libs: ${_generic_libs:S/$/__L/}
1042 .for __target in all clean cleandepend cleandir depend includes obj
1043 .for entry in ${SUBDIR}
1044 ${entry}.${__target}__D: .PHONY
1045 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1046 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1047 edir=${entry}.${MACHINE_ARCH}; \
1048 cd ${.CURDIR}/$${edir}; \
1050 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1052 cd ${.CURDIR}/$${edir}; \
1054 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1056 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1059 .include <bsd.subdir.mk>
1061 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1064 # check for / delete old files section
1067 .include "ObsoleteFiles.inc"
1069 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1070 else you can not start such an application. Consult UPDATING for more \
1071 information regarding how to cope with the removal/revision bump of a \
1074 .if !defined(BATCH_DELETE_OLD_FILES)
1081 @echo ">>> Removing old files (only deletes safe to delete libs)"
1082 .for file in ${OLD_FILES}
1083 # Ask for every old file if the user really wants to remove it.
1084 # It's annoying, but better safe than sorry.
1085 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1086 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1087 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1088 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1089 chflags noschg "${DESTDIR}/${file}"; \
1090 rm ${RM_I} "${DESTDIR}/${file}"; \
1094 # Remove catpages without corresponding manpages.
1096 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1097 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1098 while read catpage; do \
1100 if [ ! -e "$${manpage}" ]; then \
1101 rm ${RM_I} $${catpage} <&3 ; \
1104 @echo ">>> Old files removed"
1107 @echo ">>> Checking for old files"
1108 .for file in ${OLD_FILES}
1109 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1110 echo "${DESTDIR}/${file}"; \
1113 # Check for catpages without corresponding manpages.
1114 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1115 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1116 while read catpage; do \
1118 if [ ! -e "$${manpage}" ]; then \
1119 echo $${catpage} ; \
1124 @echo ">>> Removing old libraries"
1125 @echo "${OLD_LIBS_MESSAGE}" | fmt
1126 .for file in ${OLD_LIBS}
1127 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1128 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1129 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1130 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1131 chflags noschg "${DESTDIR}/${file}"; \
1132 rm ${RM_I} "${DESTDIR}/${file}"; \
1136 @echo ">>> Old libraries removed"
1139 @echo ">>> Checking for old libraries"
1140 .for file in ${OLD_LIBS}
1141 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1142 echo "${DESTDIR}/${file}"; \
1147 @echo ">>> Removing old directories"
1148 .for dir in ${OLD_DIRS}
1149 # Don't fail if an old directory isn't empty.
1150 @if [ -d "${DESTDIR}/${dir}" ]; then \
1151 rmdir -v "${DESTDIR}/${dir}" || true; \
1153 if [ -L "${DESTDIR}/${dir}" ]; then \
1154 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1158 @echo ">>> Old directories removed"
1161 @echo ">>> Checking for old directories"
1162 .for dir in ${OLD_DIRS}
1163 @if [ -d "${DESTDIR}/${dir}" ]; then \
1164 echo "${DESTDIR}/${dir}"; \
1166 if [ -L "${DESTDIR}/${dir}" ]; then \
1167 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1172 delete-old: delete-old-files delete-old-dirs
1173 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1175 check-old: check-old-files check-old-libs check-old-dirs
1176 @echo "To remove old files and directories run '${MAKE} delete-old'."
1177 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1182 # showconfig - show build configuration.
1185 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort