4 # Make command line options:
5 # -DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6 # -DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7 # -DNO_RESCUE do not build rescue binaries
8 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9 # -DNO_CLEAN do not clean at all
10 # -DNO_CRYPT will prevent building of crypt versions
11 # -DNO_MAN do not build the manual pages
12 # -DNO_NLS do not build Native Language Support files
13 # -DNO_PROFILE do not build profiled libraries
14 # -DNO_GAMES do not go into games subdir
15 # -DNO_SHARE do not go into share subdir
16 # -DNO_INFO do not make or install info files
17 # -DNO_LIBC_R do not build libc_r.
18 # -DNO_FORTRAN do not build g77 and related libraries.
19 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
20 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
21 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
22 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
23 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
24 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
25 # TARGET_ARCH="arch" to crossbuild world to a different arch
28 # The intended user-driven targets are:
29 # buildworld - rebuild *everything*, including glue to help do upgrades
30 # installworld- install everything built by "buildworld"
31 # update - convenient way to update your source tree (eg: cvsup/cvs)
33 # Standard targets (not defined here) are documented in the makefiles in
34 # /usr/share/mk. These include:
35 # obj depend all install clean cleandepend cleanobj
37 # We must do share/info early so that installation of info `dir'
38 # entries works correctly. Do it first since it is less likely to
39 # grow dependencies on include and lib than vice versa.
41 # We must do lib and libexec before bin, because if installworld
42 # installs a new /bin/sh, the 'make' command will *immediately*
43 # use that new version. And the new (dynamically-linked) /bin/sh
44 # will expect to find appropriate libraries in /lib and /libexec.
46 # We must do etc last for install/distribute to work.
48 SUBDIR= share/info include lib libexec bin
49 .if !defined(NO_GAMES)
53 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
56 .if !defined(NO_RESCUE)
60 .if !defined(NO_CRYPT)
63 .if !defined(NO_SHARE)
66 SUBDIR+=sys usr.bin usr.sbin etc
68 # These are last, since it is nice to at least get the base system
69 # rebuilt before you do them.
70 .for _DIR in ${LOCAL_DIRS}
71 .if exists(${.CURDIR}/${_DIR}/Makefile)
76 .if defined(SUBDIR_OVERRIDE)
77 SUBDIR= ${SUBDIR_OVERRIDE}
83 .if defined(NO_CLEANDIR)
84 CLEANDIR= clean cleandepend
90 CVSFLAGS?= -A -P -d -I!
91 SUP?= /usr/local/bin/cvsup
92 SUPFLAGS?= -g -L 2 -P -
94 SUPFLAGS+= -h ${SUPHOST}
97 MAKEOBJDIRPREFIX?= /usr/obj
98 .if !defined(OSRELDATE)
99 .if exists(/usr/include/osreldate.h)
100 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
101 /usr/include/osreldate.h
106 TARGET_ARCH?= ${MACHINE_ARCH}
107 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
109 TARGET_CPUTYPE?=${CPUTYPE}
111 TARGET?= ${TARGET_ARCH}
114 .if !empty(TARGET_CPUTYPE)
115 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
117 _TARGET_CPUTYPE=dummy
119 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
120 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
121 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
122 .error CPUTYPE global should be set with ?=.
125 BUILD_ARCH!= sysctl -n hw.machine_arch
126 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
127 .error To cross-build, set TARGET_ARCH.
130 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
131 OBJTREE= ${MAKEOBJDIRPREFIX}
133 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
135 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
136 # /usr/games added for fortune which depend on strfile
137 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
138 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
139 STRICTTMPPATH= ${BPATH}:${XPATH}
140 TMPPATH= ${STRICTTMPPATH}:${PATH}
142 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
145 # Building a world goes through the following stages
147 # 1. legacy stage [BMAKE]
148 # This stage is responsible for creating compatibility
149 # shims that are needed by the bootstrap-tools,
150 # build-tools and cross-tools stages.
151 # 1. bootstrap-tools stage [BMAKE]
152 # This stage is responsible for creating programs that
153 # are needed for backward compatibility reasons. They
154 # are not built as cross-tools.
155 # 2. build-tools stage [TMAKE]
156 # This stage is responsible for creating the object
157 # tree and building any tools that are needed during
159 # 3. cross-tools stage [XMAKE]
160 # This stage is responsible for creating any tools that
161 # are needed for cross-builds. A cross-compiler is one
163 # 4. world stage [WMAKE]
164 # This stage actually builds the world.
165 # 5. install stage (optional) [IMAKE]
166 # This stage installs a previously built world.
171 # Common environment for world related stages
172 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
173 MACHINE_ARCH=${TARGET_ARCH} \
175 CPUTYPE=${TARGET_CPUTYPE} \
176 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
177 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
178 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
180 # bootstrap-tools stage
181 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
182 PATH=${BPATH}:${PATH} \
183 WORLDTMP=${WORLDTMP} \
184 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
185 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
186 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
188 BOOTSTRAPPING=${OSRELDATE} \
189 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
190 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
193 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
194 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
196 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
199 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
202 WMAKEENV= ${CROSSENV} \
203 _SHLIBDIRPREFIX=${WORLDTMP} \
204 INSTALL="sh ${.CURDIR}/tools/install.sh" \
206 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
208 .if ${TARGET_ARCH} == "amd64"
210 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
212 LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
213 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
214 -L${LIB32TMP}/usr/lib32 \
215 -B${LIB32TMP}/usr/lib32
216 LIB32CC= ${LIB32PREFLAGS} \
218 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
220 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
223 # Yes, the flags are redundant.
224 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
225 _SHLIBDIRPREFIX=${LIB32TMP} \
228 INSTALL="sh ${.CURDIR}/tools/install.sh" \
231 CXX="c++ ${LIB32CXX}" \
232 OBJC="cc ${LIB32OBJC}" \
233 LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
238 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
239 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML \
241 CXX="c++ ${LIB32CXX}" \
242 OBJC="cc ${LIB32OBJC}" \
243 LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
250 .if empty(.MAKEFLAGS:M-n)
251 IMAKEENV= ${CROSSENV} \
252 PATH=${STRICTTMPPATH}:${INSTALLTMP}
254 IMAKEENV= ${CROSSENV} \
255 PATH=${TMPPATH}:${INSTALLTMP}
257 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
260 KMAKEENV= ${WMAKEENV}
265 # Attempt to rebuild the entire system, with reasonable chance of
266 # success, regardless of how old your existing system is.
269 .if ${.CURDIR:C/[^,]//g} != ""
270 # The m4 build of sendmail files doesn't like it if ',' is used
271 # anywhere in the path of it's files.
273 @echo "*** Error: path to source tree contains a comma ','"
278 @echo "--------------------------------------------------------------"
279 @echo ">>> Rebuilding the temporary build tree"
280 @echo "--------------------------------------------------------------"
281 .if !defined(NO_CLEAN)
284 rm -rf ${WORLDTMP}/legacy/usr/include
285 # XXX - These two can depend on any header file.
286 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
287 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
290 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
291 usr/libexec usr/sbin usr/share/dict \
292 usr/share/groff_font/devX100 \
293 usr/share/groff_font/devX100-12 \
294 usr/share/groff_font/devX75 \
295 usr/share/groff_font/devX75-12 \
296 usr/share/groff_font/devascii \
297 usr/share/groff_font/devcp1047 \
298 usr/share/groff_font/devdvi \
299 usr/share/groff_font/devhtml \
300 usr/share/groff_font/devkoi8-r \
301 usr/share/groff_font/devlatin1 \
302 usr/share/groff_font/devlbp \
303 usr/share/groff_font/devlj4 \
304 usr/share/groff_font/devps \
305 usr/share/groff_font/devutf8 \
306 usr/share/tmac/mdoc usr/share/tmac/mm
307 mkdir -p ${WORLDTMP}/legacy/${_dir}
310 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
311 usr/libexec usr/sbin usr/share/misc \
312 usr/share/snmp/defs usr/share/snmp/mibs
313 mkdir -p ${WORLDTMP}/${_dir}
315 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
316 -p ${WORLDTMP}/usr/include >/dev/null
317 ln -sf ${.CURDIR}/sys ${WORLDTMP}
318 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
319 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
320 -p ${WORLDTMP}/usr/include >/dev/null
324 @echo "--------------------------------------------------------------"
325 @echo ">>> stage 1.1: legacy release compatibility shims"
326 @echo "--------------------------------------------------------------"
327 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
330 @echo "--------------------------------------------------------------"
331 @echo ">>> stage 1.2: bootstrap tools"
332 @echo "--------------------------------------------------------------"
333 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
335 .if !defined(NO_CLEAN)
337 @echo "--------------------------------------------------------------"
338 @echo ">>> stage 2.1: cleaning up the object tree"
339 @echo "--------------------------------------------------------------"
340 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
344 @echo "--------------------------------------------------------------"
345 @echo ">>> stage 2.2: rebuilding the object tree"
346 @echo "--------------------------------------------------------------"
347 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
350 @echo "--------------------------------------------------------------"
351 @echo ">>> stage 2.3: build tools"
352 @echo "--------------------------------------------------------------"
353 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
356 @echo "--------------------------------------------------------------"
357 @echo ">>> stage 3: cross tools"
358 @echo "--------------------------------------------------------------"
359 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
362 @echo "--------------------------------------------------------------"
363 @echo ">>> stage 4.1: building includes"
364 @echo "--------------------------------------------------------------"
365 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
368 @echo "--------------------------------------------------------------"
369 @echo ">>> stage 4.2: building libraries"
370 @echo "--------------------------------------------------------------"
371 ${_+_}cd ${.CURDIR}; \
372 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
373 -DNO_NLS -DNO_PROFILE libraries
376 @echo "--------------------------------------------------------------"
377 @echo ">>> stage 4.3: make dependencies"
378 @echo "--------------------------------------------------------------"
379 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
382 @echo "--------------------------------------------------------------"
383 @echo ">>> stage 4.4: building everything"
384 @echo "--------------------------------------------------------------"
385 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
386 .if ${TARGET_ARCH} == "amd64"
389 @echo "--------------------------------------------------------------"
390 @echo ">>> stage 5.1: building 32 bit shim libraries"
391 @echo "--------------------------------------------------------------"
393 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
394 usr/libexec usr/sbin usr/share/misc \
395 usr/share/snmp/defs usr/share/snmp/mibs
396 mkdir -p ${LIB32TMP}/${_dir}
398 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
399 -p ${LIB32TMP}/usr/include >/dev/null
400 ln -sf ${.CURDIR}/sys ${WORLDTMP}
401 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
402 .for _t in obj depend all
403 cd ${.CURDIR}/kerberos5/tools; \
404 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
407 .for _t in obj includes
408 cd ${.CURDIR}/include; \
409 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
411 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412 cd ${.CURDIR}/gnu/lib; \
413 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
414 .if !defined(NO_CRYPT)
415 cd ${.CURDIR}/secure/lib; \
416 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
418 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
419 cd ${.CURDIR}/kerberos5/lib; \
420 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
423 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
424 cd ${.CURDIR}/${_dir}; \
425 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
427 .for _dir in lib/libncurses lib/libmagic
428 cd ${.CURDIR}/${_dir}; \
429 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
432 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
433 .for _t in obj depend all
434 cd ${.CURDIR}/libexec/rtld-elf; \
435 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
439 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
440 cd ${.CURDIR}/lib; ${LIB32MAKE} install
441 cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
442 .if !defined(NO_CRYPT)
443 cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
445 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
450 .if !defined(SUBDIR_OVERRIDE)
451 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
453 WMAKE_TGTS+= _cleanobj _obj _build-tools
454 .if !defined(SUBDIR_OVERRIDE)
455 WMAKE_TGTS+= _cross-tools
457 WMAKE_TGTS+= _includes _libraries _depend everything
458 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
462 buildworld: ${WMAKE_TGTS}
463 .ORDER: ${WMAKE_TGTS}
466 @echo Entering world for ${TARGET_ARCH}:${TARGET}
467 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
469 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything}
470 toolchain: ${TOOLCHAIN_TGTS}
471 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
474 # Use this to add checks to installworld/installkernel targets.
476 SPECIAL_INSTALLCHECKS=
481 # Checks to be sure system is ready for installworld
485 .if !defined(NO_SENDMAIL)
491 CHECK_GIDS+= proxy authpf
493 installcheck: ${SPECIAL_INSTALLCHECKS}
494 .for uid in ${CHECK_UIDS}
495 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
496 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
500 .for gid in ${CHECK_GIDS}
501 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
502 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
510 # Distributes everything compiled by a `buildworld'.
514 # Installs everything compiled by a 'buildworld'.
516 distributeworld installworld: installcheck
517 mkdir -p ${INSTALLTMP}
518 for prog in [ awk cap_mkdb cat chflags chmod chown \
519 date echo egrep find grep \
520 ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
521 test true uname wc zic; do \
522 cp `which $$prog` ${INSTALLTMP}; \
524 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
530 # If you have a build server, you can NFS mount the source and obj directories
531 # and do a 'make reinstall' on the *client* to install new binaries from the
532 # most recent server build.
534 reinstall: ${SPECIAL_INSTALLCHECKS}
535 @echo "--------------------------------------------------------------"
536 @echo ">>> Making hierarchy"
537 @echo "--------------------------------------------------------------"
538 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
540 @echo "--------------------------------------------------------------"
541 @echo ">>> Installing everything"
542 @echo "--------------------------------------------------------------"
543 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
544 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
545 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
549 @echo "--------------------------------------------------------------"
550 @echo ">>> Distributing everything"
551 @echo "--------------------------------------------------------------"
552 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
555 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} distribution
558 # buildkernel and installkernel
560 # Which kernels to build and/or install is specified by setting
561 # KERNCONF. If not defined a GENERIC kernel is built/installed.
562 # Only the existing (depending TARGET) config files are used
563 # for building kernels and only the first of these is designated
564 # as the one being installed.
566 # Note that we have to use TARGET instead of TARGET_ARCH when
567 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
568 # be set to cross-build, we have to make sure TARGET is set
571 .if !defined(KERNCONF) && defined(KERNEL)
577 INSTKERNNAME?= kernel
579 KERNSRCDIR?= ${.CURDIR}/sys
580 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
581 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
582 KERNCONFDIR?= ${KRNLCONFDIR}
586 .for _kernel in ${KERNCONF}
587 .if exists(${KERNCONFDIR}/${_kernel})
588 BUILDKERNELS+= ${_kernel}
589 .if empty(INSTALLKERNEL)
590 INSTALLKERNEL= ${_kernel}
598 # Builds all kernels defined by BUILDKERNELS.
601 .if empty(BUILDKERNELS)
602 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
605 .if defined(KERNWARN)
606 @echo "--------------------------------------------------------------"
607 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
608 @echo "--------------------------------------------------------------"
612 .for _kernel in ${BUILDKERNELS}
613 @echo "--------------------------------------------------------------"
614 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
615 @echo "--------------------------------------------------------------"
616 @echo "===> ${_kernel}"
617 mkdir -p ${KRNLOBJDIR}
618 .if !defined(NO_KERNELCONFIG)
620 @echo "--------------------------------------------------------------"
621 @echo ">>> stage 1: configuring the kernel"
622 @echo "--------------------------------------------------------------"
625 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
626 ${KERNCONFDIR}/${_kernel}
628 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
630 @echo "--------------------------------------------------------------"
631 @echo ">>> stage 2.1: cleaning up the object tree"
632 @echo "--------------------------------------------------------------"
633 cd ${KRNLOBJDIR}/${_kernel}; \
634 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
637 @echo "--------------------------------------------------------------"
638 @echo ">>> stage 2.2: rebuilding the object tree"
639 @echo "--------------------------------------------------------------"
640 cd ${KRNLOBJDIR}/${_kernel}; \
641 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
643 @echo "--------------------------------------------------------------"
644 @echo ">>> stage 2.3: build tools"
645 @echo "--------------------------------------------------------------"
646 cd ${KRNLOBJDIR}/${_kernel}; \
647 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
648 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
649 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
650 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
651 .for target in obj depend all
652 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
653 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
654 ${MAKE} -DNO_CPU_CFLAGS ${target}
657 .if !defined(NO_KERNELDEPEND)
659 @echo "--------------------------------------------------------------"
660 @echo ">>> stage 3.1: making dependencies"
661 @echo "--------------------------------------------------------------"
662 cd ${KRNLOBJDIR}/${_kernel}; \
663 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
666 @echo "--------------------------------------------------------------"
667 @echo ">>> stage 3.2: building everything"
668 @echo "--------------------------------------------------------------"
669 cd ${KRNLOBJDIR}/${_kernel}; \
670 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
671 @echo "--------------------------------------------------------------"
672 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
673 @echo "--------------------------------------------------------------"
677 # installkernel, etc.
679 # Install the kernel defined by INSTALLKERNEL
681 installkernel installkernel.debug \
682 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
683 .if empty(INSTALLKERNEL)
684 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
687 @echo "--------------------------------------------------------------"
688 @echo ">>> Making hierarchy"
689 @echo "--------------------------------------------------------------"
691 ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
693 @echo "--------------------------------------------------------------"
694 @echo ">>> Installing kernel"
695 @echo "--------------------------------------------------------------"
696 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
697 ${CROSSENV} PATH=${TMPPATH} \
698 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
703 # Update the source tree, by running cvsup and/or running cvs to update to the
707 .if defined(SUP_UPDATE)
708 @echo "--------------------------------------------------------------"
709 @echo ">>> Running ${SUP}"
710 @echo "--------------------------------------------------------------"
712 @${SUP} ${SUPFLAGS} ${SUPFILE}
714 .if defined(SUPFILE1)
715 @${SUP} ${SUPFLAGS} ${SUPFILE1}
717 .if defined(SUPFILE2)
718 @${SUP} ${SUPFLAGS} ${SUPFILE2}
720 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
721 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
723 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
724 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
727 .if defined(CVS_UPDATE)
728 @echo "--------------------------------------------------------------"
729 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
730 @echo "--------------------------------------------------------------"
731 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
735 # ------------------------------------------------------------------------
737 # From here onwards are utility targets used by the 'make world' and
738 # related targets. If your 'world' breaks, you may like to try to fix
739 # the problem and manually run the following targets to attempt to
740 # complete the build. Beware, this is *not* guaranteed to work, you
741 # need to have a pretty good grip on the current state of the system
742 # to attempt to manually finish it. If in doubt, 'make world' again.
746 # legacy: Build compatibility shims for the next three targets
749 .if ${BOOTSTRAPPING} < 503000
750 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
753 .for _tool in tools/build
754 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
755 cd ${.CURDIR}/${_tool}; \
756 ${MAKE} DIRPRFX=${_tool}/ obj; \
757 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
758 ${MAKE} DIRPRFX=${_tool}/ depend; \
759 ${MAKE} DIRPRFX=${_tool}/ all; \
760 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
764 # bootstrap-tools: Build tools needed for compatibility
766 .if !defined(NO_GAMES)
767 _strfile= games/fortune/strfile
771 _gperf= gnu/usr.bin/gperf
772 .if ${BOOTSTRAPPING} < 500113
773 _groff= gnu/usr.bin/groff
775 _groff= gnu/usr.bin/groff/tmac
779 .if ${BOOTSTRAPPING} < 600015
780 _cap_mkdb= usr.bin/cap_mkdb
783 .if ${BOOTSTRAPPING} < 600018
784 _colldef= usr.bin/colldef
787 .if ${BOOTSTRAPPING} < 600017
788 _gencat= usr.bin/gencat
791 .if ${BOOTSTRAPPING} < 600016
792 _mklocale= usr.bin/mklocale
795 .if !defined(NO_RESCUE) && \
796 ${BOOTSTRAPPING} < 600008
797 _crunchgen= usr.sbin/crunch/crunchgen
800 .if ${BOOTSTRAPPING} < 600020
801 _pwd_mkdb= usr.sbin/pwd_mkdb
809 gnu/usr.bin/texinfo \
821 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
822 cd ${.CURDIR}/${_tool}; \
823 ${MAKE} DIRPRFX=${_tool}/ obj; \
824 ${MAKE} DIRPRFX=${_tool}/ depend; \
825 ${MAKE} DIRPRFX=${_tool}/ all; \
826 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
830 # build-tools: Build special purpose build tools
832 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
833 _aicasm= sys/modules/aic7xxx/aicasm
836 .if !defined(NO_SHARE)
837 _share= share/syscons/scrnmaps
840 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
841 _kerberos5_tools= kerberos5/tools
844 .if !defined(NO_RESCUE)
845 _rescue= rescue/rescue
859 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
860 cd ${.CURDIR}/${_tool}; \
861 ${MAKE} DIRPRFX=${_tool}/ obj; \
862 ${MAKE} DIRPRFX=${_tool}/ build-tools
865 gnu/usr.bin/cc/cc_tools \
867 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
868 cd ${.CURDIR}/${_tool}; \
869 ${MAKE} DIRPRFX=${_tool}/ obj; \
870 ${MAKE} DIRPRFX=${_tool}/ depend; \
871 ${MAKE} DIRPRFX=${_tool}/ all
875 # cross-tools: Build cross-building tools
877 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
878 ${TARGET_ARCH} != ${MACHINE_ARCH}
879 _btxld= usr.sbin/btxld
882 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
883 ${TARGET_ARCH} != ${MACHINE_ARCH}
884 _crunchide= usr.sbin/crunch/crunchide
887 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
888 _elf2exe= usr.sbin/elf2exe
891 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
893 _kgzip= usr.sbin/kgzip
898 gnu/usr.bin/binutils \
900 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
905 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
906 cd ${.CURDIR}/${_tool}; \
907 ${MAKE} DIRPRFX=${_tool}/ obj; \
908 ${MAKE} DIRPRFX=${_tool}/ depend; \
909 ${MAKE} DIRPRFX=${_tool}/ all; \
910 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
914 # hierarchy - ensure that all the needed directories are present
917 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
920 # libraries - build all libraries, and install them under ${DESTDIR}.
922 # The list of libraries with dependents (${_prebuild_libs}) and their
923 # interdependencies (__L) are built automatically by the
924 # ${.CURDIR}/tools/make_libdeps.sh script.
928 ${MAKE} -f Makefile.inc1 _startup_libs; \
929 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
930 ${MAKE} -f Makefile.inc1 _generic_libs;
932 # These dependencies are not automatically generated:
934 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
935 # shared libraries for ELF.
937 _startup_libs= gnu/lib/csu gnu/lib/libgcc
938 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
939 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
941 _startup_libs+= lib/csu/${MACHINE_ARCH}
946 _generic_libs= gnu/lib
948 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
949 _prebuild_libs+= kerberos5/lib/libasn1
950 _prebuild_libs+= kerberos5/lib/libgssapi
951 _prebuild_libs+= kerberos5/lib/libkrb5
952 _prebuild_libs+= kerberos5/lib/libroken
953 _generic_libs+= kerberos5/lib
956 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
957 lib/libkvm lib/libmd \
958 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
960 lib/libsbuf lib/libtacplus lib/libutil \
963 lib/libopie__L lib/libtacplus__L: lib/libmd__L
965 .if !defined(NO_BIND)
966 .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
967 _prebuild_libs+= lib/libc_r
969 _prebuild_libs+= lib/libpthread
975 .if !defined(NO_CRYPT)
976 .if !defined(NO_OPENSSL)
977 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
978 lib/libradius__L: secure/lib/libssl__L
979 secure/lib/libssl__L: secure/lib/libcrypto__L
980 .if !defined(NO_OPENSSH)
981 _prebuild_libs+= secure/lib/libssh
982 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
983 .if !defined(NO_KERBEROS)
984 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
985 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
986 kerberos5/lib/libroken__L
990 _generic_libs+= secure/lib
993 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
994 lib/libradius__L: lib/libmd__L
998 _prebuild_libs+= lib/libypclnt
1001 _generic_libs+= usr.bin/lex/lib
1003 .if ${MACHINE_ARCH} == "i386"
1004 _generic_libs+= usr.sbin/pcvt/keycap
1007 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1009 .if exists(${.CURDIR}/${_lib})
1010 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1011 cd ${.CURDIR}/${_lib}; \
1012 ${MAKE} DIRPRFX=${_lib}/ depend; \
1013 ${MAKE} DIRPRFX=${_lib}/ all; \
1014 ${MAKE} DIRPRFX=${_lib}/ install
1018 # libpam is special: we need to build static PAM modules before
1019 # static PAM library, and dynamic PAM library before dynamic PAM
1021 lib/libpam__L: .PHONY
1022 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1023 cd ${.CURDIR}/lib/libpam; \
1024 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1025 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1026 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1028 _startup_libs: ${_startup_libs:S/$/__L/}
1029 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1030 _generic_libs: ${_generic_libs:S/$/__L/}
1032 .for __target in all clean cleandepend cleandir depend includes obj
1033 .for entry in ${SUBDIR}
1034 ${entry}.${__target}__D: .PHONY
1035 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1036 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1037 edir=${entry}.${MACHINE_ARCH}; \
1038 cd ${.CURDIR}/$${edir}; \
1040 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1042 cd ${.CURDIR}/$${edir}; \
1044 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1046 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1049 .include <bsd.subdir.mk>