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!= sysctl -n hw.machine_arch
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 LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
238 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
239 -L${LIB32TMP}/usr/lib32 \
240 -B${LIB32TMP}/usr/lib32
241 LIB32CC= ${LIB32PREFLAGS} \
243 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
245 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
248 # Yes, the flags are redundant.
249 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
250 _SHLIBDIRPREFIX=${LIB32TMP} \
253 INSTALL="sh ${.CURDIR}/tools/install.sh" \
255 CC="${CC} ${LIB32CC}" \
256 CXX="${CXX} ${LIB32CXX}" \
257 OBJC="${OBJC} ${LIB32OBJC}" \
258 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
263 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
264 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
265 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -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 rm -rf ${OBJTREE}/lib32
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; \
435 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
437 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
438 cd ${.CURDIR}/gnu/lib; \
439 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
440 .if !defined(NO_CRYPT)
441 cd ${.CURDIR}/secure/lib; \
442 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
444 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
445 cd ${.CURDIR}/kerberos5/lib; \
446 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
449 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
450 cd ${.CURDIR}/${_dir}; \
451 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
453 .for _dir in lib/libncurses lib/libmagic
454 cd ${.CURDIR}/${_dir}; \
455 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
458 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
459 .for _t in obj depend all
460 cd ${.CURDIR}/libexec/rtld-elf; \
461 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
464 distribute32 install32:
465 .if make(distribute32)
466 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
468 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
470 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
471 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
472 .if !defined(NO_CRYPT)
473 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
475 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
480 .if !defined(SUBDIR_OVERRIDE)
481 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
483 WMAKE_TGTS+= _cleanobj _obj _build-tools
484 .if !defined(SUBDIR_OVERRIDE)
485 WMAKE_TGTS+= _cross-tools
487 WMAKE_TGTS+= _includes _libraries _depend everything
488 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
492 buildworld: ${WMAKE_TGTS}
493 .ORDER: ${WMAKE_TGTS}
496 @echo Entering world for ${TARGET_ARCH}:${TARGET}
497 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
499 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
500 toolchain: ${TOOLCHAIN_TGTS}
501 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
504 # Use this to add checks to installworld/installkernel targets.
506 SPECIAL_INSTALLCHECKS=
509 # Require DESTDIR to be set if installing for a different architecture.
511 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
512 .if !make(distributeworld)
513 SPECIAL_INSTALLCHECKS+= installcheck_DESTDIR
514 installcheck_DESTDIR:
515 .if !defined(DESTDIR) || empty(DESTDIR)
516 @echo "ERROR: Please set DESTDIR!"; \
525 # Checks to be sure system is ready for installworld
529 .if !defined(NO_SENDMAIL)
535 CHECK_GIDS+= proxy authpf
537 installcheck: ${SPECIAL_INSTALLCHECKS}
538 .for uid in ${CHECK_UIDS}
539 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
540 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
544 .for gid in ${CHECK_GIDS}
545 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
546 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
554 # Distributes everything compiled by a `buildworld'.
558 # Installs everything compiled by a 'buildworld'.
560 distributeworld installworld: installcheck
561 mkdir -p ${INSTALLTMP}
562 for prog in [ awk cap_mkdb cat chflags chmod chown \
563 date echo egrep find grep install-info \
564 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
565 test true uname wc zic; do \
566 cp `which $$prog` ${INSTALLTMP}; \
568 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
574 # If you have a build server, you can NFS mount the source and obj directories
575 # and do a 'make reinstall' on the *client* to install new binaries from the
576 # most recent server build.
578 reinstall: ${SPECIAL_INSTALLCHECKS}
579 @echo "--------------------------------------------------------------"
580 @echo ">>> Making hierarchy"
581 @echo "--------------------------------------------------------------"
582 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
584 @echo "--------------------------------------------------------------"
585 @echo ">>> Installing everything"
586 @echo "--------------------------------------------------------------"
587 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
588 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
589 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
593 @echo "--------------------------------------------------------------"
594 @echo ">>> Distributing everything"
595 @echo "--------------------------------------------------------------"
596 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
597 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
598 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
601 distrib-dirs distribution:
602 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
605 # buildkernel and installkernel
607 # Which kernels to build and/or install is specified by setting
608 # KERNCONF. If not defined a GENERIC kernel is built/installed.
609 # Only the existing (depending TARGET) config files are used
610 # for building kernels and only the first of these is designated
611 # as the one being installed.
613 # Note that we have to use TARGET instead of TARGET_ARCH when
614 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
615 # be set to cross-build, we have to make sure TARGET is set
618 .if !defined(KERNCONF) && defined(KERNEL)
624 INSTKERNNAME?= kernel
626 KERNSRCDIR?= ${.CURDIR}/sys
627 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
628 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
629 KERNCONFDIR?= ${KRNLCONFDIR}
633 .for _kernel in ${KERNCONF}
634 .if exists(${KERNCONFDIR}/${_kernel})
635 BUILDKERNELS+= ${_kernel}
636 .if empty(INSTALLKERNEL)
637 INSTALLKERNEL= ${_kernel}
645 # Builds all kernels defined by BUILDKERNELS.
648 .if empty(BUILDKERNELS)
649 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
652 .if defined(KERNWARN)
653 @echo "--------------------------------------------------------------"
654 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
655 @echo "--------------------------------------------------------------"
659 .for _kernel in ${BUILDKERNELS}
660 @echo "--------------------------------------------------------------"
661 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
662 @echo "--------------------------------------------------------------"
663 @echo "===> ${_kernel}"
664 mkdir -p ${KRNLOBJDIR}
665 .if !defined(NO_KERNELCONFIG)
667 @echo "--------------------------------------------------------------"
668 @echo ">>> stage 1: configuring the kernel"
669 @echo "--------------------------------------------------------------"
672 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
673 ${KERNCONFDIR}/${_kernel}
675 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
677 @echo "--------------------------------------------------------------"
678 @echo ">>> stage 2.1: cleaning up the object tree"
679 @echo "--------------------------------------------------------------"
680 cd ${KRNLOBJDIR}/${_kernel}; \
681 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
684 @echo "--------------------------------------------------------------"
685 @echo ">>> stage 2.2: rebuilding the object tree"
686 @echo "--------------------------------------------------------------"
687 cd ${KRNLOBJDIR}/${_kernel}; \
688 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
690 @echo "--------------------------------------------------------------"
691 @echo ">>> stage 2.3: build tools"
692 @echo "--------------------------------------------------------------"
693 cd ${KRNLOBJDIR}/${_kernel}; \
694 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
695 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
696 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
697 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
698 .for target in obj depend all
699 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
700 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
701 ${MAKE} -DNO_CPU_CFLAGS ${target}
704 .if !defined(NO_KERNELDEPEND)
706 @echo "--------------------------------------------------------------"
707 @echo ">>> stage 3.1: making dependencies"
708 @echo "--------------------------------------------------------------"
709 cd ${KRNLOBJDIR}/${_kernel}; \
710 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
713 @echo "--------------------------------------------------------------"
714 @echo ">>> stage 3.2: building everything"
715 @echo "--------------------------------------------------------------"
716 cd ${KRNLOBJDIR}/${_kernel}; \
717 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
718 @echo "--------------------------------------------------------------"
719 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
720 @echo "--------------------------------------------------------------"
724 # installkernel, etc.
726 # Install the kernel defined by INSTALLKERNEL
728 installkernel installkernel.debug \
729 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
730 .if empty(INSTALLKERNEL)
731 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
734 @echo "--------------------------------------------------------------"
735 @echo ">>> Installing kernel"
736 @echo "--------------------------------------------------------------"
737 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
738 ${CROSSENV} PATH=${TMPPATH} \
739 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
744 # Update the source tree, by running cvsup and/or running cvs to update to the
748 .if defined(SUP_UPDATE)
749 @echo "--------------------------------------------------------------"
750 @echo ">>> Running ${SUP}"
751 @echo "--------------------------------------------------------------"
753 @${SUP} ${SUPFLAGS} ${SUPFILE}
755 .if defined(SUPFILE1)
756 @${SUP} ${SUPFLAGS} ${SUPFILE1}
758 .if defined(SUPFILE2)
759 @${SUP} ${SUPFLAGS} ${SUPFILE2}
761 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
762 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
764 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
765 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
768 .if defined(CVS_UPDATE)
769 @echo "--------------------------------------------------------------"
770 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
771 @echo "--------------------------------------------------------------"
772 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
776 # ------------------------------------------------------------------------
778 # From here onwards are utility targets used by the 'make world' and
779 # related targets. If your 'world' breaks, you may like to try to fix
780 # the problem and manually run the following targets to attempt to
781 # complete the build. Beware, this is *not* guaranteed to work, you
782 # need to have a pretty good grip on the current state of the system
783 # to attempt to manually finish it. If in doubt, 'make world' again.
787 # legacy: Build compatibility shims for the next three targets
790 .if ${BOOTSTRAPPING} < 503000
791 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
794 .for _tool in tools/build
795 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
796 cd ${.CURDIR}/${_tool}; \
797 ${MAKE} DIRPRFX=${_tool}/ obj; \
798 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
799 ${MAKE} DIRPRFX=${_tool}/ depend; \
800 ${MAKE} DIRPRFX=${_tool}/ all; \
801 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
805 # bootstrap-tools: Build tools needed for compatibility
807 .if !defined(NO_GAMES)
808 _strfile= games/fortune/strfile
812 _gperf= gnu/usr.bin/gperf
813 .if ${BOOTSTRAPPING} < 600101
814 _groff= gnu/usr.bin/groff
816 _groff= gnu/usr.bin/groff/tmac
820 .if ${BOOTSTRAPPING} < 600029
821 _texinfo= gnu/usr.bin/texinfo
824 .if ${BOOTSTRAPPING} < 600015
825 _cap_mkdb= usr.bin/cap_mkdb
828 .if ${BOOTSTRAPPING} < 600018
829 _colldef= usr.bin/colldef
832 .if ${BOOTSTRAPPING} < 600017
833 _gencat= usr.bin/gencat
836 .if ${BOOTSTRAPPING} < 600016
837 _mklocale= usr.bin/mklocale
840 .if ${BOOTSTRAPPING} < 600106
841 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
844 .if !defined(NO_RESCUE) && \
845 ${BOOTSTRAPPING} < 600008
846 _crunchgen= usr.sbin/crunch/crunchgen
849 .if ${BOOTSTRAPPING} < 600020
850 _pwd_mkdb= usr.sbin/pwd_mkdb
871 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
872 cd ${.CURDIR}/${_tool}; \
873 ${MAKE} DIRPRFX=${_tool}/ obj; \
874 ${MAKE} DIRPRFX=${_tool}/ depend; \
875 ${MAKE} DIRPRFX=${_tool}/ all; \
876 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
880 # build-tools: Build special purpose build tools
882 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
883 _aicasm= sys/modules/aic7xxx/aicasm
886 .if !defined(NO_SHARE)
887 _share= share/syscons/scrnmaps
890 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
891 _kerberos5_tools= kerberos5/tools
894 .if !defined(NO_RESCUE)
895 _rescue= rescue/rescue
909 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
910 cd ${.CURDIR}/${_tool}; \
911 ${MAKE} DIRPRFX=${_tool}/ obj; \
912 ${MAKE} DIRPRFX=${_tool}/ build-tools
915 gnu/usr.bin/cc/cc_tools \
917 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
918 cd ${.CURDIR}/${_tool}; \
919 ${MAKE} DIRPRFX=${_tool}/ obj; \
920 ${MAKE} DIRPRFX=${_tool}/ depend; \
921 ${MAKE} DIRPRFX=${_tool}/ all
925 # cross-tools: Build cross-building tools
927 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
928 ${TARGET_ARCH} != ${MACHINE_ARCH}
929 _btxld= usr.sbin/btxld
932 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
933 ${TARGET_ARCH} != ${MACHINE_ARCH}
934 _crunchide= usr.sbin/crunch/crunchide
937 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
938 _elf2exe= usr.sbin/elf2exe
941 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
943 _kgzip= usr.sbin/kgzip
948 gnu/usr.bin/binutils \
950 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
955 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
956 cd ${.CURDIR}/${_tool}; \
957 ${MAKE} DIRPRFX=${_tool}/ obj; \
958 ${MAKE} DIRPRFX=${_tool}/ depend; \
959 ${MAKE} DIRPRFX=${_tool}/ all; \
960 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
964 # hierarchy - ensure that all the needed directories are present
967 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
970 # libraries - build all libraries, and install them under ${DESTDIR}.
972 # The list of libraries with dependents (${_prebuild_libs}) and their
973 # interdependencies (__L) are built automatically by the
974 # ${.CURDIR}/tools/make_libdeps.sh script.
978 ${MAKE} -f Makefile.inc1 _startup_libs; \
979 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
980 ${MAKE} -f Makefile.inc1 _generic_libs;
982 # These dependencies are not automatically generated:
984 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
985 # shared libraries for ELF.
987 _startup_libs= gnu/lib/csu gnu/lib/libgcc
988 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
989 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
991 _startup_libs+= lib/csu/${MACHINE_ARCH}
996 _generic_libs= gnu/lib
998 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
999 _prebuild_libs+= kerberos5/lib/libasn1
1000 _prebuild_libs+= kerberos5/lib/libgssapi
1001 _prebuild_libs+= kerberos5/lib/libkrb5
1002 _prebuild_libs+= kerberos5/lib/libroken
1003 _generic_libs+= kerberos5/lib
1006 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1007 lib/libkvm lib/libmd \
1008 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1010 lib/libsbuf lib/libtacplus lib/libutil \
1013 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1017 .if !defined(NO_CRYPT)
1018 .if !defined(NO_OPENSSL)
1019 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
1020 lib/libradius__L: secure/lib/libssl__L
1021 secure/lib/libssl__L: secure/lib/libcrypto__L
1022 .if !defined(NO_OPENSSH)
1023 _prebuild_libs+= secure/lib/libssh
1024 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L \
1026 .if !defined(NO_KERBEROS)
1027 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1028 kerberos5/lib/libasn1__L lib/libcom_err__L \
1029 kerberos5/lib/libroken__L
1033 _generic_libs+= secure/lib
1036 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1037 lib/libradius__L: lib/libmd__L
1040 .if !defined(NO_NIS)
1041 _prebuild_libs+= lib/libypclnt
1044 _generic_libs+= usr.bin/lex/lib
1046 .if ${MACHINE} == "i386"
1047 _generic_libs+= usr.sbin/pcvt/keycap
1050 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1052 .if exists(${.CURDIR}/${_lib})
1053 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1054 cd ${.CURDIR}/${_lib}; \
1055 ${MAKE} DIRPRFX=${_lib}/ depend; \
1056 ${MAKE} DIRPRFX=${_lib}/ all; \
1057 ${MAKE} DIRPRFX=${_lib}/ install
1061 # libpam is special: we need to build static PAM modules before
1062 # static PAM library, and dynamic PAM library before dynamic PAM
1064 lib/libpam__L: .PHONY
1065 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1066 cd ${.CURDIR}/lib/libpam; \
1067 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1068 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1069 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1071 _startup_libs: ${_startup_libs:S/$/__L/}
1072 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1073 _generic_libs: ${_generic_libs:S/$/__L/}
1075 .for __target in all clean cleandepend cleandir depend includes obj
1076 .for entry in ${SUBDIR}
1077 ${entry}.${__target}__D: .PHONY
1078 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1079 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1080 edir=${entry}.${MACHINE_ARCH}; \
1081 cd ${.CURDIR}/$${edir}; \
1083 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1085 cd ${.CURDIR}/$${edir}; \
1087 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1089 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1092 .include <bsd.subdir.mk>
1094 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1097 # check for / delete old files section
1100 .include "ObsoleteFiles.inc"
1102 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1103 else you can not start such an application. Consult UPDATING for more \
1104 information regarding how to cope with the removal/revision bump of a \
1107 .if !defined(BATCH_DELETE_OLD_FILES)
1114 @echo ">>> Removing old files (only deletes safe to delete libs)"
1115 .for file in ${OLD_FILES}
1116 # Ask for every old file if the user really wants to remove it.
1117 # It's annoying, but better safe than sorry.
1118 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1119 || ([ -f "${DESTDIR}/${file}" ] \
1120 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1121 && chflags noschg "${DESTDIR}/${file}" \
1122 && rm ${RM_I} "${DESTDIR}/${file}"))
1124 # Remove catpages without corresponding manpages.
1126 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1127 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1128 while read catpage; do \
1130 if [ ! -e "$${manpage}" ]; then \
1131 rm ${RM_I} $${catpage} <&3 ; \
1134 @echo ">>> Old files removed"
1137 @echo ">>> Checking for old files"
1138 .for file in ${OLD_FILES}
1139 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1141 # Check for catpages without corresponding manpages.
1142 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1143 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1144 while read catpage; do \
1146 if [ ! -e "$${manpage}" ]; then \
1147 echo $${catpage} ; \
1152 @echo ">>> Removing old libraries"
1153 @echo "${OLD_LIBS_MESSAGE}" | fmt
1154 .for file in ${OLD_LIBS}
1155 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1156 || ([ -f "${DESTDIR}/${file}" ] \
1157 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1158 && chflags noschg "${DESTDIR}/${file}" \
1159 && rm ${RM_I} "${DESTDIR}/${file}"))
1161 @echo ">>> Old libraries removed"
1164 @echo ">>> Checking for old libraries"
1165 .for file in ${OLD_LIBS}
1166 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1170 @echo ">>> Removing old directories"
1171 .for dir in ${OLD_DIRS}
1172 # Don't fail if an old directory isn't empty.
1173 @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1175 @echo ">>> Old directories removed"
1178 @echo ">>> Checking for old directories"
1179 .for dir in ${OLD_DIRS}
1180 @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1183 delete-old: delete-old-files delete-old-dirs
1184 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1186 check-old: check-old-files check-old-libs check-old-dirs
1187 @echo "To remove old files and directories run '${MAKE} delete-old'."
1188 @echo "To remove old libraries run '${MAKE} delete-old-libs'."