4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DNO_SHARE do not go into share subdir
8 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
12 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
13 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
14 # TARGET_ARCH="arch" to crossbuild world to a different arch
17 # The intended user-driven targets are:
18 # buildworld - rebuild *everything*, including glue to help do upgrades
19 # installworld- install everything built by "buildworld"
20 # doxygen - build API documentation of the kernel
21 # update - convenient way to update your source tree (eg: cvsup/cvs)
23 # Standard targets (not defined here) are documented in the makefiles in
24 # /usr/share/mk. These include:
25 # obj depend all install clean cleandepend cleanobj
29 # We must do share/info early so that installation of info `dir'
30 # entries works correctly. Do it first since it is less likely to
31 # grow dependencies on include and lib than vice versa.
33 # We must do lib and libexec before bin, because if installworld
34 # installs a new /bin/sh, the 'make' command will *immediately*
35 # use that new version. And the new (dynamically-linked) /bin/sh
36 # will expect to find appropriate libraries in /lib and /libexec.
38 # We must do etc last for install/distribute to work.
40 SUBDIR= share/info include lib libexec bin
41 .if ${MK_GAMES} != "no"
45 .if ${MK_KERBEROS} != "no"
48 .if ${MK_RESCUE} != "no"
52 .if ${MK_CRYPT} != "no"
55 .if !defined(NO_SHARE)
58 SUBDIR+=sys usr.bin usr.sbin etc
60 # These are last, since it is nice to at least get the base system
61 # rebuilt before you do them.
62 .for _DIR in ${LOCAL_DIRS}
63 .if exists(${.CURDIR}/${_DIR}/Makefile)
68 .if defined(SUBDIR_OVERRIDE)
69 SUBDIR= ${SUBDIR_OVERRIDE}
75 .if defined(NO_CLEANDIR)
76 CLEANDIR= clean cleandepend
82 CVSFLAGS?= -A -P -d -I!
86 SUPFLAGS+= -h ${SUPHOST}
89 MAKEOBJDIRPREFIX?= /usr/obj
90 .if !defined(OSRELDATE)
91 .if exists(/usr/include/osreldate.h)
92 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
93 /usr/include/osreldate.h
98 TARGET_ARCH?= ${MACHINE_ARCH}
99 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
101 TARGET_CPUTYPE?=${CPUTYPE}
103 TARGET?= ${TARGET_ARCH}
106 .if !empty(TARGET_CPUTYPE)
107 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
109 _TARGET_CPUTYPE=dummy
111 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
112 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
113 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
114 .error CPUTYPE global should be set with ?=.
117 BUILD_ARCH!= uname -p
118 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
119 .error To cross-build, set TARGET_ARCH.
122 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
123 OBJTREE= ${MAKEOBJDIRPREFIX}
125 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
127 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
128 # /usr/games added for fortune which depend on strfile
129 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
130 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
131 STRICTTMPPATH= ${BPATH}:${XPATH}
132 TMPPATH= ${STRICTTMPPATH}:${PATH}
134 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
137 # Building a world goes through the following stages
139 # 1. legacy stage [BMAKE]
140 # This stage is responsible for creating compatibility
141 # shims that are needed by the bootstrap-tools,
142 # build-tools and cross-tools stages.
143 # 1. bootstrap-tools stage [BMAKE]
144 # This stage is responsible for creating programs that
145 # are needed for backward compatibility reasons. They
146 # are not built as cross-tools.
147 # 2. build-tools stage [TMAKE]
148 # This stage is responsible for creating the object
149 # tree and building any tools that are needed during
151 # 3. cross-tools stage [XMAKE]
152 # This stage is responsible for creating any tools that
153 # are needed for cross-builds. A cross-compiler is one
155 # 4. world stage [WMAKE]
156 # This stage actually builds the world.
157 # 5. install stage (optional) [IMAKE]
158 # This stage installs a previously built world.
163 # Common environment for world related stages
164 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
165 MACHINE_ARCH=${TARGET_ARCH} \
167 CPUTYPE=${TARGET_CPUTYPE} \
168 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
169 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
170 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
172 # bootstrap-tools stage
173 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
174 PATH=${BPATH}:${PATH} \
175 WORLDTMP=${WORLDTMP} \
176 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
177 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
178 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
180 BOOTSTRAPPING=${OSRELDATE} \
181 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
182 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
183 -DNO_CPU_CFLAGS -DNO_WARNS
186 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
187 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
189 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
192 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
193 -DWITHOUT_FORTRAN -DWITHOUT_GDB
196 WMAKEENV= ${CROSSENV} \
197 _SHLIBDIRPREFIX=${WORLDTMP} \
198 INSTALL="sh ${.CURDIR}/tools/install.sh" \
200 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
202 .if ${TARGET_ARCH} == "amd64"
204 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
206 .if empty(TARGET_CPUTYPE)
209 LIB32CPUTYPE= ${TARGET_CPUTYPE}
211 LIB32PREFLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
212 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
213 -L${LIB32TMP}/usr/lib32 \
214 -B${LIB32TMP}/usr/lib32
215 LIB32CC= ${LIB32PREFLAGS} \
217 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
219 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
222 # Yes, the flags are redundant.
223 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
224 _SHLIBDIRPREFIX=${LIB32TMP} \
227 INSTALL="sh ${.CURDIR}/tools/install.sh" \
229 CC="${CC} ${LIB32CC}" \
230 CXX="${CXX} ${LIB32CXX}" \
231 OBJC="${OBJC} ${LIB32OBJC}" \
232 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
237 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
238 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
240 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*} -DNO_INCS
244 .if empty(.MAKEFLAGS:M-n)
245 IMAKEENV= ${CROSSENV} \
246 PATH=${STRICTTMPPATH}:${INSTALLTMP}
248 IMAKEENV= ${CROSSENV} \
249 PATH=${TMPPATH}:${INSTALLTMP}
251 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
254 KMAKEENV= ${WMAKEENV}
255 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
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(NO_CLEAN)
278 .if ${TARGET_ARCH} == "amd64"
282 rm -rf ${WORLDTMP}/legacy/usr/include
283 # XXX - These two can depend on any header file.
284 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
285 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
288 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
289 usr/libexec usr/sbin usr/share/dict \
290 usr/share/groff_font/devX100 \
291 usr/share/groff_font/devX100-12 \
292 usr/share/groff_font/devX75 \
293 usr/share/groff_font/devX75-12 \
294 usr/share/groff_font/devascii \
295 usr/share/groff_font/devcp1047 \
296 usr/share/groff_font/devdvi \
297 usr/share/groff_font/devhtml \
298 usr/share/groff_font/devkoi8-r \
299 usr/share/groff_font/devlatin1 \
300 usr/share/groff_font/devlbp \
301 usr/share/groff_font/devlj4 \
302 usr/share/groff_font/devps \
303 usr/share/groff_font/devutf8 \
304 usr/share/tmac/mdoc usr/share/tmac/mm
305 mkdir -p ${WORLDTMP}/legacy/${_dir}
308 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
309 usr/libexec usr/sbin usr/share/misc \
310 usr/share/snmp/defs usr/share/snmp/mibs
311 mkdir -p ${WORLDTMP}/${_dir}
313 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
314 -p ${WORLDTMP}/usr/include >/dev/null
315 ln -sf ${.CURDIR}/sys ${WORLDTMP}
316 .if ${MK_BIND_LIBS} != "no"
317 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
318 -p ${WORLDTMP}/usr/include >/dev/null
322 @echo "--------------------------------------------------------------"
323 @echo ">>> stage 1.1: legacy release compatibility shims"
324 @echo "--------------------------------------------------------------"
325 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
328 @echo "--------------------------------------------------------------"
329 @echo ">>> stage 1.2: bootstrap tools"
330 @echo "--------------------------------------------------------------"
331 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
333 .if !defined(NO_CLEAN)
335 @echo "--------------------------------------------------------------"
336 @echo ">>> stage 2.1: cleaning up the object tree"
337 @echo "--------------------------------------------------------------"
338 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
339 .if ${TARGET_ARCH} == "amd64"
340 rm -rf ${OBJTREE}/lib32
345 @echo "--------------------------------------------------------------"
346 @echo ">>> stage 2.2: rebuilding the object tree"
347 @echo "--------------------------------------------------------------"
348 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
351 @echo "--------------------------------------------------------------"
352 @echo ">>> stage 2.3: build tools"
353 @echo "--------------------------------------------------------------"
354 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
357 @echo "--------------------------------------------------------------"
358 @echo ">>> stage 3: cross tools"
359 @echo "--------------------------------------------------------------"
360 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
363 @echo "--------------------------------------------------------------"
364 @echo ">>> stage 4.1: building includes"
365 @echo "--------------------------------------------------------------"
366 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 4.2: building libraries"
371 @echo "--------------------------------------------------------------"
372 ${_+_}cd ${.CURDIR}; \
373 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
374 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
377 @echo "--------------------------------------------------------------"
378 @echo ">>> stage 4.3: make dependencies"
379 @echo "--------------------------------------------------------------"
380 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
383 @echo "--------------------------------------------------------------"
384 @echo ">>> stage 4.4: building everything"
385 @echo "--------------------------------------------------------------"
386 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
387 .if ${TARGET_ARCH} == "amd64"
390 @echo "--------------------------------------------------------------"
391 @echo ">>> stage 5.1: building 32 bit shim libraries"
392 @echo "--------------------------------------------------------------"
394 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
395 usr/libexec usr/sbin usr/share/misc \
396 usr/share/snmp/defs usr/share/snmp/mibs
397 mkdir -p ${LIB32TMP}/${_dir}
399 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
400 -p ${LIB32TMP}/usr/include >/dev/null
402 ln -sf ${.CURDIR}/sys ${WORLDTMP}
403 .if ${MK_KERBEROS} != "no"
404 .for _t in obj depend all
405 cd ${.CURDIR}/kerberos5/tools; \
406 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
409 .for _t in obj includes
410 cd ${.CURDIR}/include; \
411 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
413 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
414 cd ${.CURDIR}/gnu/lib; \
415 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416 .if ${MK_CRYPT} != "no"
417 cd ${.CURDIR}/secure/lib; \
418 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
420 .if ${MK_KERBEROS} != "no"
421 cd ${.CURDIR}/kerberos5/lib; \
422 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
425 .for _dir in usr.bin/lex/lib
426 cd ${.CURDIR}/${_dir}; \
427 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
429 .for _dir in lib/libncurses lib/libmagic
430 cd ${.CURDIR}/${_dir}; \
431 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
434 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
435 .for _t in obj depend all
436 cd ${.CURDIR}/libexec/rtld-elf; \
437 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
440 distribute32 install32:
441 .if make(distribute32)
442 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
444 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
446 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
447 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
448 .if ${MK_CRYPT} != "no"
449 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
451 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
456 .if !defined(SUBDIR_OVERRIDE)
457 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
459 WMAKE_TGTS+= _cleanobj _obj _build-tools
460 .if !defined(SUBDIR_OVERRIDE)
461 WMAKE_TGTS+= _cross-tools
463 WMAKE_TGTS+= _includes _libraries _depend everything
464 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
468 buildworld: ${WMAKE_TGTS}
469 .ORDER: ${WMAKE_TGTS}
473 # We need to have this as a target because the indirection between Makefile
474 # and Makefile.inc1 causes the correct PATH to be used, rather than a
475 # modification of the current environment's PATH.
481 @echo Entering world for ${TARGET_ARCH}:${TARGET}
482 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
484 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
485 toolchain: ${TOOLCHAIN_TGTS}
486 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
491 # Checks to be sure system is ready for installworld/installkernel.
496 # Require DESTDIR to be set if installing for a different architecture.
498 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
499 .if !make(distributeworld)
500 installcheck: installcheck_DESTDIR
501 installcheck_DESTDIR:
502 .if !defined(DESTDIR) || empty(DESTDIR)
503 @echo "ERROR: Please set DESTDIR!"; \
510 # Check for missing UIDs/GIDs.
514 .if ${MK_SENDMAIL} != "no"
520 CHECK_GIDS+= proxy authpf
522 installcheck: installcheck_UGID
524 .for uid in ${CHECK_UIDS}
525 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
526 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
530 .for gid in ${CHECK_GIDS}
531 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
532 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
540 # Distributes everything compiled by a `buildworld'.
544 # Installs everything compiled by a 'buildworld'.
546 distributeworld installworld: installcheck
547 mkdir -p ${INSTALLTMP}
548 for prog in [ awk cap_mkdb cat chflags chmod chown \
549 date echo egrep find grep install-info \
550 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
551 test true uname wc zic; do \
552 cp `which $$prog` ${INSTALLTMP}; \
554 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
560 # If you have a build server, you can NFS mount the source and obj directories
561 # and do a 'make reinstall' on the *client* to install new binaries from the
562 # most recent server build.
565 @echo "--------------------------------------------------------------"
566 @echo ">>> Making hierarchy"
567 @echo "--------------------------------------------------------------"
568 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
570 @echo "--------------------------------------------------------------"
571 @echo ">>> Installing everything"
572 @echo "--------------------------------------------------------------"
573 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
574 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
575 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
579 @echo "--------------------------------------------------------------"
580 @echo ">>> Distributing everything"
581 @echo "--------------------------------------------------------------"
582 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
583 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
584 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
587 distrib-dirs distribution:
588 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
591 # buildkernel and installkernel
593 # Which kernels to build and/or install is specified by setting
594 # KERNCONF. If not defined a GENERIC kernel is built/installed.
595 # Only the existing (depending TARGET) config files are used
596 # for building kernels and only the first of these is designated
597 # as the one being installed.
599 # Note that we have to use TARGET instead of TARGET_ARCH when
600 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
601 # be set to cross-build, we have to make sure TARGET is set
604 .if !defined(KERNCONF) && defined(KERNEL)
610 INSTKERNNAME?= kernel
612 KERNSRCDIR?= ${.CURDIR}/sys
613 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
614 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
615 KERNCONFDIR?= ${KRNLCONFDIR}
619 .for _kernel in ${KERNCONF}
620 .if exists(${KERNCONFDIR}/${_kernel})
621 BUILDKERNELS+= ${_kernel}
622 .if empty(INSTALLKERNEL)
623 INSTALLKERNEL= ${_kernel}
631 # Builds all kernels defined by BUILDKERNELS.
634 .if empty(BUILDKERNELS)
635 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
638 .if defined(KERNWARN)
639 @echo "--------------------------------------------------------------"
640 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
641 @echo "--------------------------------------------------------------"
645 .for _kernel in ${BUILDKERNELS}
646 @echo "--------------------------------------------------------------"
647 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
648 @echo "--------------------------------------------------------------"
649 @echo "===> ${_kernel}"
650 mkdir -p ${KRNLOBJDIR}
651 .if !defined(NO_KERNELCONFIG)
653 @echo "--------------------------------------------------------------"
654 @echo ">>> stage 1: configuring the kernel"
655 @echo "--------------------------------------------------------------"
658 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
659 ${KERNCONFDIR}/${_kernel}
661 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
663 @echo "--------------------------------------------------------------"
664 @echo ">>> stage 2.1: cleaning up the object tree"
665 @echo "--------------------------------------------------------------"
666 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
669 @echo "--------------------------------------------------------------"
670 @echo ">>> stage 2.2: rebuilding the object tree"
671 @echo "--------------------------------------------------------------"
672 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
674 @echo "--------------------------------------------------------------"
675 @echo ">>> stage 2.3: build tools"
676 @echo "--------------------------------------------------------------"
677 cd ${KRNLOBJDIR}/${_kernel}; \
678 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
679 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
680 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
681 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
682 .for target in obj depend all
683 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
684 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
685 ${MAKE} -DNO_CPU_CFLAGS ${target}
688 .if !defined(NO_KERNELDEPEND)
690 @echo "--------------------------------------------------------------"
691 @echo ">>> stage 3.1: making dependencies"
692 @echo "--------------------------------------------------------------"
693 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
696 @echo "--------------------------------------------------------------"
697 @echo ">>> stage 3.2: building everything"
698 @echo "--------------------------------------------------------------"
699 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
700 @echo "--------------------------------------------------------------"
701 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
702 @echo "--------------------------------------------------------------"
706 # installkernel, etc.
708 # Install the kernel defined by INSTALLKERNEL
710 installkernel installkernel.debug \
711 reinstallkernel reinstallkernel.debug: installcheck
712 .if empty(INSTALLKERNEL)
713 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
716 @echo "--------------------------------------------------------------"
717 @echo ">>> Installing kernel"
718 @echo "--------------------------------------------------------------"
719 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
720 ${CROSSENV} PATH=${TMPPATH} \
721 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
726 # Build the API documentation with doxygen
729 @if [ ! -x `/usr/bin/which doxygen` ]; then \
730 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
733 cd ${.CURDIR}/sys/doc/subsys && ${MAKE} obj all
738 # Update the source tree, by running cvsup and/or running cvs to update to the
742 .if defined(SUP_UPDATE)
743 @echo "--------------------------------------------------------------"
744 @echo ">>> Running ${SUP}"
745 @echo "--------------------------------------------------------------"
747 @${SUP} ${SUPFLAGS} ${SUPFILE}
749 .if defined(SUPFILE1)
750 @${SUP} ${SUPFLAGS} ${SUPFILE1}
752 .if defined(SUPFILE2)
753 @${SUP} ${SUPFLAGS} ${SUPFILE2}
755 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
756 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
758 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
759 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
762 .if defined(CVS_UPDATE)
763 @echo "--------------------------------------------------------------"
764 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
765 @echo "--------------------------------------------------------------"
766 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
770 # ------------------------------------------------------------------------
772 # From here onwards are utility targets used by the 'make world' and
773 # related targets. If your 'world' breaks, you may like to try to fix
774 # the problem and manually run the following targets to attempt to
775 # complete the build. Beware, this is *not* guaranteed to work, you
776 # need to have a pretty good grip on the current state of the system
777 # to attempt to manually finish it. If in doubt, 'make world' again.
781 # legacy: Build compatibility shims for the next three targets
784 .if ${BOOTSTRAPPING} < 503000
785 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
788 .for _tool in tools/build
789 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
790 cd ${.CURDIR}/${_tool}; \
791 ${MAKE} DIRPRFX=${_tool}/ obj; \
792 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
793 ${MAKE} DIRPRFX=${_tool}/ depend; \
794 ${MAKE} DIRPRFX=${_tool}/ all; \
795 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
799 # bootstrap-tools: Build tools needed for compatibility
801 .if ${MK_GAMES} != "no"
802 _strfile= games/fortune/strfile
805 .if ${MK_CXX} != "no"
806 _gperf= gnu/usr.bin/gperf
807 .if ${BOOTSTRAPPING} < 700004
808 _groff= gnu/usr.bin/groff
810 _groff= gnu/usr.bin/groff/tmac
814 .if ${BOOTSTRAPPING} < 600029
815 _texinfo= gnu/usr.bin/texinfo
818 .if ${BOOTSTRAPPING} < 600015
819 _cap_mkdb= usr.bin/cap_mkdb
822 .if ${BOOTSTRAPPING} < 600018
823 _colldef= usr.bin/colldef
826 .if ${BOOTSTRAPPING} < 600017
827 _gencat= usr.bin/gencat
830 .if ${BOOTSTRAPPING} < 600016
831 _mklocale= usr.bin/mklocale
834 .if ${BOOTSTRAPPING} < 700015
835 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
838 .if ${MK_RESCUE} != "no" && \
839 ${BOOTSTRAPPING} < 600008
840 _crunchgen= usr.sbin/crunch/crunchgen
843 .if ${BOOTSTRAPPING} < 600020
844 _pwd_mkdb= usr.sbin/pwd_mkdb
865 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
866 cd ${.CURDIR}/${_tool}; \
867 ${MAKE} DIRPRFX=${_tool}/ obj; \
868 ${MAKE} DIRPRFX=${_tool}/ depend; \
869 ${MAKE} DIRPRFX=${_tool}/ all; \
870 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
874 # build-tools: Build special purpose build tools
876 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
877 _aicasm= sys/modules/aic7xxx/aicasm
880 .if !defined(NO_SHARE)
881 _share= share/syscons/scrnmaps
884 .if ${MK_KERBEROS} != "no"
885 _kerberos5_tools= kerberos5/tools
888 .if ${MK_RESCUE} != "no"
889 _rescue= rescue/rescue
903 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
904 cd ${.CURDIR}/${_tool}; \
905 ${MAKE} DIRPRFX=${_tool}/ obj; \
906 ${MAKE} DIRPRFX=${_tool}/ build-tools
909 gnu/usr.bin/cc/cc_tools \
911 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
912 cd ${.CURDIR}/${_tool}; \
913 ${MAKE} DIRPRFX=${_tool}/ obj; \
914 ${MAKE} DIRPRFX=${_tool}/ depend; \
915 ${MAKE} DIRPRFX=${_tool}/ all
919 # cross-tools: Build cross-building tools
921 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
922 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
923 _btxld= usr.sbin/btxld
925 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
926 _crunchide= usr.sbin/crunch/crunchide
928 .if ${TARGET_ARCH} == "alpha"
929 _elf2exe= usr.sbin/elf2exe
931 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
932 _kgzip= usr.sbin/kgzip
938 gnu/usr.bin/binutils \
940 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
945 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
946 cd ${.CURDIR}/${_tool}; \
947 ${MAKE} DIRPRFX=${_tool}/ obj; \
948 ${MAKE} DIRPRFX=${_tool}/ depend; \
949 ${MAKE} DIRPRFX=${_tool}/ all; \
950 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
954 # hierarchy - ensure that all the needed directories are present
957 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
960 # libraries - build all libraries, and install them under ${DESTDIR}.
962 # The list of libraries with dependents (${_prebuild_libs}) and their
963 # interdependencies (__L) are built automatically by the
964 # ${.CURDIR}/tools/make_libdeps.sh script.
968 ${MAKE} -f Makefile.inc1 _startup_libs; \
969 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
970 ${MAKE} -f Makefile.inc1 _generic_libs;
972 # These dependencies are not automatically generated:
974 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
975 # shared libraries for ELF.
977 _startup_libs= gnu/lib/csu gnu/lib/libgcc
978 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
979 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
981 _startup_libs+= lib/csu/${MACHINE_ARCH}
986 _generic_libs= gnu/lib
988 .if ${MK_IPX} != "no"
989 _prebuild_libs+= lib/libipx
992 .if ${MK_KERBEROS} != "no"
993 _prebuild_libs+= kerberos5/lib/libasn1
994 _prebuild_libs+= kerberos5/lib/libkrb5
995 _prebuild_libs+= kerberos5/lib/libroken
996 _generic_libs+= kerberos5/lib
999 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1000 lib/libkiconv lib/libkvm lib/libmd \
1001 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1003 lib/libsbuf lib/libtacplus lib/libutil \
1004 lib/libz lib/msun lib/libgssapi
1006 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1010 .if ${MK_CRYPT} != "no"
1011 .if ${MK_OPENSSL} != "no"
1012 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
1013 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1014 .if ${MK_OPENSSH} != "no"
1015 _prebuild_libs+= secure/lib/libssh
1016 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1017 .if ${MK_KERBEROS} != "no"
1018 secure/lib/libssh__L: lib/libgssapi__L
1022 _generic_libs+= secure/lib
1025 .if ${MK_OPENSSL} == "no"
1026 lib/libradius__L: lib/libmd__L
1029 .if ${MK_NIS} != "no"
1030 _prebuild_libs+= lib/libypclnt
1033 _generic_libs+= usr.bin/lex/lib
1035 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1037 .if exists(${.CURDIR}/${_lib})
1038 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1039 cd ${.CURDIR}/${_lib}; \
1040 ${MAKE} DIRPRFX=${_lib}/ depend; \
1041 ${MAKE} DIRPRFX=${_lib}/ all; \
1042 ${MAKE} DIRPRFX=${_lib}/ install
1046 # libpam is special: we need to build static PAM modules before
1047 # static PAM library, and dynamic PAM library before dynamic PAM
1049 lib/libpam__L: .PHONY
1050 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1051 cd ${.CURDIR}/lib/libpam; \
1052 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1053 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1054 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1056 _startup_libs: ${_startup_libs:S/$/__L/}
1057 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1058 _generic_libs: ${_generic_libs:S/$/__L/}
1060 .for __target in all clean cleandepend cleandir depend includes obj
1061 .for entry in ${SUBDIR}
1062 ${entry}.${__target}__D: .PHONY
1063 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1064 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1065 edir=${entry}.${MACHINE_ARCH}; \
1066 cd ${.CURDIR}/$${edir}; \
1068 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1070 cd ${.CURDIR}/$${edir}; \
1072 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1074 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1077 .include <bsd.subdir.mk>
1079 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1082 # check for / delete old files section
1085 .include "ObsoleteFiles.inc"
1087 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1088 else you can not start such an application. Consult UPDATING for more \
1089 information regarding how to cope with the removal/revision bump of a \
1092 .if !defined(BATCH_DELETE_OLD_FILES)
1099 @echo ">>> Removing old files (only deletes safe to delete libs)"
1100 .for file in ${OLD_FILES}
1101 # Ask for every old file if the user really wants to remove it.
1102 # It's annoying, but better safe than sorry.
1103 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1104 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1105 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1106 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1107 chflags noschg "${DESTDIR}/${file}"; \
1108 rm ${RM_I} "${DESTDIR}/${file}"; \
1112 # Remove catpages without corresponding manpages.
1114 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1115 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1116 while read catpage; do \
1118 if [ ! -e "$${manpage}" ]; then \
1119 rm ${RM_I} $${catpage} <&3 ; \
1122 @echo ">>> Old files removed"
1125 @echo ">>> Checking for old files"
1126 .for file in ${OLD_FILES}
1127 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1128 echo "${DESTDIR}/${file}"; \
1131 # Check for catpages without corresponding manpages.
1132 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1133 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1134 while read catpage; do \
1136 if [ ! -e "$${manpage}" ]; then \
1137 echo $${catpage} ; \
1142 @echo ">>> Removing old libraries"
1143 @echo "${OLD_LIBS_MESSAGE}" | fmt
1144 .for file in ${OLD_LIBS}
1145 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1146 rm ${RM_I} "${DESTDIR}/${file}" || true; \
1147 if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1148 echo "Removing schg flag on ${DESTDIR}/${file}"; \
1149 chflags noschg "${DESTDIR}/${file}"; \
1150 rm ${RM_I} "${DESTDIR}/${file}"; \
1154 @echo ">>> Old libraries removed"
1157 @echo ">>> Checking for old libraries"
1158 .for file in ${OLD_LIBS}
1159 @if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1160 echo "${DESTDIR}/${file}"; \
1165 @echo ">>> Removing old directories"
1166 .for dir in ${OLD_DIRS}
1167 # Don't fail if an old directory isn't empty.
1168 @if [ -d "${DESTDIR}/${dir}" ]; then \
1169 rmdir -v "${DESTDIR}/${dir}" || true; \
1171 if [ -L "${DESTDIR}/${dir}" ]; then \
1172 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1176 @echo ">>> Old directories removed"
1179 @echo ">>> Checking for old directories"
1180 .for dir in ${OLD_DIRS}
1181 @if [ -d "${DESTDIR}/${dir}" ]; then \
1182 echo "${DESTDIR}/${dir}"; \
1184 if [ -L "${DESTDIR}/${dir}" ]; then \
1185 echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1190 delete-old: delete-old-files delete-old-dirs
1191 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1193 check-old: check-old-files check-old-libs check-old-dirs
1194 @echo "To remove old files and directories run '${MAKE} delete-old'."
1195 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1200 # showconfig - show build configuration.
1203 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort