4 # Make command line options:
5 # -DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6 # -DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7 # -DNO_RESCUE do not build rescue binaries
8 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9 # -DNO_CLEAN do not clean at all
10 # -DNO_CRYPT will prevent building of crypt versions
11 # -DNO_MAN do not build the manual pages
12 # -DNO_NLS do not build Native Language Support files
13 # -DNO_PROFILE do not build profiled libraries
14 # -DNO_GAMES do not go into games subdir
15 # -DNO_SHARE do not go into share subdir
16 # -DNO_INFO do not make or install info files
17 # -DNO_LIBC_R do not build libc_r.
18 # -DNO_FORTRAN do not build g77 and related libraries.
19 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
20 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
21 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
22 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
23 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
24 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
25 # TARGET_ARCH="arch" to crossbuild world to a different arch
28 # The intended user-driven targets are:
29 # buildworld - rebuild *everything*, including glue to help do upgrades
30 # installworld- install everything built by "buildworld"
31 # update - convenient way to update your source tree (eg: cvsup/cvs)
33 # Standard targets (not defined here) are documented in the makefiles in
34 # /usr/share/mk. These include:
35 # obj depend all install clean cleandepend cleanobj
37 # We must do share/info early so that installation of info `dir'
38 # entries works correctly. Do it first since it is less likely to
39 # grow dependencies on include and lib than vice versa.
41 # We must do lib and libexec before bin, because if installworld
42 # installs a new /bin/sh, the 'make' command will *immediately*
43 # use that new version. And the new (dynamically-linked) /bin/sh
44 # will expect to find appropriate libraries in /lib and /libexec.
46 # We must do etc last for install/distribute to work.
48 SUBDIR= share/info include lib libexec bin
49 .if !defined(NO_GAMES)
53 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
56 .if !defined(NO_RESCUE)
60 .if !defined(NO_CRYPT)
63 .if !defined(NO_SHARE)
66 SUBDIR+=sys usr.bin usr.sbin etc
68 # These are last, since it is nice to at least get the base system
69 # rebuilt before you do them.
70 .for _DIR in ${LOCAL_DIRS}
71 .if exists(${.CURDIR}/${_DIR}/Makefile)
76 .if defined(SUBDIR_OVERRIDE)
77 SUBDIR= ${SUBDIR_OVERRIDE}
83 .if defined(NO_CLEANDIR)
84 CLEANDIR= clean cleandepend
90 CVSFLAGS?= -A -P -d -I!
91 SUP?= /usr/local/bin/cvsup
92 SUPFLAGS?= -g -L 2 -P -
94 SUPFLAGS+= -h ${SUPHOST}
97 MAKEOBJDIRPREFIX?= /usr/obj
98 .if !defined(OSRELDATE)
99 .if exists(/usr/include/osreldate.h)
100 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
101 /usr/include/osreldate.h
106 TARGET_ARCH?= ${MACHINE_ARCH}
107 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
109 TARGET_CPUTYPE?=${CPUTYPE}
111 TARGET?= ${TARGET_ARCH}
114 .if !empty(TARGET_CPUTYPE)
115 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
117 _TARGET_CPUTYPE=dummy
119 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
120 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
121 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
122 .error CPUTYPE global should be set with ?=.
125 BUILD_ARCH!= uname -p
126 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
127 .error To cross-build, set TARGET_ARCH.
130 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
131 OBJTREE= ${MAKEOBJDIRPREFIX}
133 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
135 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
136 # /usr/games added for fortune which depend on strfile
137 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
138 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
139 STRICTTMPPATH= ${BPATH}:${XPATH}
140 TMPPATH= ${STRICTTMPPATH}:${PATH}
142 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
145 # Building a world goes through the following stages
147 # 1. legacy stage [BMAKE]
148 # This stage is responsible for creating compatibility
149 # shims that are needed by the bootstrap-tools,
150 # build-tools and cross-tools stages.
151 # 1. bootstrap-tools stage [BMAKE]
152 # This stage is responsible for creating programs that
153 # are needed for backward compatibility reasons. They
154 # are not built as cross-tools.
155 # 2. build-tools stage [TMAKE]
156 # This stage is responsible for creating the object
157 # tree and building any tools that are needed during
159 # 3. cross-tools stage [XMAKE]
160 # This stage is responsible for creating any tools that
161 # are needed for cross-builds. A cross-compiler is one
163 # 4. world stage [WMAKE]
164 # This stage actually builds the world.
165 # 5. install stage (optional) [IMAKE]
166 # This stage installs a previously built world.
171 # Common environment for world related stages
172 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
173 MACHINE_ARCH=${TARGET_ARCH} \
175 CPUTYPE=${TARGET_CPUTYPE} \
176 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
177 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
178 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
180 # bootstrap-tools stage
181 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
182 PATH=${BPATH}:${PATH} \
183 WORLDTMP=${WORLDTMP} \
184 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
185 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
186 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
188 BOOTSTRAPPING=${OSRELDATE} \
189 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
190 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
193 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
194 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
196 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
199 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
202 WMAKEENV= ${CROSSENV} \
203 _SHLIBDIRPREFIX=${WORLDTMP} \
204 INSTALL="sh ${.CURDIR}/tools/install.sh" \
206 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
208 .if ${TARGET_ARCH} == "amd64"
210 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
212 .if empty(TARGET_CPUTYPE)
215 LIB32CPUTYPE= ${TARGET_CPUTYPE}
217 LIB32PREFLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
218 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
219 -L${LIB32TMP}/usr/lib32 \
220 -B${LIB32TMP}/usr/lib32
221 LIB32CC= ${LIB32PREFLAGS} \
223 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
225 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
228 # Yes, the flags are redundant.
229 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
230 _SHLIBDIRPREFIX=${LIB32TMP} \
233 INSTALL="sh ${.CURDIR}/tools/install.sh" \
235 CC="${CC} ${LIB32CC}" \
236 CXX="${CXX} ${LIB32CXX}" \
237 OBJC="${OBJC} ${LIB32OBJC}" \
238 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
243 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
244 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
245 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -DNO_INCS
249 .if empty(.MAKEFLAGS:M-n)
250 IMAKEENV= ${CROSSENV} \
251 PATH=${STRICTTMPPATH}:${INSTALLTMP}
253 IMAKEENV= ${CROSSENV} \
254 PATH=${TMPPATH}:${INSTALLTMP}
256 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
259 KMAKEENV= ${WMAKEENV}
260 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
265 # Attempt to rebuild the entire system, with reasonable chance of
266 # success, regardless of how old your existing system is.
269 .if ${.CURDIR:C/[^,]//g} != ""
270 # The m4 build of sendmail files doesn't like it if ',' is used
271 # anywhere in the path of it's files.
273 @echo "*** Error: path to source tree contains a comma ','"
278 @echo "--------------------------------------------------------------"
279 @echo ">>> Rebuilding the temporary build tree"
280 @echo "--------------------------------------------------------------"
281 .if !defined(NO_CLEAN)
283 .if ${TARGET_ARCH} == "amd64"
287 rm -rf ${WORLDTMP}/legacy/usr/include
288 # XXX - These two can depend on any header file.
289 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
290 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
293 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
294 usr/libexec usr/sbin usr/share/dict \
295 usr/share/groff_font/devX100 \
296 usr/share/groff_font/devX100-12 \
297 usr/share/groff_font/devX75 \
298 usr/share/groff_font/devX75-12 \
299 usr/share/groff_font/devascii \
300 usr/share/groff_font/devcp1047 \
301 usr/share/groff_font/devdvi \
302 usr/share/groff_font/devhtml \
303 usr/share/groff_font/devkoi8-r \
304 usr/share/groff_font/devlatin1 \
305 usr/share/groff_font/devlbp \
306 usr/share/groff_font/devlj4 \
307 usr/share/groff_font/devps \
308 usr/share/groff_font/devutf8 \
309 usr/share/tmac/mdoc usr/share/tmac/mm
310 mkdir -p ${WORLDTMP}/legacy/${_dir}
313 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
314 usr/libexec usr/sbin usr/share/misc \
315 usr/share/snmp/defs usr/share/snmp/mibs
316 mkdir -p ${WORLDTMP}/${_dir}
318 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
319 -p ${WORLDTMP}/usr/include >/dev/null
320 ln -sf ${.CURDIR}/sys ${WORLDTMP}
321 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
322 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
323 -p ${WORLDTMP}/usr/include >/dev/null
327 @echo "--------------------------------------------------------------"
328 @echo ">>> stage 1.1: legacy release compatibility shims"
329 @echo "--------------------------------------------------------------"
330 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
333 @echo "--------------------------------------------------------------"
334 @echo ">>> stage 1.2: bootstrap tools"
335 @echo "--------------------------------------------------------------"
336 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
338 .if !defined(NO_CLEAN)
340 @echo "--------------------------------------------------------------"
341 @echo ">>> stage 2.1: cleaning up the object tree"
342 @echo "--------------------------------------------------------------"
343 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
344 .if ${TARGET_ARCH} == "amd64"
345 rm -rf ${OBJTREE}/lib32
350 @echo "--------------------------------------------------------------"
351 @echo ">>> stage 2.2: rebuilding the object tree"
352 @echo "--------------------------------------------------------------"
353 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
356 @echo "--------------------------------------------------------------"
357 @echo ">>> stage 2.3: build tools"
358 @echo "--------------------------------------------------------------"
359 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
362 @echo "--------------------------------------------------------------"
363 @echo ">>> stage 3: cross tools"
364 @echo "--------------------------------------------------------------"
365 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
368 @echo "--------------------------------------------------------------"
369 @echo ">>> stage 4.1: building includes"
370 @echo "--------------------------------------------------------------"
371 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
374 @echo "--------------------------------------------------------------"
375 @echo ">>> stage 4.2: building libraries"
376 @echo "--------------------------------------------------------------"
377 ${_+_}cd ${.CURDIR}; \
378 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
379 -DNO_NLS -DNO_PROFILE libraries
382 @echo "--------------------------------------------------------------"
383 @echo ">>> stage 4.3: make dependencies"
384 @echo "--------------------------------------------------------------"
385 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
388 @echo "--------------------------------------------------------------"
389 @echo ">>> stage 4.4: building everything"
390 @echo "--------------------------------------------------------------"
391 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
392 .if ${TARGET_ARCH} == "amd64"
395 @echo "--------------------------------------------------------------"
396 @echo ">>> stage 5.1: building 32 bit shim libraries"
397 @echo "--------------------------------------------------------------"
399 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
400 usr/libexec usr/sbin usr/share/misc \
401 usr/share/snmp/defs usr/share/snmp/mibs
402 mkdir -p ${LIB32TMP}/${_dir}
404 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
405 -p ${LIB32TMP}/usr/include >/dev/null
407 ln -sf ${.CURDIR}/sys ${WORLDTMP}
408 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
409 .for _t in obj depend all
410 cd ${.CURDIR}/kerberos5/tools; \
411 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
414 .for _t in obj includes
415 cd ${.CURDIR}/include; \
416 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
418 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419 cd ${.CURDIR}/gnu/lib; \
420 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
421 .if !defined(NO_CRYPT)
422 cd ${.CURDIR}/secure/lib; \
423 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
425 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
426 cd ${.CURDIR}/kerberos5/lib; \
427 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
430 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
431 cd ${.CURDIR}/${_dir}; \
432 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
434 .for _dir in lib/libncurses lib/libmagic
435 cd ${.CURDIR}/${_dir}; \
436 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
439 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
440 .for _t in obj depend all
441 cd ${.CURDIR}/libexec/rtld-elf; \
442 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
445 distribute32 install32:
446 .if make(distribute32)
447 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
449 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
451 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
452 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
453 .if !defined(NO_CRYPT)
454 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
456 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
461 .if !defined(SUBDIR_OVERRIDE)
462 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
464 WMAKE_TGTS+= _cleanobj _obj _build-tools
465 .if !defined(SUBDIR_OVERRIDE)
466 WMAKE_TGTS+= _cross-tools
468 WMAKE_TGTS+= _includes _libraries _depend everything
469 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
473 buildworld: ${WMAKE_TGTS}
474 .ORDER: ${WMAKE_TGTS}
477 @echo Entering world for ${TARGET_ARCH}:${TARGET}
478 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
480 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
481 toolchain: ${TOOLCHAIN_TGTS}
482 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
487 # Checks to be sure system is ready for installworld/installkernel.
492 # Require DESTDIR to be set if installing for a different architecture.
494 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
495 .if !make(distributeworld)
496 installcheck: installcheck_DESTDIR
497 installcheck_DESTDIR:
498 .if !defined(DESTDIR) || empty(DESTDIR)
499 @echo "ERROR: Please set DESTDIR!"; \
506 # Check for missing UIDs/GIDs.
510 .if !defined(NO_SENDMAIL)
516 CHECK_GIDS+= proxy authpf
518 installcheck: installcheck_UGID
520 .for uid in ${CHECK_UIDS}
521 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
522 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
526 .for gid in ${CHECK_GIDS}
527 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
528 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
536 # Distributes everything compiled by a `buildworld'.
540 # Installs everything compiled by a 'buildworld'.
542 distributeworld installworld: installcheck
543 mkdir -p ${INSTALLTMP}
544 for prog in [ awk cap_mkdb cat chflags chmod chown \
545 date echo egrep find grep install-info \
546 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
547 test true uname wc zic; do \
548 cp `which $$prog` ${INSTALLTMP}; \
550 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
556 # If you have a build server, you can NFS mount the source and obj directories
557 # and do a 'make reinstall' on the *client* to install new binaries from the
558 # most recent server build.
561 @echo "--------------------------------------------------------------"
562 @echo ">>> Making hierarchy"
563 @echo "--------------------------------------------------------------"
564 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
566 @echo "--------------------------------------------------------------"
567 @echo ">>> Installing everything"
568 @echo "--------------------------------------------------------------"
569 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
570 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
571 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
575 @echo "--------------------------------------------------------------"
576 @echo ">>> Distributing everything"
577 @echo "--------------------------------------------------------------"
578 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
579 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
580 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
583 distrib-dirs distribution:
584 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
587 # buildkernel and installkernel
589 # Which kernels to build and/or install is specified by setting
590 # KERNCONF. If not defined a GENERIC kernel is built/installed.
591 # Only the existing (depending TARGET) config files are used
592 # for building kernels and only the first of these is designated
593 # as the one being installed.
595 # Note that we have to use TARGET instead of TARGET_ARCH when
596 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
597 # be set to cross-build, we have to make sure TARGET is set
600 .if !defined(KERNCONF) && defined(KERNEL)
606 INSTKERNNAME?= kernel
608 KERNSRCDIR?= ${.CURDIR}/sys
609 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
610 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
611 KERNCONFDIR?= ${KRNLCONFDIR}
615 .for _kernel in ${KERNCONF}
616 .if exists(${KERNCONFDIR}/${_kernel})
617 BUILDKERNELS+= ${_kernel}
618 .if empty(INSTALLKERNEL)
619 INSTALLKERNEL= ${_kernel}
627 # Builds all kernels defined by BUILDKERNELS.
630 .if empty(BUILDKERNELS)
631 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
634 .if defined(KERNWARN)
635 @echo "--------------------------------------------------------------"
636 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
637 @echo "--------------------------------------------------------------"
641 .for _kernel in ${BUILDKERNELS}
642 @echo "--------------------------------------------------------------"
643 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
644 @echo "--------------------------------------------------------------"
645 @echo "===> ${_kernel}"
646 mkdir -p ${KRNLOBJDIR}
647 .if !defined(NO_KERNELCONFIG)
649 @echo "--------------------------------------------------------------"
650 @echo ">>> stage 1: configuring the kernel"
651 @echo "--------------------------------------------------------------"
654 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
655 ${KERNCONFDIR}/${_kernel}
657 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
659 @echo "--------------------------------------------------------------"
660 @echo ">>> stage 2.1: cleaning up the object tree"
661 @echo "--------------------------------------------------------------"
662 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
665 @echo "--------------------------------------------------------------"
666 @echo ">>> stage 2.2: rebuilding the object tree"
667 @echo "--------------------------------------------------------------"
668 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
670 @echo "--------------------------------------------------------------"
671 @echo ">>> stage 2.3: build tools"
672 @echo "--------------------------------------------------------------"
673 cd ${KRNLOBJDIR}/${_kernel}; \
674 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
675 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
676 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
677 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
678 .for target in obj depend all
679 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
680 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
681 ${MAKE} -DNO_CPU_CFLAGS ${target}
684 .if !defined(NO_KERNELDEPEND)
686 @echo "--------------------------------------------------------------"
687 @echo ">>> stage 3.1: making dependencies"
688 @echo "--------------------------------------------------------------"
689 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
692 @echo "--------------------------------------------------------------"
693 @echo ">>> stage 3.2: building everything"
694 @echo "--------------------------------------------------------------"
695 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
696 @echo "--------------------------------------------------------------"
697 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
698 @echo "--------------------------------------------------------------"
702 # installkernel, etc.
704 # Install the kernel defined by INSTALLKERNEL
706 installkernel installkernel.debug \
707 reinstallkernel reinstallkernel.debug: installcheck
708 .if empty(INSTALLKERNEL)
709 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
712 @echo "--------------------------------------------------------------"
713 @echo ">>> Installing kernel"
714 @echo "--------------------------------------------------------------"
715 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
716 ${CROSSENV} PATH=${TMPPATH} \
717 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
722 # Update the source tree, by running cvsup and/or running cvs to update to the
726 .if defined(SUP_UPDATE)
727 @echo "--------------------------------------------------------------"
728 @echo ">>> Running ${SUP}"
729 @echo "--------------------------------------------------------------"
731 @${SUP} ${SUPFLAGS} ${SUPFILE}
733 .if defined(SUPFILE1)
734 @${SUP} ${SUPFLAGS} ${SUPFILE1}
736 .if defined(SUPFILE2)
737 @${SUP} ${SUPFLAGS} ${SUPFILE2}
739 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
740 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
742 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
743 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
746 .if defined(CVS_UPDATE)
747 @echo "--------------------------------------------------------------"
748 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
749 @echo "--------------------------------------------------------------"
750 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
754 # ------------------------------------------------------------------------
756 # From here onwards are utility targets used by the 'make world' and
757 # related targets. If your 'world' breaks, you may like to try to fix
758 # the problem and manually run the following targets to attempt to
759 # complete the build. Beware, this is *not* guaranteed to work, you
760 # need to have a pretty good grip on the current state of the system
761 # to attempt to manually finish it. If in doubt, 'make world' again.
765 # legacy: Build compatibility shims for the next three targets
768 .if ${BOOTSTRAPPING} < 503000
769 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
772 .for _tool in tools/build
773 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
774 cd ${.CURDIR}/${_tool}; \
775 ${MAKE} DIRPRFX=${_tool}/ obj; \
776 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
777 ${MAKE} DIRPRFX=${_tool}/ depend; \
778 ${MAKE} DIRPRFX=${_tool}/ all; \
779 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
783 # bootstrap-tools: Build tools needed for compatibility
785 .if !defined(NO_GAMES)
786 _strfile= games/fortune/strfile
790 _gperf= gnu/usr.bin/gperf
791 .if ${BOOTSTRAPPING} < 700004
792 _groff= gnu/usr.bin/groff
794 _groff= gnu/usr.bin/groff/tmac
798 .if ${BOOTSTRAPPING} < 600029
799 _texinfo= gnu/usr.bin/texinfo
802 .if ${BOOTSTRAPPING} < 600015
803 _cap_mkdb= usr.bin/cap_mkdb
806 .if ${BOOTSTRAPPING} < 600018
807 _colldef= usr.bin/colldef
810 .if ${BOOTSTRAPPING} < 600017
811 _gencat= usr.bin/gencat
814 .if ${BOOTSTRAPPING} < 600016
815 _mklocale= usr.bin/mklocale
818 .if !defined(NO_RESCUE) && \
819 ${BOOTSTRAPPING} < 600008
820 _crunchgen= usr.sbin/crunch/crunchgen
823 .if ${BOOTSTRAPPING} < 600020
824 _pwd_mkdb= usr.sbin/pwd_mkdb
844 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
845 cd ${.CURDIR}/${_tool}; \
846 ${MAKE} DIRPRFX=${_tool}/ obj; \
847 ${MAKE} DIRPRFX=${_tool}/ depend; \
848 ${MAKE} DIRPRFX=${_tool}/ all; \
849 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
853 # build-tools: Build special purpose build tools
855 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
856 _aicasm= sys/modules/aic7xxx/aicasm
859 .if !defined(NO_SHARE)
860 _share= share/syscons/scrnmaps
863 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
864 _kerberos5_tools= kerberos5/tools
867 .if !defined(NO_RESCUE)
868 _rescue= rescue/rescue
882 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
883 cd ${.CURDIR}/${_tool}; \
884 ${MAKE} DIRPRFX=${_tool}/ obj; \
885 ${MAKE} DIRPRFX=${_tool}/ build-tools
888 gnu/usr.bin/cc/cc_tools \
890 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
891 cd ${.CURDIR}/${_tool}; \
892 ${MAKE} DIRPRFX=${_tool}/ obj; \
893 ${MAKE} DIRPRFX=${_tool}/ depend; \
894 ${MAKE} DIRPRFX=${_tool}/ all
898 # cross-tools: Build cross-building tools
900 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
901 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
902 _btxld= usr.sbin/btxld
904 .if !defined(NO_RESCUE) || defined(RELEASEDIR)
905 _crunchide= usr.sbin/crunch/crunchide
907 .if ${TARGET_ARCH} == "alpha"
908 _elf2exe= usr.sbin/elf2exe
910 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
911 _kgzip= usr.sbin/kgzip
917 gnu/usr.bin/binutils \
919 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
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} install
933 # hierarchy - ensure that all the needed directories are present
936 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
939 # libraries - build all libraries, and install them under ${DESTDIR}.
941 # The list of libraries with dependents (${_prebuild_libs}) and their
942 # interdependencies (__L) are built automatically by the
943 # ${.CURDIR}/tools/make_libdeps.sh script.
947 ${MAKE} -f Makefile.inc1 _startup_libs; \
948 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
949 ${MAKE} -f Makefile.inc1 _generic_libs;
951 # These dependencies are not automatically generated:
953 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
954 # shared libraries for ELF.
956 _startup_libs= gnu/lib/csu gnu/lib/libgcc
957 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
958 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
960 _startup_libs+= lib/csu/${MACHINE_ARCH}
965 _generic_libs= gnu/lib
967 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
968 _prebuild_libs+= kerberos5/lib/libasn1
969 _prebuild_libs+= kerberos5/lib/libkrb5
970 _prebuild_libs+= kerberos5/lib/libroken
971 _generic_libs+= kerberos5/lib
974 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
975 lib/libipx lib/libkiconv lib/libkvm lib/libmd \
976 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
978 lib/libsbuf lib/libtacplus lib/libutil \
979 lib/libz lib/msun lib/libgssapi
981 lib/libopie__L lib/libtacplus__L: lib/libmd__L
985 .if !defined(NO_CRYPT)
986 .if !defined(NO_OPENSSL)
987 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
988 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
989 .if !defined(NO_OPENSSH)
990 _prebuild_libs+= secure/lib/libssh
991 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
992 .if !defined(NO_KERBEROS)
993 secure/lib/libssh__L: lib/libgssapi__L
997 _generic_libs+= secure/lib
1000 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1001 lib/libradius__L: lib/libmd__L
1004 .if !defined(NO_NIS)
1005 _prebuild_libs+= lib/libypclnt
1008 _generic_libs+= usr.bin/lex/lib
1010 .if ${MACHINE_ARCH} == "i386"
1011 _generic_libs+= usr.sbin/pcvt/keycap
1014 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1016 .if exists(${.CURDIR}/${_lib})
1017 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1018 cd ${.CURDIR}/${_lib}; \
1019 ${MAKE} DIRPRFX=${_lib}/ depend; \
1020 ${MAKE} DIRPRFX=${_lib}/ all; \
1021 ${MAKE} DIRPRFX=${_lib}/ install
1025 # libpam is special: we need to build static PAM modules before
1026 # static PAM library, and dynamic PAM library before dynamic PAM
1028 lib/libpam__L: .PHONY
1029 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1030 cd ${.CURDIR}/lib/libpam; \
1031 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1032 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1033 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1035 _startup_libs: ${_startup_libs:S/$/__L/}
1036 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1037 _generic_libs: ${_generic_libs:S/$/__L/}
1039 .for __target in all clean cleandepend cleandir depend includes obj
1040 .for entry in ${SUBDIR}
1041 ${entry}.${__target}__D: .PHONY
1042 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1043 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1044 edir=${entry}.${MACHINE_ARCH}; \
1045 cd ${.CURDIR}/$${edir}; \
1047 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1049 cd ${.CURDIR}/$${edir}; \
1051 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1053 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1056 .include <bsd.subdir.mk>
1058 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1061 # check for / delete old files section
1064 .include "ObsoleteFiles.inc"
1066 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1067 else you can not start such an application. Consult UPDATING for more \
1068 information regarding how to cope with the removal/revision bump of a \
1071 .if !defined(BATCH_DELETE_OLD_FILES)
1078 @echo ">>> Removing old files (only deletes safe to delete libs)"
1079 .for file in ${OLD_FILES}
1080 # Ask for every old file if the user really wants to remove it.
1081 # It's annoying, but better safe than sorry.
1082 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1083 || ([ -f "${DESTDIR}/${file}" ] \
1084 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1085 && chflags noschg "${DESTDIR}/${file}" \
1086 && rm ${RM_I} "${DESTDIR}/${file}"))
1088 # Remove catpages without corresponding manpages.
1090 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1091 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1092 while read catpage; do \
1094 if [ ! -e "$${manpage}" ]; then \
1095 rm ${RM_I} $${catpage} <&3 ; \
1098 @echo ">>> Old files removed"
1101 @echo ">>> Checking for old files"
1102 .for file in ${OLD_FILES}
1103 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1105 # Check for catpages without corresponding manpages.
1106 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1107 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1108 while read catpage; do \
1110 if [ ! -e "$${manpage}" ]; then \
1111 echo $${catpage} ; \
1116 @echo ">>> Removing old libraries"
1117 @echo "${OLD_LIBS_MESSAGE}" | fmt
1118 .for file in ${OLD_LIBS}
1119 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1120 || ([ -f "${DESTDIR}/${file}" ] \
1121 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1122 && chflags noschg "${DESTDIR}/${file}" \
1123 && rm ${RM_I} "${DESTDIR}/${file}"))
1125 @echo ">>> Old libraries removed"
1128 @echo ">>> Checking for old libraries"
1129 .for file in ${OLD_LIBS}
1130 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1134 @echo ">>> Removing old directories"
1135 .for dir in ${OLD_DIRS}
1136 # Don't fail if an old directory isn't empty.
1137 @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1139 @echo ">>> Old directories removed"
1142 @echo ">>> Checking for old directories"
1143 .for dir in ${OLD_DIRS}
1144 @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1147 delete-old: delete-old-files delete-old-dirs
1148 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1150 check-old: check-old-files check-old-libs check-old-dirs
1151 @echo "To remove old files and directories run '${MAKE} delete-old'."
1152 @echo "To remove old libraries run '${MAKE} delete-old-libs'."