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 # -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9 # -DNOCLEAN do not clean at all
10 # -DNOCRYPT will prevent building of crypt versions
11 # -DNO_MAN do not build the manual pages
12 # -DNO_PROFILE do not build profiled libraries
13 # -DNOGAMES do not go into games subdir
14 # -DNOSHARE do not go into share subdir
15 # -DNO_INFO do not make or install info files
16 # -DNO_LIBC_R do not build libc_r.
17 # -DNO_FORTRAN do not build g77 and related libraries.
18 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
19 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
20 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
21 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
22 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
23 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24 # TARGET_ARCH="arch" to crossbuild world to a different arch
27 # The intended user-driven targets are:
28 # buildworld - rebuild *everything*, including glue to help do upgrades
29 # installworld- install everything built by "buildworld"
30 # update - convenient way to update your source tree (eg: cvsup/cvs)
32 # Standard targets (not defined here) are documented in the makefiles in
33 # /usr/share/mk. These include:
34 # obj depend all install clean cleandepend cleanobj
36 # We must do share/info early so that installation of info `dir'
37 # entries works correctly. Do it first since it is less likely to
38 # grow dependencies on include and lib than vice versa.
40 # We must do lib and libexec before bin, because if installworld
41 # installs a new /bin/sh, the 'make' command will *immediately*
42 # use that new version. And the new (dynamically-linked) /bin/sh
43 # will expect to find appropriate libraries in /lib and /libexec.
45 # We must do etc last for install/distribute to work.
47 SUBDIR= share/info include lib libexec bin
52 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
55 .if !defined(NO_RESCUE)
65 SUBDIR+=sys usr.bin usr.sbin etc
67 # These are last, since it is nice to at least get the base system
68 # rebuilt before you do them.
69 .for _DIR in ${LOCAL_DIRS}
70 .if exists(${.CURDIR}/${_DIR}/Makefile)
75 .if defined(SUBDIR_OVERRIDE)
76 SUBDIR= ${SUBDIR_OVERRIDE}
79 .if defined(NOCLEANDIR)
80 CLEANDIR= clean cleandepend
86 CVSFLAGS?= -A -P -d -I!
87 SUP?= /usr/local/bin/cvsup
88 SUPFLAGS?= -g -L 2 -P -
90 SUPFLAGS+= -h ${SUPHOST}
93 MAKEOBJDIRPREFIX?= /usr/obj
94 .if !defined(OSRELDATE)
95 .if exists(/usr/include/osreldate.h)
96 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
97 /usr/include/osreldate.h
102 TARGET_ARCH?= ${MACHINE_ARCH}
103 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
105 TARGET_CPUTYPE?=${CPUTYPE}
107 TARGET?= ${TARGET_ARCH}
110 .if !empty(TARGET_CPUTYPE)
111 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
113 _TARGET_CPUTYPE=dummy
115 _CPUTYPE!= MAKEFLAGS= ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
116 CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
117 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
118 .error CPUTYPE global should be set with ?=.
121 BUILD_ARCH!= sysctl -n hw.machine_arch
122 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
123 .error To cross-build, set TARGET_ARCH.
126 .if ${MACHINE} == ${TARGET}
127 OBJTREE= ${MAKEOBJDIRPREFIX}
129 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
131 WORLDTMP= ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
132 # /usr/games added for fortune which depend on strfile
133 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
134 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
135 STRICTTMPPATH= ${BPATH}:${XPATH}
136 TMPPATH= ${STRICTTMPPATH}:${PATH}
138 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
141 # Building a world goes through the following stages
143 # 1. legacy stage [BMAKE]
144 # This stage is responsible for creating compatibility
145 # shims that are needed by the bootstrap-tools,
146 # build-tools and cross-tools stages.
147 # 1. bootstrap-tools stage [BMAKE]
148 # This stage is responsible for creating programs that
149 # are needed for backward compatibility reasons. They
150 # are not built as cross-tools.
151 # 2. build-tools stage [TMAKE]
152 # This stage is responsible for creating the object
153 # tree and building any tools that are needed during
155 # 3. cross-tools stage [XMAKE]
156 # This stage is responsible for creating any tools that
157 # are needed for cross-builds. A cross-compiler is one
159 # 4. world stage [WMAKE]
160 # This stage actually builds the world.
161 # 5. install stage (optional) [IMAKE]
162 # This stage installs a previously built world.
167 # Common environment for world related stages
168 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
169 MACHINE_ARCH=${TARGET_ARCH} \
171 CPUTYPE=${TARGET_CPUTYPE} \
172 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
173 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
174 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
176 # bootstrap-tools stage
177 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
178 PATH=${BPATH}:${PATH} \
179 WORLDTMP=${WORLDTMP} \
180 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
181 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
182 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
184 BOOTSTRAPPING=${OSRELDATE} \
185 -DNOHTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PIC -DNO_PROFILE \
186 -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
189 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
190 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
192 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
195 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
198 WMAKEENV= ${CROSSENV} \
199 _SHLIBDIRPREFIX=${WORLDTMP} \
200 INSTALL="sh ${.CURDIR}/tools/install.sh" \
202 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
204 .if ${MACHINE_ARCH} == "amd64"
206 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
208 LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
209 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
210 -L${LIB32TMP}/usr/lib32 \
211 -B${LIB32TMP}/usr/lib32
212 LIB32CC= ${LIB32PREFLAGS} \
214 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
216 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
219 # Yes, the flags are redundant.
220 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
221 _SHLIBDIRPREFIX=${LIB32TMP} \
223 INSTALL="sh ${.CURDIR}/tools/install.sh" \
226 CXX="c++ ${LIB32CXX}" \
227 OBJC="cc ${LIB32OBJC}" \
228 LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
233 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
234 -DNO_BIND -DNO_MAN -DNO_INFO -DNOHTML \
236 CXX="c++ ${LIB32CXX}" \
237 OBJC="cc ${LIB32OBJC}" \
238 LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
245 .if empty(.MAKEFLAGS:M-n)
246 IMAKEENV= ${CROSSENV} \
247 PATH=${STRICTTMPPATH}:${INSTALLTMP}
249 IMAKEENV= ${CROSSENV} \
250 PATH=${TMPPATH}:${INSTALLTMP}
252 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
255 KMAKEENV= ${WMAKEENV}
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(NOCLEAN)
279 rm -rf ${WORLDTMP}/legacy/usr/include
280 # XXX - These two can depend on any header file.
281 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
282 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
285 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
286 usr/libexec usr/sbin usr/share/dict \
287 usr/share/groff_font/devX100 \
288 usr/share/groff_font/devX100-12 \
289 usr/share/groff_font/devX75 \
290 usr/share/groff_font/devX75-12 \
291 usr/share/groff_font/devascii \
292 usr/share/groff_font/devcp1047 \
293 usr/share/groff_font/devdvi \
294 usr/share/groff_font/devhtml \
295 usr/share/groff_font/devkoi8-r \
296 usr/share/groff_font/devlatin1 \
297 usr/share/groff_font/devlbp \
298 usr/share/groff_font/devlj4 \
299 usr/share/groff_font/devps \
300 usr/share/groff_font/devutf8 \
301 usr/share/tmac/mdoc usr/share/tmac/mm
302 mkdir -p ${WORLDTMP}/legacy/${_dir}
305 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
306 usr/libexec usr/sbin usr/share/misc \
307 usr/share/snmp/defs usr/share/snmp/mibs
308 mkdir -p ${WORLDTMP}/${_dir}
310 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
311 -p ${WORLDTMP}/usr/include >/dev/null
312 ln -sf ${.CURDIR}/sys ${WORLDTMP}
313 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
314 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
315 -p ${WORLDTMP}/usr/include >/dev/null
319 @echo "--------------------------------------------------------------"
320 @echo ">>> stage 1.1: legacy release compatibility shims"
321 @echo "--------------------------------------------------------------"
322 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
325 @echo "--------------------------------------------------------------"
326 @echo ">>> stage 1.2: bootstrap tools"
327 @echo "--------------------------------------------------------------"
328 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
330 .if !defined(NOCLEAN)
332 @echo "--------------------------------------------------------------"
333 @echo ">>> stage 2.1: cleaning up the object tree"
334 @echo "--------------------------------------------------------------"
335 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
339 @echo "--------------------------------------------------------------"
340 @echo ">>> stage 2.2: rebuilding the object tree"
341 @echo "--------------------------------------------------------------"
342 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
345 @echo "--------------------------------------------------------------"
346 @echo ">>> stage 2.3: build tools"
347 @echo "--------------------------------------------------------------"
348 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
351 @echo "--------------------------------------------------------------"
352 @echo ">>> stage 3: cross tools"
353 @echo "--------------------------------------------------------------"
354 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
357 @echo "--------------------------------------------------------------"
358 @echo ">>> stage 4.1: building includes"
359 @echo "--------------------------------------------------------------"
360 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
363 @echo "--------------------------------------------------------------"
364 @echo ">>> stage 4.2: building libraries"
365 @echo "--------------------------------------------------------------"
366 ${_+_}cd ${.CURDIR}; \
367 ${WMAKE} -DNO_FSCHG -DNOHTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PROFILE \
371 @echo "--------------------------------------------------------------"
372 @echo ">>> stage 4.3: make dependencies"
373 @echo "--------------------------------------------------------------"
374 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
377 @echo "--------------------------------------------------------------"
378 @echo ">>> stage 4.4: building everything"
379 @echo "--------------------------------------------------------------"
380 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
381 .if ${MACHINE_ARCH} == "amd64"
384 @echo "--------------------------------------------------------------"
385 @echo ">>> stage 5.1: building 32 bit shim libraries"
386 @echo "--------------------------------------------------------------"
388 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
389 usr/libexec usr/sbin usr/share/misc \
390 usr/share/snmp/defs usr/share/snmp/mibs
391 mkdir -p ${LIB32TMP}/${_dir}
393 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
394 -p ${LIB32TMP}/usr/include >/dev/null
395 ln -sf ${.CURDIR}/sys ${WORLDTMP}
396 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
397 .for _t in obj depend all
398 cd ${.CURDIR}/kerberos5/tools; \
399 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
402 .for _t in obj includes
403 cd ${.CURDIR}/include; \
404 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
406 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
407 cd ${.CURDIR}/gnu/lib; \
408 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
409 .if !defined(NOCRYPT)
410 cd ${.CURDIR}/secure/lib; \
411 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
413 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
414 cd ${.CURDIR}/kerberos5/lib; \
415 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
418 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
419 cd ${.CURDIR}/${_dir}; \
420 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
422 .for _dir in lib/libncurses lib/libmagic
423 cd ${.CURDIR}/${_dir}; \
424 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
427 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
428 .for _t in obj depend all
429 cd ${.CURDIR}/libexec/rtld-elf; \
430 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
434 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
435 cd ${.CURDIR}/lib; ${LIB32MAKE} install
436 cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
437 .if !defined(NOCRYPT)
438 cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
440 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
445 .if !defined(SUBDIR_OVERRIDE)
446 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
448 WMAKE_TGTS+= _cleanobj _obj _build-tools
449 .if !defined(SUBDIR_OVERRIDE)
450 WMAKE_TGTS+= _cross-tools
452 WMAKE_TGTS+= _includes _libraries _depend everything
453 .if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
457 buildworld: ${WMAKE_TGTS}
458 .ORDER: ${WMAKE_TGTS}
460 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything}
461 toolchain: ${TOOLCHAIN_TGTS}
462 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
465 # Use this to add checks to installworld/installkernel targets.
467 SPECIAL_INSTALLCHECKS=
470 # The following install-time check will see if the installation will
471 # change the type used for time_t, and if it will, the target makes
472 # sure that the user is expecting to make that change.
474 .if ${TARGET_ARCH} == "sparc64"
475 SPECIAL_INSTALLCHECKS+=sparc64_installcheck
477 CUR_TIMET!= grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
478 SRC_TIMET!= grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
480 NEWSPARC_TIMETYPE?=${CUR_TIMET}
482 sparc64_installcheck:
483 .if ${CUR_TIMET} != ${SRC_TIMET}
485 .if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
486 @echo "*** ERROR: This target would change the type used for time_t!"
488 @echo "* Note: This installation changes the type used for time_t."
491 @echo "* This host has time_t defined as ${CUR_TIMET},"
492 @echo "* and this installation would change that to type ${SRC_TIMET}."
493 .if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
495 @echo "* If that is *NOT* what you wanted, then you need to change the"
496 @echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
497 @echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'. After that you *MUST*"
498 @echo "* do a complete cleanworld, buildworld, buildkernel before you"
499 @echo "* retry the 'make' command. Also read /usr/src/UPDATING.64BTT."
501 @echo "* If that *is* what you want, then enter the commands:"
502 @echo " NEWSPARC_TIMETYPE=${SRC_TIMET}"
503 @echo " export NEWSPARC_TIMETYPE"
504 @echo "* and repeat your 'make' command."
509 .elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
511 @echo "*** ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
512 @echo "*** but ${.CURDIR}/sys/sparc64/include/_types.h"
513 @echo "*** has __time_t defined as '${SRC_TIMET}'."
516 @# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
523 # Checks to be sure system is ready for installworld
527 .if !defined(NO_SENDMAIL)
533 CHECK_GIDS+= proxy authpf
535 installcheck: ${SPECIAL_INSTALLCHECKS}
536 .for uid in ${CHECK_UIDS}
537 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
538 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
542 .for gid in ${CHECK_GIDS}
543 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
544 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
552 # Distributes everything compiled by a `buildworld'.
556 # Installs everything compiled by a 'buildworld'.
558 distributeworld installworld: installcheck
559 mkdir -p ${INSTALLTMP}
560 for prog in [ awk cap_mkdb cat chflags chmod chown \
561 date echo egrep find grep \
562 ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
563 test true uname wc zic; do \
564 cp `which $$prog` ${INSTALLTMP}; \
566 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
572 # If you have a build server, you can NFS mount the source and obj directories
573 # and do a 'make reinstall' on the *client* to install new binaries from the
574 # most recent server build.
576 reinstall: ${SPECIAL_INSTALLCHECKS}
577 @echo "--------------------------------------------------------------"
578 @echo ">>> Making hierarchy"
579 @echo "--------------------------------------------------------------"
580 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
582 @echo "--------------------------------------------------------------"
583 @echo ">>> Installing everything"
584 @echo "--------------------------------------------------------------"
585 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
586 .if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
587 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
591 @echo "--------------------------------------------------------------"
592 @echo ">>> Distributing everything"
593 @echo "--------------------------------------------------------------"
594 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
597 # buildkernel and installkernel
599 # Which kernels to build and/or install is specified by setting
600 # KERNCONF. If not defined a GENERIC kernel is built/installed.
601 # Only the existing (depending TARGET) config files are used
602 # for building kernels and only the first of these is designated
603 # as the one being installed.
605 # Note that we have to use TARGET instead of TARGET_ARCH when
606 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
607 # be set to cross-build, we have to make sure TARGET is set
610 .if !defined(KERNCONF) && defined(KERNEL)
616 INSTKERNNAME?= kernel
618 KERNSRCDIR?= ${.CURDIR}/sys
619 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
620 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
621 KERNCONFDIR?= ${KRNLCONFDIR}
625 .for _kernel in ${KERNCONF}
626 .if exists(${KERNCONFDIR}/${_kernel})
627 BUILDKERNELS+= ${_kernel}
628 .if empty(INSTALLKERNEL)
629 INSTALLKERNEL= ${_kernel}
637 # Builds all kernels defined by BUILDKERNELS.
640 .if empty(BUILDKERNELS)
641 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
644 .if defined(KERNWARN)
645 @echo "--------------------------------------------------------------"
646 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
647 @echo "--------------------------------------------------------------"
651 .for _kernel in ${BUILDKERNELS}
652 @echo "--------------------------------------------------------------"
653 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
654 @echo "--------------------------------------------------------------"
655 @echo "===> ${_kernel}"
656 mkdir -p ${KRNLOBJDIR}
657 .if !defined(NO_KERNELCONFIG)
659 @echo "--------------------------------------------------------------"
660 @echo ">>> stage 1: configuring the kernel"
661 @echo "--------------------------------------------------------------"
664 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
665 ${KERNCONFDIR}/${_kernel}
667 .if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
669 @echo "--------------------------------------------------------------"
670 @echo ">>> stage 2.1: cleaning up the object tree"
671 @echo "--------------------------------------------------------------"
672 cd ${KRNLOBJDIR}/${_kernel}; \
673 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
676 @echo "--------------------------------------------------------------"
677 @echo ">>> stage 2.2: rebuilding the object tree"
678 @echo "--------------------------------------------------------------"
679 cd ${KRNLOBJDIR}/${_kernel}; \
680 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
682 @echo "--------------------------------------------------------------"
683 @echo ">>> stage 2.3: build tools"
684 @echo "--------------------------------------------------------------"
685 cd ${KRNLOBJDIR}/${_kernel}; \
686 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
687 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
688 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
689 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
690 .for target in obj depend all
691 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
692 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
693 ${MAKE} -DNO_CPU_CFLAGS ${target}
696 .if !defined(NO_KERNELDEPEND)
698 @echo "--------------------------------------------------------------"
699 @echo ">>> stage 3.1: making dependencies"
700 @echo "--------------------------------------------------------------"
701 cd ${KRNLOBJDIR}/${_kernel}; \
702 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
705 @echo "--------------------------------------------------------------"
706 @echo ">>> stage 3.2: building everything"
707 @echo "--------------------------------------------------------------"
708 cd ${KRNLOBJDIR}/${_kernel}; \
709 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
710 @echo "--------------------------------------------------------------"
711 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
712 @echo "--------------------------------------------------------------"
716 # installkernel, etc.
718 # Install the kernel defined by INSTALLKERNEL
720 installkernel installkernel.debug \
721 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
722 .if empty(INSTALLKERNEL)
723 @echo "ERROR: No kernel \"${KERNCONF}\" to install."
726 @echo "--------------------------------------------------------------"
727 @echo ">>> Making hierarchy"
728 @echo "--------------------------------------------------------------"
730 ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
732 @echo "--------------------------------------------------------------"
733 @echo ">>> Installing kernel"
734 @echo "--------------------------------------------------------------"
735 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
736 ${CROSSENV} PATH=${TMPPATH} \
737 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
742 # Update the source tree, by running cvsup and/or running cvs to update to the
746 .if defined(SUP_UPDATE)
747 @echo "--------------------------------------------------------------"
748 @echo ">>> Running ${SUP}"
749 @echo "--------------------------------------------------------------"
751 @${SUP} ${SUPFLAGS} ${SUPFILE}
753 .if defined(SUPFILE1)
754 @${SUP} ${SUPFLAGS} ${SUPFILE1}
756 .if defined(SUPFILE2)
757 @${SUP} ${SUPFLAGS} ${SUPFILE2}
759 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
760 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
762 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
763 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
766 .if defined(CVS_UPDATE)
767 @echo "--------------------------------------------------------------"
768 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
769 @echo "--------------------------------------------------------------"
770 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
774 # ------------------------------------------------------------------------
776 # From here onwards are utility targets used by the 'make world' and
777 # related targets. If your 'world' breaks, you may like to try to fix
778 # the problem and manually run the following targets to attempt to
779 # complete the build. Beware, this is *not* guaranteed to work, you
780 # need to have a pretty good grip on the current state of the system
781 # to attempt to manually finish it. If in doubt, 'make world' again.
785 # legacy: Build compatibility shims for the next three targets
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(NOGAMES)
802 _strfile= games/fortune/strfile
806 _gperf= gnu/usr.bin/gperf
807 .if ${BOOTSTRAPPING} < 500113
808 _groff= gnu/usr.bin/groff
810 _groff= gnu/usr.bin/groff/tmac
814 .if ${BOOTSTRAPPING} < 502102
818 .if ${BOOTSTRAPPING} < 450005 || \
819 ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
820 _uudecode= usr.bin/uudecode
823 .if ${BOOTSTRAPPING} < 430002 || \
824 ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
825 _xargs= usr.bin/xargs
828 .if ${BOOTSTRAPPING} < 430002 || \
829 ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
833 .if !defined(NO_RESCUE) && \
834 ${BOOTSTRAPPING} < 502128
835 _crunchgen= usr.sbin/crunch/crunchgen
838 .if ${BOOTSTRAPPING} < 502128
839 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
842 .if ${BOOTSTRAPPING} < 500019
843 _kbdcontrol= usr.sbin/kbdcontrol
851 gnu/usr.bin/texinfo \
864 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
865 cd ${.CURDIR}/${_tool}; \
866 ${MAKE} DIRPRFX=${_tool}/ obj; \
867 ${MAKE} DIRPRFX=${_tool}/ depend; \
868 ${MAKE} DIRPRFX=${_tool}/ all; \
869 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
873 # build-tools: Build special purpose build tools
875 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
876 _aicasm= sys/modules/aic7xxx/aicasm
879 .if !defined(NOSHARE)
880 _share= share/syscons/scrnmaps
883 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
884 _kerberos5_tools= kerberos5/tools
887 .if !defined(NO_RESCUE)
888 _rescue= rescue/rescue
902 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
903 cd ${.CURDIR}/${_tool}; \
904 ${MAKE} DIRPRFX=${_tool}/ obj; \
905 ${MAKE} DIRPRFX=${_tool}/ build-tools
908 gnu/usr.bin/cc/cc_tools \
910 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
911 cd ${.CURDIR}/${_tool}; \
912 ${MAKE} DIRPRFX=${_tool}/ obj; \
913 ${MAKE} DIRPRFX=${_tool}/ depend; \
914 ${MAKE} DIRPRFX=${_tool}/ all
918 # cross-tools: Build cross-building tools
920 .if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
921 ${BOOTSTRAPPING} < 500037
922 _elf2aout= usr.bin/elf2aout
925 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
926 _btxld= usr.sbin/btxld
929 .if (!defined(NO_RESCUE) || \
930 defined(RELEASEDIR)) && \
931 (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
932 _crunchide= usr.sbin/crunch/crunchide
935 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
936 _elf2exe= usr.sbin/elf2exe
939 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
941 _kgzip= usr.sbin/kgzip
946 gnu/usr.bin/binutils \
949 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
954 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
955 cd ${.CURDIR}/${_tool}; \
956 ${MAKE} DIRPRFX=${_tool}/ obj; \
957 ${MAKE} DIRPRFX=${_tool}/ depend; \
958 ${MAKE} DIRPRFX=${_tool}/ all; \
959 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
963 # hierarchy - ensure that all the needed directories are present
966 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
969 # libraries - build all libraries, and install them under ${DESTDIR}.
971 # The list of libraries with dependents (${_prebuild_libs}) and their
972 # interdependencies (__L) are built automatically by the
973 # ${.CURDIR}/tools/make_libdeps.sh script.
977 ${MAKE} -f Makefile.inc1 _startup_libs; \
978 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
979 ${MAKE} -f Makefile.inc1 _generic_libs;
981 # These dependencies are not automatically generated:
983 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
984 # shared libraries for ELF.
986 _startup_libs= gnu/lib/csu gnu/lib/libgcc
987 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
988 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
990 _startup_libs+= lib/csu/${MACHINE_ARCH}
995 _generic_libs= gnu/lib
997 .if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
998 _prebuild_libs+= kerberos5/lib/libasn1
999 _prebuild_libs+= kerberos5/lib/libgssapi
1000 _prebuild_libs+= kerberos5/lib/libkrb5
1001 _prebuild_libs+= kerberos5/lib/libroken
1002 _generic_libs+= kerberos5/lib
1005 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
1006 lib/libkvm lib/libmd \
1007 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1009 lib/libsbuf lib/libtacplus lib/libutil \
1012 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1014 .if !defined(NO_BIND)
1015 .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
1016 _prebuild_libs+= lib/libc_r
1018 _prebuild_libs+= lib/libpthread
1024 .if !defined(NOCRYPT)
1025 .if !defined(NO_OPENSSL)
1026 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
1027 lib/libradius__L: secure/lib/libssl__L
1028 secure/lib/libssl__L: secure/lib/libcrypto__L
1029 .if !defined(NO_OPENSSH)
1030 _prebuild_libs+= secure/lib/libssh
1031 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1032 .if !defined(NO_KERBEROS)
1033 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1034 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1035 kerberos5/lib/libroken__L
1039 _generic_libs+= secure/lib
1042 .if defined(NOCRYPT) || defined(NO_OPENSSL)
1043 lib/libradius__L: lib/libmd__L
1046 .if !defined(NO_NIS)
1047 _prebuild_libs+= lib/libypclnt
1050 _generic_libs+= usr.bin/lex/lib
1052 .if ${MACHINE_ARCH} == "i386"
1053 _generic_libs+= usr.sbin/pcvt/keycap
1056 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1058 .if exists(${.CURDIR}/${_lib})
1059 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1060 cd ${.CURDIR}/${_lib}; \
1061 ${MAKE} DIRPRFX=${_lib}/ depend; \
1062 ${MAKE} DIRPRFX=${_lib}/ all; \
1063 ${MAKE} DIRPRFX=${_lib}/ install
1067 # libpam is special: we need to build static PAM modules before
1068 # static PAM library, and dynamic PAM library before dynamic PAM
1070 lib/libpam__L: .PHONY
1071 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1072 cd ${.CURDIR}/lib/libpam; \
1073 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1074 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1075 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1077 _startup_libs: ${_startup_libs:S/$/__L/}
1078 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1079 _generic_libs: ${_generic_libs:S/$/__L/}
1081 .for __target in all clean cleandepend cleandir depend includes obj
1082 .for entry in ${SUBDIR}
1083 ${entry}.${__target}__D: .PHONY
1084 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1085 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1086 edir=${entry}.${MACHINE_ARCH}; \
1087 cd ${.CURDIR}/$${edir}; \
1089 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1091 cd ${.CURDIR}/$${edir}; \
1093 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1095 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1098 .include <bsd.subdir.mk>