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}
80 .if defined(NO_CLEANDIR)
81 CLEANDIR= clean cleandepend
87 CVSFLAGS?= -A -P -d -I!
88 SUP?= /usr/local/bin/cvsup
89 SUPFLAGS?= -g -L 2 -P -
91 SUPFLAGS+= -h ${SUPHOST}
94 MAKEOBJDIRPREFIX?= /usr/obj
95 .if !defined(OSRELDATE)
96 .if exists(/usr/include/osreldate.h)
97 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
98 /usr/include/osreldate.h
103 TARGET_ARCH?= ${MACHINE_ARCH}
104 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
106 TARGET_CPUTYPE?=${CPUTYPE}
108 TARGET?= ${TARGET_ARCH}
111 .if !empty(TARGET_CPUTYPE)
112 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
114 _TARGET_CPUTYPE=dummy
116 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
117 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
118 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
119 .error CPUTYPE global should be set with ?=.
122 BUILD_ARCH!= sysctl -n hw.machine_arch
123 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
124 .error To cross-build, set TARGET_ARCH.
127 .if ${MACHINE} == ${TARGET}
128 OBJTREE= ${MAKEOBJDIRPREFIX}
130 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
132 WORLDTMP= ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
133 # /usr/games added for fortune which depend on strfile
134 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
135 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
136 STRICTTMPPATH= ${BPATH}:${XPATH}
137 TMPPATH= ${STRICTTMPPATH}:${PATH}
139 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
142 # Building a world goes through the following stages
144 # 1. legacy stage [BMAKE]
145 # This stage is responsible for creating compatibility
146 # shims that are needed by the bootstrap-tools,
147 # build-tools and cross-tools stages.
148 # 1. bootstrap-tools stage [BMAKE]
149 # This stage is responsible for creating programs that
150 # are needed for backward compatibility reasons. They
151 # are not built as cross-tools.
152 # 2. build-tools stage [TMAKE]
153 # This stage is responsible for creating the object
154 # tree and building any tools that are needed during
156 # 3. cross-tools stage [XMAKE]
157 # This stage is responsible for creating any tools that
158 # are needed for cross-builds. A cross-compiler is one
160 # 4. world stage [WMAKE]
161 # This stage actually builds the world.
162 # 5. install stage (optional) [IMAKE]
163 # This stage installs a previously built world.
168 # Common environment for world related stages
169 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
170 MACHINE_ARCH=${TARGET_ARCH} \
172 CPUTYPE=${TARGET_CPUTYPE} \
173 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
174 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
175 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
177 # bootstrap-tools stage
178 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
179 PATH=${BPATH}:${PATH} \
180 WORLDTMP=${WORLDTMP} \
181 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
182 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
183 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
185 BOOTSTRAPPING=${OSRELDATE} \
186 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
187 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
190 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
191 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
193 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
196 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
199 WMAKEENV= ${CROSSENV} \
200 _SHLIBDIRPREFIX=${WORLDTMP} \
201 INSTALL="sh ${.CURDIR}/tools/install.sh" \
203 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
205 .if ${MACHINE_ARCH} == "amd64"
207 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
209 LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
210 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
211 -L${LIB32TMP}/usr/lib32 \
212 -B${LIB32TMP}/usr/lib32
213 LIB32CC= ${LIB32PREFLAGS} \
215 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
217 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
220 # Yes, the flags are redundant.
221 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
222 _SHLIBDIRPREFIX=${LIB32TMP} \
224 INSTALL="sh ${.CURDIR}/tools/install.sh" \
227 CXX="c++ ${LIB32CXX}" \
228 OBJC="cc ${LIB32OBJC}" \
229 LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
234 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
235 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML \
237 CXX="c++ ${LIB32CXX}" \
238 OBJC="cc ${LIB32OBJC}" \
239 LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
246 .if empty(.MAKEFLAGS:M-n)
247 IMAKEENV= ${CROSSENV} \
248 PATH=${STRICTTMPPATH}:${INSTALLTMP}
250 IMAKEENV= ${CROSSENV} \
251 PATH=${TMPPATH}:${INSTALLTMP}
253 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
256 KMAKEENV= ${WMAKEENV}
261 # Attempt to rebuild the entire system, with reasonable chance of
262 # success, regardless of how old your existing system is.
265 .if ${.CURDIR:C/[^,]//g} != ""
266 # The m4 build of sendmail files doesn't like it if ',' is used
267 # anywhere in the path of it's files.
269 @echo "*** Error: path to source tree contains a comma ','"
274 @echo "--------------------------------------------------------------"
275 @echo ">>> Rebuilding the temporary build tree"
276 @echo "--------------------------------------------------------------"
277 .if !defined(NO_CLEAN)
280 rm -rf ${WORLDTMP}/legacy/usr/include
281 # XXX - These two can depend on any header file.
282 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
283 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
286 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
287 usr/libexec usr/sbin usr/share/dict \
288 usr/share/groff_font/devX100 \
289 usr/share/groff_font/devX100-12 \
290 usr/share/groff_font/devX75 \
291 usr/share/groff_font/devX75-12 \
292 usr/share/groff_font/devascii \
293 usr/share/groff_font/devcp1047 \
294 usr/share/groff_font/devdvi \
295 usr/share/groff_font/devhtml \
296 usr/share/groff_font/devkoi8-r \
297 usr/share/groff_font/devlatin1 \
298 usr/share/groff_font/devlbp \
299 usr/share/groff_font/devlj4 \
300 usr/share/groff_font/devps \
301 usr/share/groff_font/devutf8 \
302 usr/share/tmac/mdoc usr/share/tmac/mm
303 mkdir -p ${WORLDTMP}/legacy/${_dir}
306 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
307 usr/libexec usr/sbin usr/share/misc \
308 usr/share/snmp/defs usr/share/snmp/mibs
309 mkdir -p ${WORLDTMP}/${_dir}
311 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
312 -p ${WORLDTMP}/usr/include >/dev/null
313 ln -sf ${.CURDIR}/sys ${WORLDTMP}
314 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
315 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
316 -p ${WORLDTMP}/usr/include >/dev/null
320 @echo "--------------------------------------------------------------"
321 @echo ">>> stage 1.1: legacy release compatibility shims"
322 @echo "--------------------------------------------------------------"
323 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
326 @echo "--------------------------------------------------------------"
327 @echo ">>> stage 1.2: bootstrap tools"
328 @echo "--------------------------------------------------------------"
329 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
331 .if !defined(NO_CLEAN)
333 @echo "--------------------------------------------------------------"
334 @echo ">>> stage 2.1: cleaning up the object tree"
335 @echo "--------------------------------------------------------------"
336 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
340 @echo "--------------------------------------------------------------"
341 @echo ">>> stage 2.2: rebuilding the object tree"
342 @echo "--------------------------------------------------------------"
343 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
346 @echo "--------------------------------------------------------------"
347 @echo ">>> stage 2.3: build tools"
348 @echo "--------------------------------------------------------------"
349 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
352 @echo "--------------------------------------------------------------"
353 @echo ">>> stage 3: cross tools"
354 @echo "--------------------------------------------------------------"
355 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
358 @echo "--------------------------------------------------------------"
359 @echo ">>> stage 4.1: building includes"
360 @echo "--------------------------------------------------------------"
361 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
364 @echo "--------------------------------------------------------------"
365 @echo ">>> stage 4.2: building libraries"
366 @echo "--------------------------------------------------------------"
367 ${_+_}cd ${.CURDIR}; \
368 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
369 -DNO_NLS -DNO_PROFILE libraries
372 @echo "--------------------------------------------------------------"
373 @echo ">>> stage 4.3: make dependencies"
374 @echo "--------------------------------------------------------------"
375 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
378 @echo "--------------------------------------------------------------"
379 @echo ">>> stage 4.4: building everything"
380 @echo "--------------------------------------------------------------"
381 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
382 .if ${MACHINE_ARCH} == "amd64"
385 @echo "--------------------------------------------------------------"
386 @echo ">>> stage 5.1: building 32 bit shim libraries"
387 @echo "--------------------------------------------------------------"
389 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
390 usr/libexec usr/sbin usr/share/misc \
391 usr/share/snmp/defs usr/share/snmp/mibs
392 mkdir -p ${LIB32TMP}/${_dir}
394 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
395 -p ${LIB32TMP}/usr/include >/dev/null
396 ln -sf ${.CURDIR}/sys ${WORLDTMP}
397 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
398 .for _t in obj depend all
399 cd ${.CURDIR}/kerberos5/tools; \
400 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
403 .for _t in obj includes
404 cd ${.CURDIR}/include; \
405 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
407 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
408 cd ${.CURDIR}/gnu/lib; \
409 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
410 .if !defined(NO_CRYPT)
411 cd ${.CURDIR}/secure/lib; \
412 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
414 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
415 cd ${.CURDIR}/kerberos5/lib; \
416 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
420 cd ${.CURDIR}/${_dir}; \
421 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
423 .for _dir in lib/libncurses lib/libmagic
424 cd ${.CURDIR}/${_dir}; \
425 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
428 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
429 .for _t in obj depend all
430 cd ${.CURDIR}/libexec/rtld-elf; \
431 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
435 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
436 cd ${.CURDIR}/lib; ${LIB32MAKE} install
437 cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
438 .if !defined(NO_CRYPT)
439 cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
441 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
446 .if !defined(SUBDIR_OVERRIDE)
447 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
449 WMAKE_TGTS+= _cleanobj _obj _build-tools
450 .if !defined(SUBDIR_OVERRIDE)
451 WMAKE_TGTS+= _cross-tools
453 WMAKE_TGTS+= _includes _libraries _depend everything
454 .if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
458 buildworld: ${WMAKE_TGTS}
459 .ORDER: ${WMAKE_TGTS}
462 @echo Entering world for ${TARGET_ARCH}:${TARGET}
463 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
465 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything}
466 toolchain: ${TOOLCHAIN_TGTS}
467 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
470 # Use this to add checks to installworld/installkernel targets.
472 SPECIAL_INSTALLCHECKS=
477 # Checks to be sure system is ready for installworld
481 .if !defined(NO_SENDMAIL)
487 CHECK_GIDS+= proxy authpf
489 installcheck: ${SPECIAL_INSTALLCHECKS}
490 .for uid in ${CHECK_UIDS}
491 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
492 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
496 .for gid in ${CHECK_GIDS}
497 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
498 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
506 # Distributes everything compiled by a `buildworld'.
510 # Installs everything compiled by a 'buildworld'.
512 distributeworld installworld: installcheck
513 mkdir -p ${INSTALLTMP}
514 for prog in [ awk cap_mkdb cat chflags chmod chown \
515 date echo egrep find grep \
516 ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
517 test true uname wc zic; do \
518 cp `which $$prog` ${INSTALLTMP}; \
520 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
526 # If you have a build server, you can NFS mount the source and obj directories
527 # and do a 'make reinstall' on the *client* to install new binaries from the
528 # most recent server build.
530 reinstall: ${SPECIAL_INSTALLCHECKS}
531 @echo "--------------------------------------------------------------"
532 @echo ">>> Making hierarchy"
533 @echo "--------------------------------------------------------------"
534 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
536 @echo "--------------------------------------------------------------"
537 @echo ">>> Installing everything"
538 @echo "--------------------------------------------------------------"
539 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
540 .if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
541 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
545 @echo "--------------------------------------------------------------"
546 @echo ">>> Distributing everything"
547 @echo "--------------------------------------------------------------"
548 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
551 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} distribution
554 # buildkernel and installkernel
556 # Which kernels to build and/or install is specified by setting
557 # KERNCONF. If not defined a GENERIC kernel is built/installed.
558 # Only the existing (depending TARGET) config files are used
559 # for building kernels and only the first of these is designated
560 # as the one being installed.
562 # Note that we have to use TARGET instead of TARGET_ARCH when
563 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
564 # be set to cross-build, we have to make sure TARGET is set
567 .if !defined(KERNCONF) && defined(KERNEL)
573 INSTKERNNAME?= kernel
575 KERNSRCDIR?= ${.CURDIR}/sys
576 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
577 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
578 KERNCONFDIR?= ${KRNLCONFDIR}
582 .for _kernel in ${KERNCONF}
583 .if exists(${KERNCONFDIR}/${_kernel})
584 BUILDKERNELS+= ${_kernel}
585 .if empty(INSTALLKERNEL)
586 INSTALLKERNEL= ${_kernel}
594 # Builds all kernels defined by BUILDKERNELS.
597 .if empty(BUILDKERNELS)
598 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
601 .if defined(KERNWARN)
602 @echo "--------------------------------------------------------------"
603 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
604 @echo "--------------------------------------------------------------"
608 .for _kernel in ${BUILDKERNELS}
609 @echo "--------------------------------------------------------------"
610 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
611 @echo "--------------------------------------------------------------"
612 @echo "===> ${_kernel}"
613 mkdir -p ${KRNLOBJDIR}
614 .if !defined(NO_KERNELCONFIG)
616 @echo "--------------------------------------------------------------"
617 @echo ">>> stage 1: configuring the kernel"
618 @echo "--------------------------------------------------------------"
621 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
622 ${KERNCONFDIR}/${_kernel}
624 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
626 @echo "--------------------------------------------------------------"
627 @echo ">>> stage 2.1: cleaning up the object tree"
628 @echo "--------------------------------------------------------------"
629 cd ${KRNLOBJDIR}/${_kernel}; \
630 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
633 @echo "--------------------------------------------------------------"
634 @echo ">>> stage 2.2: rebuilding the object tree"
635 @echo "--------------------------------------------------------------"
636 cd ${KRNLOBJDIR}/${_kernel}; \
637 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
639 @echo "--------------------------------------------------------------"
640 @echo ">>> stage 2.3: build tools"
641 @echo "--------------------------------------------------------------"
642 cd ${KRNLOBJDIR}/${_kernel}; \
643 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
644 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
645 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
646 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
647 .for target in obj depend all
648 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
649 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
650 ${MAKE} -DNO_CPU_CFLAGS ${target}
653 .if !defined(NO_KERNELDEPEND)
655 @echo "--------------------------------------------------------------"
656 @echo ">>> stage 3.1: making dependencies"
657 @echo "--------------------------------------------------------------"
658 cd ${KRNLOBJDIR}/${_kernel}; \
659 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
662 @echo "--------------------------------------------------------------"
663 @echo ">>> stage 3.2: building everything"
664 @echo "--------------------------------------------------------------"
665 cd ${KRNLOBJDIR}/${_kernel}; \
666 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
667 @echo "--------------------------------------------------------------"
668 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
669 @echo "--------------------------------------------------------------"
673 # installkernel, etc.
675 # Install the kernel defined by INSTALLKERNEL
677 installkernel installkernel.debug \
678 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
679 .if empty(INSTALLKERNEL)
680 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
683 @echo "--------------------------------------------------------------"
684 @echo ">>> Making hierarchy"
685 @echo "--------------------------------------------------------------"
687 ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
689 @echo "--------------------------------------------------------------"
690 @echo ">>> Installing kernel"
691 @echo "--------------------------------------------------------------"
692 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
693 ${CROSSENV} PATH=${TMPPATH} \
694 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
699 # Update the source tree, by running cvsup and/or running cvs to update to the
703 .if defined(SUP_UPDATE)
704 @echo "--------------------------------------------------------------"
705 @echo ">>> Running ${SUP}"
706 @echo "--------------------------------------------------------------"
708 @${SUP} ${SUPFLAGS} ${SUPFILE}
710 .if defined(SUPFILE1)
711 @${SUP} ${SUPFLAGS} ${SUPFILE1}
713 .if defined(SUPFILE2)
714 @${SUP} ${SUPFLAGS} ${SUPFILE2}
716 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
717 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
719 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
720 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
723 .if defined(CVS_UPDATE)
724 @echo "--------------------------------------------------------------"
725 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
726 @echo "--------------------------------------------------------------"
727 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
731 # ------------------------------------------------------------------------
733 # From here onwards are utility targets used by the 'make world' and
734 # related targets. If your 'world' breaks, you may like to try to fix
735 # the problem and manually run the following targets to attempt to
736 # complete the build. Beware, this is *not* guaranteed to work, you
737 # need to have a pretty good grip on the current state of the system
738 # to attempt to manually finish it. If in doubt, 'make world' again.
742 # legacy: Build compatibility shims for the next three targets
745 .if ${BOOTSTRAPPING} < 503000
746 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
749 .for _tool in tools/build
750 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
751 cd ${.CURDIR}/${_tool}; \
752 ${MAKE} DIRPRFX=${_tool}/ obj; \
753 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
754 ${MAKE} DIRPRFX=${_tool}/ depend; \
755 ${MAKE} DIRPRFX=${_tool}/ all; \
756 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
760 # bootstrap-tools: Build tools needed for compatibility
762 .if !defined(NO_GAMES)
763 _strfile= games/fortune/strfile
767 _gperf= gnu/usr.bin/gperf
768 .if ${BOOTSTRAPPING} < 500113
769 _groff= gnu/usr.bin/groff
771 _groff= gnu/usr.bin/groff/tmac
775 .if ${BOOTSTRAPPING} < 600015
776 _cap_mkdb= usr.bin/cap_mkdb
779 .if ${BOOTSTRAPPING} < 600018
780 _colldef= usr.bin/colldef
783 .if ${BOOTSTRAPPING} < 600017
784 _gencat= usr.bin/gencat
787 .if ${BOOTSTRAPPING} < 600016
788 _mklocale= usr.bin/mklocale
791 .if !defined(NO_RESCUE) && \
792 ${BOOTSTRAPPING} < 600008
793 _crunchgen= usr.sbin/crunch/crunchgen
801 gnu/usr.bin/texinfo \
812 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
813 cd ${.CURDIR}/${_tool}; \
814 ${MAKE} DIRPRFX=${_tool}/ obj; \
815 ${MAKE} DIRPRFX=${_tool}/ depend; \
816 ${MAKE} DIRPRFX=${_tool}/ all; \
817 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
821 # build-tools: Build special purpose build tools
823 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
824 _aicasm= sys/modules/aic7xxx/aicasm
827 .if !defined(NO_SHARE)
828 _share= share/syscons/scrnmaps
831 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
832 _kerberos5_tools= kerberos5/tools
835 .if !defined(NO_RESCUE)
836 _rescue= rescue/rescue
850 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
851 cd ${.CURDIR}/${_tool}; \
852 ${MAKE} DIRPRFX=${_tool}/ obj; \
853 ${MAKE} DIRPRFX=${_tool}/ build-tools
856 gnu/usr.bin/cc/cc_tools \
858 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
859 cd ${.CURDIR}/${_tool}; \
860 ${MAKE} DIRPRFX=${_tool}/ obj; \
861 ${MAKE} DIRPRFX=${_tool}/ depend; \
862 ${MAKE} DIRPRFX=${_tool}/ all
866 # cross-tools: Build cross-building tools
868 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
869 ${TARGET_ARCH} != ${MACHINE_ARCH}
870 _btxld= usr.sbin/btxld
873 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
874 ${TARGET_ARCH} != ${MACHINE_ARCH}
875 _crunchide= usr.sbin/crunch/crunchide
878 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
879 _elf2exe= usr.sbin/elf2exe
882 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
884 _kgzip= usr.sbin/kgzip
889 gnu/usr.bin/binutils \
891 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
896 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
897 cd ${.CURDIR}/${_tool}; \
898 ${MAKE} DIRPRFX=${_tool}/ obj; \
899 ${MAKE} DIRPRFX=${_tool}/ depend; \
900 ${MAKE} DIRPRFX=${_tool}/ all; \
901 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
905 # hierarchy - ensure that all the needed directories are present
908 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
911 # libraries - build all libraries, and install them under ${DESTDIR}.
913 # The list of libraries with dependents (${_prebuild_libs}) and their
914 # interdependencies (__L) are built automatically by the
915 # ${.CURDIR}/tools/make_libdeps.sh script.
919 ${MAKE} -f Makefile.inc1 _startup_libs; \
920 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
921 ${MAKE} -f Makefile.inc1 _generic_libs;
923 # These dependencies are not automatically generated:
925 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
926 # shared libraries for ELF.
928 _startup_libs= gnu/lib/csu gnu/lib/libgcc
929 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
930 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
932 _startup_libs+= lib/csu/${MACHINE_ARCH}
937 _generic_libs= gnu/lib
939 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
940 _prebuild_libs+= kerberos5/lib/libasn1
941 _prebuild_libs+= kerberos5/lib/libgssapi
942 _prebuild_libs+= kerberos5/lib/libkrb5
943 _prebuild_libs+= kerberos5/lib/libroken
944 _generic_libs+= kerberos5/lib
947 _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
948 lib/libkvm lib/libmd \
949 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
951 lib/libsbuf lib/libtacplus lib/libutil \
954 lib/libopie__L lib/libtacplus__L: lib/libmd__L
956 .if !defined(NO_BIND)
957 .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
958 _prebuild_libs+= lib/libc_r
960 _prebuild_libs+= lib/libpthread
966 .if !defined(NO_CRYPT)
967 .if !defined(NO_OPENSSL)
968 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
969 lib/libradius__L: secure/lib/libssl__L
970 secure/lib/libssl__L: secure/lib/libcrypto__L
971 .if !defined(NO_OPENSSH)
972 _prebuild_libs+= secure/lib/libssh
973 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
974 .if !defined(NO_KERBEROS)
975 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
976 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
977 kerberos5/lib/libroken__L
981 _generic_libs+= secure/lib
984 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
985 lib/libradius__L: lib/libmd__L
989 _prebuild_libs+= lib/libypclnt
992 _generic_libs+= usr.bin/lex/lib
994 .if ${MACHINE_ARCH} == "i386"
995 _generic_libs+= usr.sbin/pcvt/keycap
998 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1000 .if exists(${.CURDIR}/${_lib})
1001 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1002 cd ${.CURDIR}/${_lib}; \
1003 ${MAKE} DIRPRFX=${_lib}/ depend; \
1004 ${MAKE} DIRPRFX=${_lib}/ all; \
1005 ${MAKE} DIRPRFX=${_lib}/ install
1009 # libpam is special: we need to build static PAM modules before
1010 # static PAM library, and dynamic PAM library before dynamic PAM
1012 lib/libpam__L: .PHONY
1013 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1014 cd ${.CURDIR}/lib/libpam; \
1015 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1016 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1017 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1019 _startup_libs: ${_startup_libs:S/$/__L/}
1020 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1021 _generic_libs: ${_generic_libs:S/$/__L/}
1023 .for __target in all clean cleandepend cleandir depend includes obj
1024 .for entry in ${SUBDIR}
1025 ${entry}.${__target}__D: .PHONY
1026 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1027 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1028 edir=${entry}.${MACHINE_ARCH}; \
1029 cd ${.CURDIR}/$${edir}; \
1031 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1033 cd ${.CURDIR}/$${edir}; \
1035 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1037 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1040 .include <bsd.subdir.mk>