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="machine" to crossbuild world for a different machine type
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?= -r RELENG_6 -P -d -I!
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
107 # Guess machine architecture from machine type, and vice versa.
108 .if !defined(TARGET_ARCH) && defined(TARGET)
109 TARGET_ARCH= ${TARGET:S/pc98/i386/}
110 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
111 ${TARGET_ARCH} != ${MACHINE_ARCH}
112 TARGET= ${TARGET_ARCH}
114 # Otherwise, default to current machine type and architecture.
116 TARGET_ARCH?= ${MACHINE_ARCH}
118 KNOWN_ARCHES?= alpha amd64 arm i386 i386/pc98 ia64 powerpc sparc64
119 .if ${TARGET} == ${TARGET_ARCH}
122 _t= ${TARGET_ARCH}/${TARGET}
125 .if empty(KNOWN_ARCHES:M${_t})
126 .error Unknown target ${TARGET_ARCH}:${TARGET}.
130 .if ${TARGET} == ${MACHINE}
131 TARGET_CPUTYPE?=${CPUTYPE}
136 .if !empty(TARGET_CPUTYPE)
137 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
139 _TARGET_CPUTYPE=dummy
141 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
142 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
143 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
144 .error CPUTYPE global should be set with ?=.
147 BUILD_ARCH!= uname -p
148 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
149 .error To cross-build, set TARGET_ARCH.
152 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
153 OBJTREE= ${MAKEOBJDIRPREFIX}
155 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
157 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
158 # /usr/games added for fortune which depend on strfile
159 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
160 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
161 STRICTTMPPATH= ${BPATH}:${XPATH}
162 TMPPATH= ${STRICTTMPPATH}:${PATH}
164 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
167 # Building a world goes through the following stages
169 # 1. legacy stage [BMAKE]
170 # This stage is responsible for creating compatibility
171 # shims that are needed by the bootstrap-tools,
172 # build-tools and cross-tools stages.
173 # 1. bootstrap-tools stage [BMAKE]
174 # This stage is responsible for creating programs that
175 # are needed for backward compatibility reasons. They
176 # are not built as cross-tools.
177 # 2. build-tools stage [TMAKE]
178 # This stage is responsible for creating the object
179 # tree and building any tools that are needed during
181 # 3. cross-tools stage [XMAKE]
182 # This stage is responsible for creating any tools that
183 # are needed for cross-builds. A cross-compiler is one
185 # 4. world stage [WMAKE]
186 # This stage actually builds the world.
187 # 5. install stage (optional) [IMAKE]
188 # This stage installs a previously built world.
193 # Common environment for world related stages
194 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
195 MACHINE_ARCH=${TARGET_ARCH} \
197 CPUTYPE=${TARGET_CPUTYPE} \
198 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
199 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
200 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
202 # bootstrap-tools stage
203 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
204 PATH=${BPATH}:${PATH} \
205 WORLDTMP=${WORLDTMP} \
206 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
207 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
208 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
210 BOOTSTRAPPING=${OSRELDATE} \
211 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
212 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
215 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
216 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
217 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
219 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
222 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
223 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
224 -DNO_FORTRAN -DNO_GDB
227 WMAKEENV= ${CROSSENV} \
228 _SHLIBDIRPREFIX=${WORLDTMP} \
229 INSTALL="sh ${.CURDIR}/tools/install.sh" \
231 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
233 .if ${TARGET_ARCH} == "amd64"
235 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
237 .if empty(TARGET_CPUTYPE)
240 LIB32CPUTYPE= ${TARGET_CPUTYPE}
242 LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
243 -iprefix ${LIB32TMP}/usr/ \
244 -L${LIB32TMP}/usr/lib32 \
245 -B${LIB32TMP}/usr/lib32
247 # Yes, the flags are redundant.
248 LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
249 _SHLIBDIRPREFIX=${LIB32TMP} \
252 INSTALL="sh ${.CURDIR}/tools/install.sh" \
254 CC="${CC} ${LIB32FLAGS}" \
255 CXX="${CXX} ${LIB32FLAGS}" \
256 OBJC="${OBJC} ${LIB32FLAGS}" \
257 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
262 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
263 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML \
265 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
269 .if empty(.MAKEFLAGS:M-n)
270 IMAKEENV= ${CROSSENV} \
271 PATH=${STRICTTMPPATH}:${INSTALLTMP}
273 IMAKEENV= ${CROSSENV} \
274 PATH=${TMPPATH}:${INSTALLTMP}
276 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
279 KMAKEENV= ${WMAKEENV}
284 # Attempt to rebuild the entire system, with reasonable chance of
285 # success, regardless of how old your existing system is.
288 .if ${.CURDIR:C/[^,]//g} != ""
289 # The m4 build of sendmail files doesn't like it if ',' is used
290 # anywhere in the path of it's files.
292 @echo "*** Error: path to source tree contains a comma ','"
297 @echo "--------------------------------------------------------------"
298 @echo ">>> Rebuilding the temporary build tree"
299 @echo "--------------------------------------------------------------"
300 .if !defined(NO_CLEAN)
302 .if ${TARGET_ARCH} == "amd64"
306 rm -rf ${WORLDTMP}/legacy/usr/include
307 # XXX - These two can depend on any header file.
308 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
309 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
312 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
313 usr/libexec usr/sbin usr/share/dict \
314 usr/share/groff_font/devX100 \
315 usr/share/groff_font/devX100-12 \
316 usr/share/groff_font/devX75 \
317 usr/share/groff_font/devX75-12 \
318 usr/share/groff_font/devascii \
319 usr/share/groff_font/devcp1047 \
320 usr/share/groff_font/devdvi \
321 usr/share/groff_font/devhtml \
322 usr/share/groff_font/devkoi8-r \
323 usr/share/groff_font/devlatin1 \
324 usr/share/groff_font/devlbp \
325 usr/share/groff_font/devlj4 \
326 usr/share/groff_font/devps \
327 usr/share/groff_font/devutf8 \
328 usr/share/tmac/mdoc usr/share/tmac/mm
329 mkdir -p ${WORLDTMP}/legacy/${_dir}
332 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
333 usr/libexec usr/sbin usr/share/misc \
334 usr/share/snmp/defs usr/share/snmp/mibs
335 mkdir -p ${WORLDTMP}/${_dir}
337 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
338 -p ${WORLDTMP}/usr/include >/dev/null
339 ln -sf ${.CURDIR}/sys ${WORLDTMP}
340 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
341 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
342 -p ${WORLDTMP}/usr/include >/dev/null
346 @echo "--------------------------------------------------------------"
347 @echo ">>> stage 1.1: legacy release compatibility shims"
348 @echo "--------------------------------------------------------------"
349 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
352 @echo "--------------------------------------------------------------"
353 @echo ">>> stage 1.2: bootstrap tools"
354 @echo "--------------------------------------------------------------"
355 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
357 .if !defined(NO_CLEAN)
359 @echo "--------------------------------------------------------------"
360 @echo ">>> stage 2.1: cleaning up the object tree"
361 @echo "--------------------------------------------------------------"
362 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
363 .if ${TARGET_ARCH} == "amd64"
364 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 2.2: rebuilding the object tree"
371 @echo "--------------------------------------------------------------"
372 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
375 @echo "--------------------------------------------------------------"
376 @echo ">>> stage 2.3: build tools"
377 @echo "--------------------------------------------------------------"
378 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
381 @echo "--------------------------------------------------------------"
382 @echo ">>> stage 3: cross tools"
383 @echo "--------------------------------------------------------------"
384 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
387 @echo "--------------------------------------------------------------"
388 @echo ">>> stage 4.1: building includes"
389 @echo "--------------------------------------------------------------"
390 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 4.2: building libraries"
395 @echo "--------------------------------------------------------------"
396 ${_+_}cd ${.CURDIR}; \
397 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
398 -DNO_NLS -DNO_PROFILE libraries
401 @echo "--------------------------------------------------------------"
402 @echo ">>> stage 4.3: make dependencies"
403 @echo "--------------------------------------------------------------"
404 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
407 @echo "--------------------------------------------------------------"
408 @echo ">>> stage 4.4: building everything"
409 @echo "--------------------------------------------------------------"
410 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
411 .if ${TARGET_ARCH} == "amd64"
414 @echo "--------------------------------------------------------------"
415 @echo ">>> stage 5.1: building 32 bit shim libraries"
416 @echo "--------------------------------------------------------------"
418 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
419 usr/libexec usr/sbin usr/share/misc \
420 usr/share/snmp/defs usr/share/snmp/mibs
421 mkdir -p ${LIB32TMP}/${_dir}
423 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
424 -p ${LIB32TMP}/usr/include >/dev/null
426 ln -sf ${.CURDIR}/sys ${WORLDTMP}
427 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
428 .for _t in obj depend all
429 cd ${.CURDIR}/kerberos5/tools; \
430 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
433 .for _t in obj includes
434 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
435 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
436 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
437 .if !defined(NO_CRYPT)
438 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
440 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
441 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
444 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
445 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
447 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
448 cd ${.CURDIR}/${_dir}; \
449 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
452 ${LIB32WMAKE} -f Makefile.inc1 libraries
453 .for _t in obj depend all
454 cd ${.CURDIR}/libexec/rtld-elf; \
455 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
458 distribute32 install32:
459 .if make(distribute32)
460 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
462 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
464 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
465 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
466 .if !defined(NO_CRYPT)
467 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
469 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
474 .if !defined(SUBDIR_OVERRIDE)
475 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
477 WMAKE_TGTS+= _cleanobj _obj _build-tools
478 .if !defined(SUBDIR_OVERRIDE)
479 WMAKE_TGTS+= _cross-tools
481 WMAKE_TGTS+= _includes _libraries _depend everything
482 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
486 buildworld: ${WMAKE_TGTS}
487 .ORDER: ${WMAKE_TGTS}
490 @echo Entering world for ${TARGET_ARCH}:${TARGET}
491 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
493 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
494 toolchain: ${TOOLCHAIN_TGTS}
495 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
498 # Use this to add checks to installworld/installkernel targets.
500 SPECIAL_INSTALLCHECKS=
503 # Require DESTDIR to be set if installing for a different architecture.
505 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
506 .if !make(distributeworld)
507 SPECIAL_INSTALLCHECKS+= installcheck_DESTDIR
508 installcheck_DESTDIR:
509 .if !defined(DESTDIR) || empty(DESTDIR)
510 @echo "ERROR: Please set DESTDIR!"; \
519 # Checks to be sure system is ready for installworld
523 .if !defined(NO_SENDMAIL)
529 CHECK_GIDS+= proxy authpf
531 installcheck: ${SPECIAL_INSTALLCHECKS}
532 .for uid in ${CHECK_UIDS}
533 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
534 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
538 .for gid in ${CHECK_GIDS}
539 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
540 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
548 # Distributes everything compiled by a `buildworld'.
552 # Installs everything compiled by a 'buildworld'.
554 distributeworld installworld: installcheck
555 mkdir -p ${INSTALLTMP}
556 for prog in [ awk cap_mkdb cat chflags chmod chown \
557 date echo egrep find grep install-info \
558 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
559 test true uname wc zic; do \
560 cp `which $$prog` ${INSTALLTMP}; \
562 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
568 # If you have a build server, you can NFS mount the source and obj directories
569 # and do a 'make reinstall' on the *client* to install new binaries from the
570 # most recent server build.
572 reinstall: ${SPECIAL_INSTALLCHECKS}
573 @echo "--------------------------------------------------------------"
574 @echo ">>> Making hierarchy"
575 @echo "--------------------------------------------------------------"
576 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
578 @echo "--------------------------------------------------------------"
579 @echo ">>> Installing everything"
580 @echo "--------------------------------------------------------------"
581 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
582 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
583 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
587 @echo "--------------------------------------------------------------"
588 @echo ">>> Distributing everything"
589 @echo "--------------------------------------------------------------"
590 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
591 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
592 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
595 distrib-dirs distribution:
596 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
599 # buildkernel and installkernel
601 # Which kernels to build and/or install is specified by setting
602 # KERNCONF. If not defined a GENERIC kernel is built/installed.
603 # Only the existing (depending TARGET) config files are used
604 # for building kernels and only the first of these is designated
605 # as the one being installed.
607 # Note that we have to use TARGET instead of TARGET_ARCH when
608 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
609 # be set to cross-build, we have to make sure TARGET is set
612 .if !defined(KERNCONF) && defined(KERNEL)
618 INSTKERNNAME?= kernel
620 KERNSRCDIR?= ${.CURDIR}/sys
621 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
622 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
623 KERNCONFDIR?= ${KRNLCONFDIR}
627 .for _kernel in ${KERNCONF}
628 .if exists(${KERNCONFDIR}/${_kernel})
629 BUILDKERNELS+= ${_kernel}
630 .if empty(INSTALLKERNEL)
631 INSTALLKERNEL= ${_kernel}
639 # Builds all kernels defined by BUILDKERNELS.
642 .if empty(BUILDKERNELS)
643 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
646 .if defined(KERNWARN)
647 @echo "--------------------------------------------------------------"
648 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
649 @echo "--------------------------------------------------------------"
653 .for _kernel in ${BUILDKERNELS}
654 @echo "--------------------------------------------------------------"
655 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
656 @echo "--------------------------------------------------------------"
657 @echo "===> ${_kernel}"
658 mkdir -p ${KRNLOBJDIR}
659 .if !defined(NO_KERNELCONFIG)
661 @echo "--------------------------------------------------------------"
662 @echo ">>> stage 1: configuring the kernel"
663 @echo "--------------------------------------------------------------"
666 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
667 ${KERNCONFDIR}/${_kernel}
669 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
671 @echo "--------------------------------------------------------------"
672 @echo ">>> stage 2.1: cleaning up the object tree"
673 @echo "--------------------------------------------------------------"
674 cd ${KRNLOBJDIR}/${_kernel}; \
675 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
678 @echo "--------------------------------------------------------------"
679 @echo ">>> stage 2.2: rebuilding the object tree"
680 @echo "--------------------------------------------------------------"
681 cd ${KRNLOBJDIR}/${_kernel}; \
682 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
684 @echo "--------------------------------------------------------------"
685 @echo ">>> stage 2.3: build tools"
686 @echo "--------------------------------------------------------------"
687 cd ${KRNLOBJDIR}/${_kernel}; \
688 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
689 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
690 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
691 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
692 .for target in obj depend all
693 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
694 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
695 ${MAKE} -DNO_CPU_CFLAGS ${target}
698 .if !defined(NO_KERNELDEPEND)
700 @echo "--------------------------------------------------------------"
701 @echo ">>> stage 3.1: making dependencies"
702 @echo "--------------------------------------------------------------"
703 cd ${KRNLOBJDIR}/${_kernel}; \
704 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
707 @echo "--------------------------------------------------------------"
708 @echo ">>> stage 3.2: building everything"
709 @echo "--------------------------------------------------------------"
710 cd ${KRNLOBJDIR}/${_kernel}; \
711 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
712 @echo "--------------------------------------------------------------"
713 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
714 @echo "--------------------------------------------------------------"
718 # installkernel, etc.
720 # Install the kernel defined by INSTALLKERNEL
722 installkernel installkernel.debug \
723 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
724 .if empty(INSTALLKERNEL)
725 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
728 @echo "--------------------------------------------------------------"
729 @echo ">>> Installing kernel"
730 @echo "--------------------------------------------------------------"
731 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
732 ${CROSSENV} PATH=${TMPPATH} \
733 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
738 # Update the source tree, by running cvsup and/or running cvs to update to the
742 .if defined(SUP_UPDATE)
743 @echo "--------------------------------------------------------------"
744 @echo ">>> Running ${SUP}"
745 @echo "--------------------------------------------------------------"
747 @${SUP} ${SUPFLAGS} ${SUPFILE}
749 .if defined(SUPFILE1)
750 @${SUP} ${SUPFLAGS} ${SUPFILE1}
752 .if defined(SUPFILE2)
753 @${SUP} ${SUPFLAGS} ${SUPFILE2}
755 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
756 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
758 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
759 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
762 .if defined(CVS_UPDATE)
763 @echo "--------------------------------------------------------------"
764 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
765 @echo "--------------------------------------------------------------"
766 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
770 # ------------------------------------------------------------------------
772 # From here onwards are utility targets used by the 'make world' and
773 # related targets. If your 'world' breaks, you may like to try to fix
774 # the problem and manually run the following targets to attempt to
775 # complete the build. Beware, this is *not* guaranteed to work, you
776 # need to have a pretty good grip on the current state of the system
777 # to attempt to manually finish it. If in doubt, 'make world' again.
781 # legacy: Build compatibility shims for the next three targets
784 .if ${BOOTSTRAPPING} < 503000
785 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
788 .for _tool in tools/build
789 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
790 cd ${.CURDIR}/${_tool}; \
791 ${MAKE} DIRPRFX=${_tool}/ obj; \
792 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
793 ${MAKE} DIRPRFX=${_tool}/ depend; \
794 ${MAKE} DIRPRFX=${_tool}/ all; \
795 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
799 # bootstrap-tools: Build tools needed for compatibility
801 .if !defined(NO_GAMES)
802 _strfile= games/fortune/strfile
806 _gperf= gnu/usr.bin/gperf
807 .if ${BOOTSTRAPPING} < 600101
808 _groff= gnu/usr.bin/groff
810 _groff= gnu/usr.bin/groff/tmac
814 .if ${BOOTSTRAPPING} < 600029
815 _texinfo= gnu/usr.bin/texinfo
818 .if ${BOOTSTRAPPING} < 600015
819 _cap_mkdb= usr.bin/cap_mkdb
822 .if ${BOOTSTRAPPING} < 600018
823 _colldef= usr.bin/colldef
826 .if ${BOOTSTRAPPING} < 600017
827 _gencat= usr.bin/gencat
830 .if ${BOOTSTRAPPING} < 600016
831 _mklocale= usr.bin/mklocale
834 .if ${BOOTSTRAPPING} < 602106
835 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
838 .if !defined(NO_RESCUE) && \
839 ${BOOTSTRAPPING} < 600008
840 _crunchgen= usr.sbin/crunch/crunchgen
843 .if ${BOOTSTRAPPING} < 600020
844 _pwd_mkdb= usr.sbin/pwd_mkdb
865 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
866 cd ${.CURDIR}/${_tool}; \
867 ${MAKE} DIRPRFX=${_tool}/ obj; \
868 ${MAKE} DIRPRFX=${_tool}/ depend; \
869 ${MAKE} DIRPRFX=${_tool}/ all; \
870 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
874 # build-tools: Build special purpose build tools
876 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
877 _aicasm= sys/modules/aic7xxx/aicasm
880 .if !defined(NO_SHARE)
881 _share= share/syscons/scrnmaps
884 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
885 _kerberos5_tools= kerberos5/tools
888 .if !defined(NO_RESCUE)
889 _rescue= rescue/rescue
897 lib/ncurses/ncurses \
898 lib/ncurses/ncursesw \
904 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
905 cd ${.CURDIR}/${_tool}; \
906 ${MAKE} DIRPRFX=${_tool}/ obj; \
907 ${MAKE} DIRPRFX=${_tool}/ build-tools
910 gnu/usr.bin/cc/cc_tools \
912 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
913 cd ${.CURDIR}/${_tool}; \
914 ${MAKE} DIRPRFX=${_tool}/ obj; \
915 ${MAKE} DIRPRFX=${_tool}/ depend; \
916 ${MAKE} DIRPRFX=${_tool}/ all
920 # cross-tools: Build cross-building tools
922 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
923 ${TARGET_ARCH} != ${MACHINE_ARCH}
924 _btxld= usr.sbin/btxld
927 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
928 ${TARGET_ARCH} != ${MACHINE_ARCH}
929 _crunchide= usr.sbin/crunch/crunchide
932 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
933 _elf2exe= usr.sbin/elf2exe
936 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
938 _kgzip= usr.sbin/kgzip
943 gnu/usr.bin/binutils \
945 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
950 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
951 cd ${.CURDIR}/${_tool}; \
952 ${MAKE} DIRPRFX=${_tool}/ obj; \
953 ${MAKE} DIRPRFX=${_tool}/ depend; \
954 ${MAKE} DIRPRFX=${_tool}/ all; \
955 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
959 # hierarchy - ensure that all the needed directories are present
962 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
965 # libraries - build all libraries, and install them under ${DESTDIR}.
967 # The list of libraries with dependents (${_prebuild_libs}) and their
968 # interdependencies (__L) are built automatically by the
969 # ${.CURDIR}/tools/make_libdeps.sh script.
973 ${MAKE} -f Makefile.inc1 _startup_libs; \
974 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
975 ${MAKE} -f Makefile.inc1 _generic_libs;
977 # These dependencies are not automatically generated:
979 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
980 # shared libraries for ELF.
982 _startup_libs= gnu/lib/csu gnu/lib/libgcc
983 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
984 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
986 _startup_libs+= lib/csu/${MACHINE_ARCH}
991 _generic_libs= gnu/lib
993 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
994 _prebuild_libs+= kerberos5/lib/libasn1
995 _prebuild_libs+= kerberos5/lib/libgssapi
996 _prebuild_libs+= kerberos5/lib/libkrb5
997 _prebuild_libs+= kerberos5/lib/libroken
998 _generic_libs+= kerberos5/lib
1001 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1002 lib/libkvm lib/libmd \
1003 lib/ncurses/ncurses lib/ncurses/ncursesw \
1004 lib/libnetgraph lib/libopie lib/libpam \
1006 lib/libsbuf lib/libtacplus lib/libutil \
1009 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1013 .if !defined(NO_CRYPT)
1014 .if !defined(NO_OPENSSL)
1015 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
1016 lib/libradius__L: secure/lib/libssl__L
1017 secure/lib/libssl__L: secure/lib/libcrypto__L
1018 .if !defined(NO_OPENSSH)
1019 _prebuild_libs+= secure/lib/libssh
1020 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L \
1022 .if !defined(NO_KERBEROS)
1023 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1024 kerberos5/lib/libasn1__L lib/libcom_err__L \
1025 kerberos5/lib/libroken__L
1029 _generic_libs+= secure/lib
1032 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1033 lib/libradius__L: lib/libmd__L
1036 .if !defined(NO_NIS)
1037 _prebuild_libs+= lib/libypclnt
1040 _generic_libs+= usr.bin/lex/lib
1042 .if ${MACHINE} == "i386"
1043 _generic_libs+= usr.sbin/pcvt/keycap
1046 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1048 .if exists(${.CURDIR}/${_lib})
1049 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1050 cd ${.CURDIR}/${_lib}; \
1051 ${MAKE} DIRPRFX=${_lib}/ obj; \
1052 ${MAKE} DIRPRFX=${_lib}/ depend; \
1053 ${MAKE} DIRPRFX=${_lib}/ all; \
1054 ${MAKE} DIRPRFX=${_lib}/ install
1058 # libpam is special: we need to build static PAM modules before
1059 # static PAM library, and dynamic PAM library before dynamic PAM
1061 lib/libpam__L: .PHONY
1062 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1063 cd ${.CURDIR}/lib/libpam; \
1064 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1065 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1066 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1067 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1069 _startup_libs: ${_startup_libs:S/$/__L/}
1070 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1071 _generic_libs: ${_generic_libs:S/$/__L/}
1073 .for __target in all clean cleandepend cleandir depend includes obj
1074 .for entry in ${SUBDIR}
1075 ${entry}.${__target}__D: .PHONY
1076 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1077 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1078 edir=${entry}.${MACHINE_ARCH}; \
1079 cd ${.CURDIR}/$${edir}; \
1081 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1083 cd ${.CURDIR}/$${edir}; \
1085 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1087 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1090 .include <bsd.subdir.mk>
1092 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1095 # check for / delete old files section
1098 .include "ObsoleteFiles.inc"
1100 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1101 else you can not start such an application. Consult UPDATING for more \
1102 information regarding how to cope with the removal/revision bump of a \
1105 .if !defined(BATCH_DELETE_OLD_FILES)
1112 @echo ">>> Removing old files (only deletes safe to delete libs)"
1113 .for file in ${OLD_FILES}
1114 # Ask for every old file if the user really wants to remove it.
1115 # It's annoying, but better safe than sorry.
1116 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1117 || ([ -f "${DESTDIR}/${file}" ] \
1118 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1119 && chflags noschg "${DESTDIR}/${file}" \
1120 && rm ${RM_I} "${DESTDIR}/${file}"))
1122 # Remove catpages without corresponding manpages.
1124 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1125 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1126 while read catpage; do \
1128 if [ ! -e "$${manpage}" ]; then \
1129 rm ${RM_I} $${catpage} <&3 ; \
1132 @echo ">>> Old files removed"
1135 @echo ">>> Checking for old files"
1136 .for file in ${OLD_FILES}
1137 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1139 # Check for catpages without corresponding manpages.
1140 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1141 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1142 while read catpage; do \
1144 if [ ! -e "$${manpage}" ]; then \
1145 echo $${catpage} ; \
1150 @echo ">>> Removing old libraries"
1151 @echo "${OLD_LIBS_MESSAGE}" | fmt
1152 .for file in ${OLD_LIBS}
1153 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1154 || ([ -f "${DESTDIR}/${file}" ] \
1155 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1156 && chflags noschg "${DESTDIR}/${file}" \
1157 && rm ${RM_I} "${DESTDIR}/${file}"))
1159 @echo ">>> Old libraries removed"
1162 @echo ">>> Checking for old libraries"
1163 .for file in ${OLD_LIBS}
1164 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1168 @echo ">>> Removing old directories"
1169 .for dir in ${OLD_DIRS}
1170 # Don't fail if an old directory isn't empty.
1171 @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1173 @echo ">>> Old directories removed"
1176 @echo ">>> Checking for old directories"
1177 .for dir in ${OLD_DIRS}
1178 @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1181 delete-old: delete-old-files delete-old-dirs
1182 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1184 check-old: check-old-files check-old-libs check-old-dirs
1185 @echo "To remove old files and directories run '${MAKE} delete-old'."
1186 @echo "To remove old libraries run '${MAKE} delete-old-libs'."