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!= sysctl -n hw.machine_arch
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 LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
213 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
214 -L${LIB32TMP}/usr/lib32 \
215 -B${LIB32TMP}/usr/lib32
216 LIB32CC= ${LIB32PREFLAGS} \
218 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
220 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
223 # Yes, the flags are redundant.
224 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
225 _SHLIBDIRPREFIX=${LIB32TMP} \
228 INSTALL="sh ${.CURDIR}/tools/install.sh" \
230 CC="${CC} ${LIB32CC}" \
231 CXX="${CXX} ${LIB32CXX}" \
232 OBJC="${OBJC} ${LIB32OBJC}" \
233 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
238 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
239 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
240 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -DNO_INCS
244 .if empty(.MAKEFLAGS:M-n)
245 IMAKEENV= ${CROSSENV} \
246 PATH=${STRICTTMPPATH}:${INSTALLTMP}
248 IMAKEENV= ${CROSSENV} \
249 PATH=${TMPPATH}:${INSTALLTMP}
251 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
254 KMAKEENV= ${WMAKEENV}
255 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
260 # Attempt to rebuild the entire system, with reasonable chance of
261 # success, regardless of how old your existing system is.
264 .if ${.CURDIR:C/[^,]//g} != ""
265 # The m4 build of sendmail files doesn't like it if ',' is used
266 # anywhere in the path of it's files.
268 @echo "*** Error: path to source tree contains a comma ','"
273 @echo "--------------------------------------------------------------"
274 @echo ">>> Rebuilding the temporary build tree"
275 @echo "--------------------------------------------------------------"
276 .if !defined(NO_CLEAN)
278 .if ${TARGET_ARCH} == "amd64"
282 rm -rf ${WORLDTMP}/legacy/usr/include
283 # XXX - These two can depend on any header file.
284 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
285 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
288 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
289 usr/libexec usr/sbin usr/share/dict \
290 usr/share/groff_font/devX100 \
291 usr/share/groff_font/devX100-12 \
292 usr/share/groff_font/devX75 \
293 usr/share/groff_font/devX75-12 \
294 usr/share/groff_font/devascii \
295 usr/share/groff_font/devcp1047 \
296 usr/share/groff_font/devdvi \
297 usr/share/groff_font/devhtml \
298 usr/share/groff_font/devkoi8-r \
299 usr/share/groff_font/devlatin1 \
300 usr/share/groff_font/devlbp \
301 usr/share/groff_font/devlj4 \
302 usr/share/groff_font/devps \
303 usr/share/groff_font/devutf8 \
304 usr/share/tmac/mdoc usr/share/tmac/mm
305 mkdir -p ${WORLDTMP}/legacy/${_dir}
308 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
309 usr/libexec usr/sbin usr/share/misc \
310 usr/share/snmp/defs usr/share/snmp/mibs
311 mkdir -p ${WORLDTMP}/${_dir}
313 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
314 -p ${WORLDTMP}/usr/include >/dev/null
315 ln -sf ${.CURDIR}/sys ${WORLDTMP}
316 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
317 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
318 -p ${WORLDTMP}/usr/include >/dev/null
322 @echo "--------------------------------------------------------------"
323 @echo ">>> stage 1.1: legacy release compatibility shims"
324 @echo "--------------------------------------------------------------"
325 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
328 @echo "--------------------------------------------------------------"
329 @echo ">>> stage 1.2: bootstrap tools"
330 @echo "--------------------------------------------------------------"
331 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
333 .if !defined(NO_CLEAN)
335 @echo "--------------------------------------------------------------"
336 @echo ">>> stage 2.1: cleaning up the object tree"
337 @echo "--------------------------------------------------------------"
338 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
339 .if ${TARGET_ARCH} == "amd64"
340 rm -rf ${OBJTREE}/lib32
345 @echo "--------------------------------------------------------------"
346 @echo ">>> stage 2.2: rebuilding the object tree"
347 @echo "--------------------------------------------------------------"
348 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
351 @echo "--------------------------------------------------------------"
352 @echo ">>> stage 2.3: build tools"
353 @echo "--------------------------------------------------------------"
354 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
357 @echo "--------------------------------------------------------------"
358 @echo ">>> stage 3: cross tools"
359 @echo "--------------------------------------------------------------"
360 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
363 @echo "--------------------------------------------------------------"
364 @echo ">>> stage 4.1: building includes"
365 @echo "--------------------------------------------------------------"
366 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 4.2: building libraries"
371 @echo "--------------------------------------------------------------"
372 ${_+_}cd ${.CURDIR}; \
373 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
374 -DNO_NLS -DNO_PROFILE libraries
377 @echo "--------------------------------------------------------------"
378 @echo ">>> stage 4.3: make dependencies"
379 @echo "--------------------------------------------------------------"
380 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
383 @echo "--------------------------------------------------------------"
384 @echo ">>> stage 4.4: building everything"
385 @echo "--------------------------------------------------------------"
386 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
387 .if ${TARGET_ARCH} == "amd64"
390 @echo "--------------------------------------------------------------"
391 @echo ">>> stage 5.1: building 32 bit shim libraries"
392 @echo "--------------------------------------------------------------"
394 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
395 usr/libexec usr/sbin usr/share/misc \
396 usr/share/snmp/defs usr/share/snmp/mibs
397 mkdir -p ${LIB32TMP}/${_dir}
399 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
400 -p ${LIB32TMP}/usr/include >/dev/null
402 ln -sf ${.CURDIR}/sys ${WORLDTMP}
403 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
404 .for _t in obj depend all
405 cd ${.CURDIR}/kerberos5/tools; \
406 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
409 .for _t in obj includes
410 cd ${.CURDIR}/include; \
411 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
413 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
414 cd ${.CURDIR}/gnu/lib; \
415 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416 .if !defined(NO_CRYPT)
417 cd ${.CURDIR}/secure/lib; \
418 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
420 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
421 cd ${.CURDIR}/kerberos5/lib; \
422 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
425 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
426 cd ${.CURDIR}/${_dir}; \
427 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
429 .for _dir in lib/libncurses lib/libmagic
430 cd ${.CURDIR}/${_dir}; \
431 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
434 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
435 .for _t in obj depend all
436 cd ${.CURDIR}/libexec/rtld-elf; \
437 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
440 distribute32 install32:
441 .if make(distribute32)
442 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
444 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
446 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
447 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
448 .if !defined(NO_CRYPT)
449 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
451 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
456 .if !defined(SUBDIR_OVERRIDE)
457 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
459 WMAKE_TGTS+= _cleanobj _obj _build-tools
460 .if !defined(SUBDIR_OVERRIDE)
461 WMAKE_TGTS+= _cross-tools
463 WMAKE_TGTS+= _includes _libraries _depend everything
464 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
468 buildworld: ${WMAKE_TGTS}
469 .ORDER: ${WMAKE_TGTS}
472 @echo Entering world for ${TARGET_ARCH}:${TARGET}
473 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
475 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
476 toolchain: ${TOOLCHAIN_TGTS}
477 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
482 # Checks to be sure system is ready for installworld/installkernel.
487 # Require DESTDIR to be set if installing for a different architecture.
489 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
490 .if !make(distributeworld)
491 installcheck: installcheck_DESTDIR
492 installcheck_DESTDIR:
493 .if !defined(DESTDIR) || empty(DESTDIR)
494 @echo "ERROR: Please set DESTDIR!"; \
501 # Check for missing UIDs/GIDs.
505 .if !defined(NO_SENDMAIL)
511 CHECK_GIDS+= proxy authpf
513 installcheck: installcheck_UGID
515 .for uid in ${CHECK_UIDS}
516 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
517 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
521 .for gid in ${CHECK_GIDS}
522 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
523 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
531 # Distributes everything compiled by a `buildworld'.
535 # Installs everything compiled by a 'buildworld'.
537 distributeworld installworld: installcheck
538 mkdir -p ${INSTALLTMP}
539 for prog in [ awk cap_mkdb cat chflags chmod chown \
540 date echo egrep find grep install-info \
541 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
542 test true uname wc zic; do \
543 cp `which $$prog` ${INSTALLTMP}; \
545 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
551 # If you have a build server, you can NFS mount the source and obj directories
552 # and do a 'make reinstall' on the *client* to install new binaries from the
553 # most recent server build.
556 @echo "--------------------------------------------------------------"
557 @echo ">>> Making hierarchy"
558 @echo "--------------------------------------------------------------"
559 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
561 @echo "--------------------------------------------------------------"
562 @echo ">>> Installing everything"
563 @echo "--------------------------------------------------------------"
564 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
565 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
566 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
570 @echo "--------------------------------------------------------------"
571 @echo ">>> Distributing everything"
572 @echo "--------------------------------------------------------------"
573 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
574 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
575 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
578 distrib-dirs distribution:
579 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
582 # buildkernel and installkernel
584 # Which kernels to build and/or install is specified by setting
585 # KERNCONF. If not defined a GENERIC kernel is built/installed.
586 # Only the existing (depending TARGET) config files are used
587 # for building kernels and only the first of these is designated
588 # as the one being installed.
590 # Note that we have to use TARGET instead of TARGET_ARCH when
591 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
592 # be set to cross-build, we have to make sure TARGET is set
595 .if !defined(KERNCONF) && defined(KERNEL)
601 INSTKERNNAME?= kernel
603 KERNSRCDIR?= ${.CURDIR}/sys
604 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
605 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
606 KERNCONFDIR?= ${KRNLCONFDIR}
610 .for _kernel in ${KERNCONF}
611 .if exists(${KERNCONFDIR}/${_kernel})
612 BUILDKERNELS+= ${_kernel}
613 .if empty(INSTALLKERNEL)
614 INSTALLKERNEL= ${_kernel}
622 # Builds all kernels defined by BUILDKERNELS.
625 .if empty(BUILDKERNELS)
626 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
629 .if defined(KERNWARN)
630 @echo "--------------------------------------------------------------"
631 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
632 @echo "--------------------------------------------------------------"
636 .for _kernel in ${BUILDKERNELS}
637 @echo "--------------------------------------------------------------"
638 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
639 @echo "--------------------------------------------------------------"
640 @echo "===> ${_kernel}"
641 mkdir -p ${KRNLOBJDIR}
642 .if !defined(NO_KERNELCONFIG)
644 @echo "--------------------------------------------------------------"
645 @echo ">>> stage 1: configuring the kernel"
646 @echo "--------------------------------------------------------------"
649 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
650 ${KERNCONFDIR}/${_kernel}
652 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
654 @echo "--------------------------------------------------------------"
655 @echo ">>> stage 2.1: cleaning up the object tree"
656 @echo "--------------------------------------------------------------"
657 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
660 @echo "--------------------------------------------------------------"
661 @echo ">>> stage 2.2: rebuilding the object tree"
662 @echo "--------------------------------------------------------------"
663 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
665 @echo "--------------------------------------------------------------"
666 @echo ">>> stage 2.3: build tools"
667 @echo "--------------------------------------------------------------"
668 cd ${KRNLOBJDIR}/${_kernel}; \
669 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
670 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
671 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
672 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
673 .for target in obj depend all
674 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
675 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
676 ${MAKE} -DNO_CPU_CFLAGS ${target}
679 .if !defined(NO_KERNELDEPEND)
681 @echo "--------------------------------------------------------------"
682 @echo ">>> stage 3.1: making dependencies"
683 @echo "--------------------------------------------------------------"
684 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
687 @echo "--------------------------------------------------------------"
688 @echo ">>> stage 3.2: building everything"
689 @echo "--------------------------------------------------------------"
690 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
691 @echo "--------------------------------------------------------------"
692 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
693 @echo "--------------------------------------------------------------"
697 # installkernel, etc.
699 # Install the kernel defined by INSTALLKERNEL
701 installkernel installkernel.debug \
702 reinstallkernel reinstallkernel.debug: installcheck
703 .if empty(INSTALLKERNEL)
704 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
707 @echo "--------------------------------------------------------------"
708 @echo ">>> Installing kernel"
709 @echo "--------------------------------------------------------------"
710 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
711 ${CROSSENV} PATH=${TMPPATH} \
712 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
717 # Update the source tree, by running cvsup and/or running cvs to update to the
721 .if defined(SUP_UPDATE)
722 @echo "--------------------------------------------------------------"
723 @echo ">>> Running ${SUP}"
724 @echo "--------------------------------------------------------------"
726 @${SUP} ${SUPFLAGS} ${SUPFILE}
728 .if defined(SUPFILE1)
729 @${SUP} ${SUPFLAGS} ${SUPFILE1}
731 .if defined(SUPFILE2)
732 @${SUP} ${SUPFLAGS} ${SUPFILE2}
734 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
735 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
737 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
738 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
741 .if defined(CVS_UPDATE)
742 @echo "--------------------------------------------------------------"
743 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
744 @echo "--------------------------------------------------------------"
745 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
749 # ------------------------------------------------------------------------
751 # From here onwards are utility targets used by the 'make world' and
752 # related targets. If your 'world' breaks, you may like to try to fix
753 # the problem and manually run the following targets to attempt to
754 # complete the build. Beware, this is *not* guaranteed to work, you
755 # need to have a pretty good grip on the current state of the system
756 # to attempt to manually finish it. If in doubt, 'make world' again.
760 # legacy: Build compatibility shims for the next three targets
763 .if ${BOOTSTRAPPING} < 503000
764 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
767 .for _tool in tools/build
768 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
769 cd ${.CURDIR}/${_tool}; \
770 ${MAKE} DIRPRFX=${_tool}/ obj; \
771 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
772 ${MAKE} DIRPRFX=${_tool}/ depend; \
773 ${MAKE} DIRPRFX=${_tool}/ all; \
774 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
778 # bootstrap-tools: Build tools needed for compatibility
780 .if !defined(NO_GAMES)
781 _strfile= games/fortune/strfile
785 _gperf= gnu/usr.bin/gperf
786 .if ${BOOTSTRAPPING} < 700004
787 _groff= gnu/usr.bin/groff
789 _groff= gnu/usr.bin/groff/tmac
793 .if ${BOOTSTRAPPING} < 600029
794 _texinfo= gnu/usr.bin/texinfo
797 .if ${BOOTSTRAPPING} < 600015
798 _cap_mkdb= usr.bin/cap_mkdb
801 .if ${BOOTSTRAPPING} < 600018
802 _colldef= usr.bin/colldef
805 .if ${BOOTSTRAPPING} < 600017
806 _gencat= usr.bin/gencat
809 .if ${BOOTSTRAPPING} < 600016
810 _mklocale= usr.bin/mklocale
813 .if !defined(NO_RESCUE) && \
814 ${BOOTSTRAPPING} < 600008
815 _crunchgen= usr.sbin/crunch/crunchgen
818 .if ${BOOTSTRAPPING} < 600020
819 _pwd_mkdb= usr.sbin/pwd_mkdb
839 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
840 cd ${.CURDIR}/${_tool}; \
841 ${MAKE} DIRPRFX=${_tool}/ obj; \
842 ${MAKE} DIRPRFX=${_tool}/ depend; \
843 ${MAKE} DIRPRFX=${_tool}/ all; \
844 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
848 # build-tools: Build special purpose build tools
850 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
851 _aicasm= sys/modules/aic7xxx/aicasm
854 .if !defined(NO_SHARE)
855 _share= share/syscons/scrnmaps
858 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
859 _kerberos5_tools= kerberos5/tools
862 .if !defined(NO_RESCUE)
863 _rescue= rescue/rescue
877 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
878 cd ${.CURDIR}/${_tool}; \
879 ${MAKE} DIRPRFX=${_tool}/ obj; \
880 ${MAKE} DIRPRFX=${_tool}/ build-tools
883 gnu/usr.bin/cc/cc_tools \
885 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
886 cd ${.CURDIR}/${_tool}; \
887 ${MAKE} DIRPRFX=${_tool}/ obj; \
888 ${MAKE} DIRPRFX=${_tool}/ depend; \
889 ${MAKE} DIRPRFX=${_tool}/ all
893 # cross-tools: Build cross-building tools
895 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
896 ${TARGET_ARCH} != ${MACHINE_ARCH}
897 _btxld= usr.sbin/btxld
900 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
901 ${TARGET_ARCH} != ${MACHINE_ARCH}
902 _crunchide= usr.sbin/crunch/crunchide
905 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
906 _elf2exe= usr.sbin/elf2exe
909 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
911 _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 !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
967 _prebuild_libs+= kerberos5/lib/libasn1
968 _prebuild_libs+= kerberos5/lib/libgssapi
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 \
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: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
994 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
995 kerberos5/lib/libroken__L
999 _generic_libs+= secure/lib
1002 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1003 lib/libradius__L: lib/libmd__L
1006 .if !defined(NO_NIS)
1007 _prebuild_libs+= lib/libypclnt
1010 _generic_libs+= usr.bin/lex/lib
1012 .if ${MACHINE_ARCH} == "i386"
1013 _generic_libs+= usr.sbin/pcvt/keycap
1016 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1018 .if exists(${.CURDIR}/${_lib})
1019 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1020 cd ${.CURDIR}/${_lib}; \
1021 ${MAKE} DIRPRFX=${_lib}/ depend; \
1022 ${MAKE} DIRPRFX=${_lib}/ all; \
1023 ${MAKE} DIRPRFX=${_lib}/ install
1027 # libpam is special: we need to build static PAM modules before
1028 # static PAM library, and dynamic PAM library before dynamic PAM
1030 lib/libpam__L: .PHONY
1031 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1032 cd ${.CURDIR}/lib/libpam; \
1033 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1034 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1035 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1037 _startup_libs: ${_startup_libs:S/$/__L/}
1038 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1039 _generic_libs: ${_generic_libs:S/$/__L/}
1041 .for __target in all clean cleandepend cleandir depend includes obj
1042 .for entry in ${SUBDIR}
1043 ${entry}.${__target}__D: .PHONY
1044 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1045 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1046 edir=${entry}.${MACHINE_ARCH}; \
1047 cd ${.CURDIR}/$${edir}; \
1049 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1051 cd ${.CURDIR}/$${edir}; \
1053 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1055 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1058 .include <bsd.subdir.mk>
1060 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1063 # check for / delete old files section
1066 .include "ObsoleteFiles.inc"
1068 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1069 else you can not start such an application. Consult UPDATING for more \
1070 information regarding how to cope with the removal/revision bump of a \
1073 .if !defined(BATCH_DELETE_OLD_FILES)
1080 @echo ">>> Removing old files (only deletes safe to delete libs)"
1081 .for file in ${OLD_FILES}
1082 # Ask for every old file if the user really wants to remove it.
1083 # It's annoying, but better safe than sorry.
1084 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1085 || ([ -f "${DESTDIR}/${file}" ] \
1086 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1087 && chflags noschg "${DESTDIR}/${file}" \
1088 && rm ${RM_I} "${DESTDIR}/${file}"))
1090 # Remove catpages without corresponding manpages.
1092 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1093 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1094 while read catpage; do \
1096 if [ ! -e "$${manpage}" ]; then \
1097 rm ${RM_I} $${catpage} <&3 ; \
1100 @echo ">>> Old files removed"
1103 @echo ">>> Checking for old files"
1104 .for file in ${OLD_FILES}
1105 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1107 # Check for catpages without corresponding manpages.
1108 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1109 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1110 while read catpage; do \
1112 if [ ! -e "$${manpage}" ]; then \
1113 echo $${catpage} ; \
1118 @echo ">>> Removing old libraries"
1119 @echo "${OLD_LIBS_MESSAGE}" | fmt
1120 .for file in ${OLD_LIBS}
1121 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1122 || ([ -f "${DESTDIR}/${file}" ] \
1123 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1124 && chflags noschg "${DESTDIR}/${file}" \
1125 && rm ${RM_I} "${DESTDIR}/${file}"))
1127 @echo ">>> Old libraries removed"
1130 @echo ">>> Checking for old libraries"
1131 .for file in ${OLD_LIBS}
1132 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1136 @echo ">>> Removing old directories"
1137 .for dir in ${OLD_DIRS}
1138 # Don't fail if an old directory isn't empty.
1139 @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1141 @echo ">>> Old directories removed"
1144 @echo ">>> Checking for old directories"
1145 .for dir in ${OLD_DIRS}
1146 @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1149 delete-old: delete-old-files delete-old-dirs
1150 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1152 check-old: check-old-files check-old-libs check-old-dirs
1153 @echo "To remove old files and directories run '${MAKE} delete-old'."
1154 @echo "To remove old libraries run '${MAKE} delete-old-libs'."