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="machine" to crossbuild world for a different machine type
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 SUBDIR= share/info lib libexec
40 .if ${MK_GAMES} != "no"
43 .if ${MK_CDDL} != "no"
47 .if ${MK_KERBEROS} != "no"
50 .if ${MK_RESCUE} != "no"
54 .if ${MK_CRYPT} != "no"
57 .if !defined(NO_SHARE)
60 SUBDIR+=sys usr.bin usr.sbin
62 # We must do etc/ last for install/distribute to work.
66 # These are last, since it is nice to at least get the base system
67 # rebuilt before you do them.
68 .for _DIR in ${LOCAL_DIRS}
69 .if exists(${.CURDIR}/${_DIR}/Makefile)
74 .if defined(SUBDIR_OVERRIDE)
75 SUBDIR= ${SUBDIR_OVERRIDE}
81 .if defined(NO_CLEANDIR)
82 CLEANDIR= clean cleandepend
88 CVSFLAGS?= -A -P -d -I!
92 SUPFLAGS+= -h ${SUPHOST}
95 MAKEOBJDIRPREFIX?= /usr/obj
96 .if !defined(OSRELDATE)
97 .if exists(/usr/include/osreldate.h)
98 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
99 /usr/include/osreldate.h
105 # Guess machine architecture from machine type, and vice versa.
106 .if !defined(TARGET_ARCH) && defined(TARGET)
107 TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
108 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
109 ${TARGET_ARCH} != ${MACHINE_ARCH}
110 TARGET= ${TARGET_ARCH}
112 # Otherwise, default to current machine type and architecture.
114 TARGET_ARCH?= ${MACHINE_ARCH}
116 KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
117 .if ${TARGET} == ${TARGET_ARCH}
120 _t= ${TARGET_ARCH}/${TARGET}
123 .if empty(KNOWN_ARCHES:M${_t})
124 .error Unknown target ${TARGET_ARCH}:${TARGET}.
128 .if ${TARGET} == ${MACHINE}
129 TARGET_CPUTYPE?=${CPUTYPE}
134 .if !empty(TARGET_CPUTYPE)
135 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
137 _TARGET_CPUTYPE=dummy
139 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
140 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
141 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
142 .error CPUTYPE global should be set with ?=.
145 BUILD_ARCH!= uname -p
146 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
147 .error To cross-build, set TARGET_ARCH.
150 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
151 OBJTREE= ${MAKEOBJDIRPREFIX}
153 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
155 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
156 # /usr/games added for fortune which depend on strfile
157 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
158 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
159 STRICTTMPPATH= ${BPATH}:${XPATH}
160 TMPPATH= ${STRICTTMPPATH}:${PATH}
163 # Avoid running mktemp(1) unless actually needed.
164 # It may not be functional, e.g., due to new ABI
165 # when in the middle of installing over this system.
167 .if make(distributeworld) || make(installworld)
168 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
172 # Building a world goes through the following stages
174 # 1. legacy stage [BMAKE]
175 # This stage is responsible for creating compatibility
176 # shims that are needed by the bootstrap-tools,
177 # build-tools and cross-tools stages.
178 # 1. bootstrap-tools stage [BMAKE]
179 # This stage is responsible for creating programs that
180 # are needed for backward compatibility reasons. They
181 # are not built as cross-tools.
182 # 2. build-tools stage [TMAKE]
183 # This stage is responsible for creating the object
184 # tree and building any tools that are needed during
186 # 3. cross-tools stage [XMAKE]
187 # This stage is responsible for creating any tools that
188 # are needed for cross-builds. A cross-compiler is one
190 # 4. world stage [WMAKE]
191 # This stage actually builds the world.
192 # 5. install stage (optional) [IMAKE]
193 # This stage installs a previously built world.
198 # Common environment for world related stages
199 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
200 MACHINE_ARCH=${TARGET_ARCH} \
202 CPUTYPE=${TARGET_CPUTYPE} \
203 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
204 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
205 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
206 .if ${OSRELDATE} < 700044
207 CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib
210 # bootstrap-tools stage
211 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
212 PATH=${BPATH}:${PATH} \
213 WORLDTMP=${WORLDTMP} \
214 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
215 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
216 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
218 BOOTSTRAPPING=${OSRELDATE} \
219 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
220 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
221 -DNO_CPU_CFLAGS -DNO_WARNS
224 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
225 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
226 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
228 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
231 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
232 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
236 WMAKEENV= ${CROSSENV} \
237 _SHLIBDIRPREFIX=${WORLDTMP} \
238 INSTALL="sh ${.CURDIR}/tools/install.sh" \
240 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
242 .if ${TARGET_ARCH} == "amd64"
244 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
246 .if empty(TARGET_CPUTYPE)
249 LIB32CPUTYPE= ${TARGET_CPUTYPE}
251 LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
252 -iprefix ${LIB32TMP}/usr/ \
253 -L${LIB32TMP}/usr/lib32 \
254 -B${LIB32TMP}/usr/lib32
256 # Yes, the flags are redundant.
257 LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
258 _SHLIBDIRPREFIX=${LIB32TMP} \
261 INSTALL="sh ${.CURDIR}/tools/install.sh" \
263 CC="${CC} ${LIB32FLAGS}" \
264 CXX="${CXX} ${LIB32FLAGS}" \
265 OBJC="${OBJC} ${LIB32FLAGS}" \
266 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
271 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
272 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
273 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
274 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
278 IMAKEENV= ${CROSSENV}
279 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
280 .if empty(.MAKEFLAGS:M-n)
281 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
282 LD_LIBRARY_PATH=${INSTALLTMP} \
283 PATH_LOCALE=${INSTALLTMP}/locale
284 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
286 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
290 KMAKEENV= ${WMAKEENV}
291 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
296 # Attempt to rebuild the entire system, with reasonable chance of
297 # success, regardless of how old your existing system is.
300 .if ${.CURDIR:C/[^,]//g} != ""
301 # The m4 build of sendmail files doesn't like it if ',' is used
302 # anywhere in the path of it's files.
304 @echo "*** Error: path to source tree contains a comma ','"
309 @echo "--------------------------------------------------------------"
310 @echo ">>> Rebuilding the temporary build tree"
311 @echo "--------------------------------------------------------------"
312 .if !defined(NO_CLEAN)
314 .if ${TARGET_ARCH} == "amd64"
318 rm -rf ${WORLDTMP}/legacy/usr/include
319 # XXX - These three can depend on any header file.
320 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
321 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
322 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
325 usr/bin usr/games usr/include/sys usr/lib \
326 usr/libexec usr/sbin usr/share/dict \
327 usr/share/groff_font/devX100 \
328 usr/share/groff_font/devX100-12 \
329 usr/share/groff_font/devX75 \
330 usr/share/groff_font/devX75-12 \
331 usr/share/groff_font/devascii \
332 usr/share/groff_font/devcp1047 \
333 usr/share/groff_font/devdvi \
334 usr/share/groff_font/devhtml \
335 usr/share/groff_font/devkoi8-r \
336 usr/share/groff_font/devlatin1 \
337 usr/share/groff_font/devlbp \
338 usr/share/groff_font/devlj4 \
339 usr/share/groff_font/devps \
340 usr/share/groff_font/devutf8 \
341 usr/share/tmac/mdoc usr/share/tmac/mm
342 mkdir -p ${WORLDTMP}/legacy/${_dir}
345 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
346 usr/libexec usr/sbin usr/share/misc
347 mkdir -p ${WORLDTMP}/${_dir}
349 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
350 -p ${WORLDTMP}/usr/include >/dev/null
351 ln -sf ${.CURDIR}/sys ${WORLDTMP}
352 .if ${MK_BIND_LIBS} != "no"
353 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
354 -p ${WORLDTMP}/usr/include >/dev/null
358 @echo "--------------------------------------------------------------"
359 @echo ">>> stage 1.1: legacy release compatibility shims"
360 @echo "--------------------------------------------------------------"
361 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
364 @echo "--------------------------------------------------------------"
365 @echo ">>> stage 1.2: bootstrap tools"
366 @echo "--------------------------------------------------------------"
367 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
369 .if !defined(NO_CLEAN)
371 @echo "--------------------------------------------------------------"
372 @echo ">>> stage 2.1: cleaning up the object tree"
373 @echo "--------------------------------------------------------------"
374 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
375 .if ${TARGET_ARCH} == "amd64"
376 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
381 @echo "--------------------------------------------------------------"
382 @echo ">>> stage 2.2: rebuilding the object tree"
383 @echo "--------------------------------------------------------------"
384 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
387 @echo "--------------------------------------------------------------"
388 @echo ">>> stage 2.3: build tools"
389 @echo "--------------------------------------------------------------"
390 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 3: cross tools"
395 @echo "--------------------------------------------------------------"
396 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
399 @echo "--------------------------------------------------------------"
400 @echo ">>> stage 4.1: building includes"
401 @echo "--------------------------------------------------------------"
402 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
405 @echo "--------------------------------------------------------------"
406 @echo ">>> stage 4.2: building libraries"
407 @echo "--------------------------------------------------------------"
408 ${_+_}cd ${.CURDIR}; \
409 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
410 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
413 @echo "--------------------------------------------------------------"
414 @echo ">>> stage 4.3: make dependencies"
415 @echo "--------------------------------------------------------------"
416 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
419 @echo "--------------------------------------------------------------"
420 @echo ">>> stage 4.4: building everything"
421 @echo "--------------------------------------------------------------"
422 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
423 .if ${TARGET_ARCH} == "amd64"
426 @echo "--------------------------------------------------------------"
427 @echo ">>> stage 5.1: building 32 bit shim libraries"
428 @echo "--------------------------------------------------------------"
430 usr/include usr/lib32 usr/share/misc
431 mkdir -p ${LIB32TMP}/${_dir}
433 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
434 -p ${LIB32TMP}/usr/include >/dev/null
436 ln -sf ${.CURDIR}/sys ${WORLDTMP}
437 .if ${MK_KERBEROS} != "no"
438 .for _t in obj depend all
439 cd ${.CURDIR}/kerberos5/tools; \
440 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
443 .for _t in obj includes
444 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
445 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
446 .if ${MK_CDDL} != "no"
447 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
449 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
450 .if ${MK_CRYPT} != "no"
451 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
453 .if ${MK_KERBEROS} != "no"
454 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
457 .for _dir in usr.bin/lex/lib
458 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
460 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
461 cd ${.CURDIR}/${_dir}; \
462 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
465 ${LIB32WMAKE} -f Makefile.inc1 libraries
466 .for _t in obj depend all
467 cd ${.CURDIR}/libexec/rtld-elf; \
468 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
471 distribute32 install32:
472 .if make(distribute32)
473 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
475 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
477 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
478 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
479 .if ${MK_CRYPT} != "no"
480 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
482 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
487 .if !defined(SUBDIR_OVERRIDE)
488 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
490 WMAKE_TGTS+= _cleanobj _obj _build-tools
491 .if !defined(SUBDIR_OVERRIDE)
492 WMAKE_TGTS+= _cross-tools
494 WMAKE_TGTS+= _includes _libraries _depend everything
495 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
499 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
500 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
503 @echo "--------------------------------------------------------------"
504 @echo ">>> World build started on `LC_ALL=C date`"
505 @echo "--------------------------------------------------------------"
509 @echo "--------------------------------------------------------------"
510 @echo ">>> World build completed on `LC_ALL=C date`"
511 @echo "--------------------------------------------------------------"
514 # We need to have this as a target because the indirection between Makefile
515 # and Makefile.inc1 causes the correct PATH to be used, rather than a
516 # modification of the current environment's PATH. In addition, we need
517 # to quote multiword values.
523 @echo Entering world for ${TARGET_ARCH}:${TARGET}
524 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
526 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
527 toolchain: ${TOOLCHAIN_TGTS}
528 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
533 # Checks to be sure system is ready for installworld/installkernel.
538 # Require DESTDIR to be set if installing for a different architecture.
540 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
541 .if !make(distributeworld)
542 installcheck: installcheck_DESTDIR
543 installcheck_DESTDIR:
544 .if !defined(DESTDIR) || empty(DESTDIR)
545 @echo "ERROR: Please set DESTDIR!"; \
552 # Check for missing UIDs/GIDs.
556 .if ${MK_SENDMAIL} != "no"
562 CHECK_GIDS+= proxy authpf
564 installcheck: installcheck_UGID
566 .for uid in ${CHECK_UIDS}
567 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
568 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
572 .for gid in ${CHECK_GIDS}
573 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
574 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
580 # Required install tools to be saved in a scratch dir for safety.
582 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
583 date echo egrep find grep install-info \
584 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
585 test true uname wc zic
590 # Distributes everything compiled by a `buildworld'.
594 # Installs everything compiled by a 'buildworld'.
596 distributeworld installworld: installcheck
597 mkdir -p ${INSTALLTMP}
598 progs=$$(for prog in ${ITOOLS}; do \
599 if progpath=`which $$prog`; then \
602 echo "Required tool $$prog not found in PATH." >&2; \
606 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
607 while read line; do \
609 if [ "$$2 $$3" != "not found" ]; then \
612 echo "Required library $$1 not found." >&2; \
616 cp $$libs $$progs ${INSTALLTMP}
617 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
618 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
619 ${IMAKEENV} rm -rf ${INSTALLTMP}
624 # If you have a build server, you can NFS mount the source and obj directories
625 # and do a 'make reinstall' on the *client* to install new binaries from the
626 # most recent server build.
629 @echo "--------------------------------------------------------------"
630 @echo ">>> Making hierarchy"
631 @echo "--------------------------------------------------------------"
632 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
634 @echo "--------------------------------------------------------------"
635 @echo ">>> Installing everything"
636 @echo "--------------------------------------------------------------"
637 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
638 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
639 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
643 @echo "--------------------------------------------------------------"
644 @echo ">>> Distributing everything"
645 @echo "--------------------------------------------------------------"
646 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
647 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
648 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
651 distrib-dirs distribution:
652 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
655 # buildkernel and installkernel
657 # Which kernels to build and/or install is specified by setting
658 # KERNCONF. If not defined a GENERIC kernel is built/installed.
659 # Only the existing (depending TARGET) config files are used
660 # for building kernels and only the first of these is designated
661 # as the one being installed.
663 # Note that we have to use TARGET instead of TARGET_ARCH when
664 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
665 # be set to cross-build, we have to make sure TARGET is set
668 .if !defined(KERNCONF) && defined(KERNEL)
674 INSTKERNNAME?= kernel
676 KERNSRCDIR?= ${.CURDIR}/sys
677 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
678 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
679 KERNCONFDIR?= ${KRNLCONFDIR}
683 .for _kernel in ${KERNCONF}
684 .if exists(${KERNCONFDIR}/${_kernel})
685 BUILDKERNELS+= ${_kernel}
686 .if empty(INSTALLKERNEL)
687 INSTALLKERNEL= ${_kernel}
695 # Builds all kernels defined by BUILDKERNELS.
698 .if empty(BUILDKERNELS)
699 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
702 .if defined(KERNWARN)
703 @echo "--------------------------------------------------------------"
704 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
705 @echo "--------------------------------------------------------------"
709 .for _kernel in ${BUILDKERNELS}
710 @echo "--------------------------------------------------------------"
711 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
712 @echo "--------------------------------------------------------------"
713 @echo "===> ${_kernel}"
714 mkdir -p ${KRNLOBJDIR}
715 .if !defined(NO_KERNELCONFIG)
717 @echo "--------------------------------------------------------------"
718 @echo ">>> stage 1: configuring the kernel"
719 @echo "--------------------------------------------------------------"
722 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
723 ${KERNCONFDIR}/${_kernel}
725 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
727 @echo "--------------------------------------------------------------"
728 @echo ">>> stage 2.1: cleaning up the object tree"
729 @echo "--------------------------------------------------------------"
730 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
733 @echo "--------------------------------------------------------------"
734 @echo ">>> stage 2.2: rebuilding the object tree"
735 @echo "--------------------------------------------------------------"
736 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
738 @echo "--------------------------------------------------------------"
739 @echo ">>> stage 2.3: build tools"
740 @echo "--------------------------------------------------------------"
741 cd ${KRNLOBJDIR}/${_kernel}; \
742 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
743 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
744 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
745 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
746 .for target in obj depend all
747 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
748 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
749 ${MAKE} -DNO_CPU_CFLAGS ${target}
752 .if !defined(NO_KERNELDEPEND)
754 @echo "--------------------------------------------------------------"
755 @echo ">>> stage 3.1: making dependencies"
756 @echo "--------------------------------------------------------------"
757 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
760 @echo "--------------------------------------------------------------"
761 @echo ">>> stage 3.2: building everything"
762 @echo "--------------------------------------------------------------"
763 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
764 @echo "--------------------------------------------------------------"
765 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
766 @echo "--------------------------------------------------------------"
770 # installkernel, etc.
772 # Install the kernel defined by INSTALLKERNEL
774 installkernel installkernel.debug \
775 reinstallkernel reinstallkernel.debug: installcheck
776 .if empty(INSTALLKERNEL)
777 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
780 @echo "--------------------------------------------------------------"
781 @echo ">>> Installing kernel"
782 @echo "--------------------------------------------------------------"
783 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
784 ${CROSSENV} PATH=${TMPPATH} \
785 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
790 # Build the API documentation with doxygen
793 @if [ ! -x `/usr/bin/which doxygen` ]; then \
794 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
797 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
802 # Update the source tree, by running cvsup and/or running cvs to update to the
806 .if defined(SUP_UPDATE)
807 @echo "--------------------------------------------------------------"
808 @echo ">>> Running ${SUP}"
809 @echo "--------------------------------------------------------------"
811 @${SUP} ${SUPFLAGS} ${SUPFILE}
813 .if defined(SUPFILE1)
814 @${SUP} ${SUPFLAGS} ${SUPFILE1}
816 .if defined(SUPFILE2)
817 @${SUP} ${SUPFLAGS} ${SUPFILE2}
819 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
820 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
822 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
823 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
826 .if defined(CVS_UPDATE)
827 @echo "--------------------------------------------------------------"
828 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
829 @echo "--------------------------------------------------------------"
830 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
834 # ------------------------------------------------------------------------
836 # From here onwards are utility targets used by the 'make world' and
837 # related targets. If your 'world' breaks, you may like to try to fix
838 # the problem and manually run the following targets to attempt to
839 # complete the build. Beware, this is *not* guaranteed to work, you
840 # need to have a pretty good grip on the current state of the system
841 # to attempt to manually finish it. If in doubt, 'make world' again.
845 # legacy: Build compatibility shims for the next three targets
848 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
849 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
852 .for _tool in tools/build
853 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
854 cd ${.CURDIR}/${_tool}; \
855 ${MAKE} DIRPRFX=${_tool}/ obj; \
856 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
857 ${MAKE} DIRPRFX=${_tool}/ depend; \
858 ${MAKE} DIRPRFX=${_tool}/ all; \
859 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
863 # bootstrap-tools: Build tools needed for compatibility
865 .if ${MK_GAMES} != "no"
866 _strfile= games/fortune/strfile
869 .if ${MK_CXX} != "no"
870 _gperf= gnu/usr.bin/gperf
871 .if ${BOOTSTRAPPING} < 700004
872 _groff= gnu/usr.bin/groff
874 _groff= gnu/usr.bin/groff/tmac
878 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
882 .if ${BOOTSTRAPPING} < 800013
883 _mklocale= usr.bin/mklocale
886 .if ${BOOTSTRAPPING} < 700018
887 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
890 .if ${MK_RESCUE} != "no" && \
891 ${BOOTSTRAPPING} < 700026
892 _crunchgen= usr.sbin/crunch/crunchgen
909 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
910 cd ${.CURDIR}/${_tool}; \
911 ${MAKE} DIRPRFX=${_tool}/ obj; \
912 ${MAKE} DIRPRFX=${_tool}/ depend; \
913 ${MAKE} DIRPRFX=${_tool}/ all; \
914 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
918 # build-tools: Build special purpose build tools
920 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
921 _aicasm= sys/modules/aic7xxx/aicasm
924 .if !defined(NO_SHARE)
925 _share= share/syscons/scrnmaps
928 .if ${MK_KERBEROS} != "no"
929 _kerberos5_tools= kerberos5/tools
932 .if ${MK_RESCUE} != "no"
933 _rescue= rescue/rescue
941 lib/ncurses/ncurses \
942 lib/ncurses/ncursesw \
948 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
949 cd ${.CURDIR}/${_tool}; \
950 ${MAKE} DIRPRFX=${_tool}/ obj; \
951 ${MAKE} DIRPRFX=${_tool}/ build-tools
954 gnu/usr.bin/cc/cc_tools \
956 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
957 cd ${.CURDIR}/${_tool}; \
958 ${MAKE} DIRPRFX=${_tool}/ obj; \
959 ${MAKE} DIRPRFX=${_tool}/ depend; \
960 ${MAKE} DIRPRFX=${_tool}/ all
964 # cross-tools: Build cross-building tools
966 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
967 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
968 _btxld= usr.sbin/btxld
970 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
971 _crunchide= usr.sbin/crunch/crunchide
973 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
974 _kgzip= usr.sbin/kgzip
980 gnu/usr.bin/binutils \
983 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
987 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
988 cd ${.CURDIR}/${_tool}; \
989 ${MAKE} DIRPRFX=${_tool}/ obj; \
990 ${MAKE} DIRPRFX=${_tool}/ depend; \
991 ${MAKE} DIRPRFX=${_tool}/ all; \
992 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
996 # hierarchy - ensure that all the needed directories are present
999 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
1002 # libraries - build all libraries, and install them under ${DESTDIR}.
1004 # The list of libraries with dependents (${_prebuild_libs}) and their
1005 # interdependencies (__L) are built automatically by the
1006 # ${.CURDIR}/tools/make_libdeps.sh script.
1010 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1011 ${MAKE} -f Makefile.inc1 _startup_libs; \
1012 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1013 ${MAKE} -f Makefile.inc1 _generic_libs;
1016 # static libgcc.a prerequisite for shared libc
1018 _prereq_libs= gnu/lib/libgcc
1020 # These dependencies are not automatically generated:
1022 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1023 # all shared libraries for ELF.
1025 _startup_libs= gnu/lib/csu
1026 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1027 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1029 _startup_libs+= lib/csu/${MACHINE_ARCH}
1031 _startup_libs+= gnu/lib/libgcc
1032 _startup_libs+= lib/libc
1034 gnu/lib/libgcc__L: lib/libc__L
1036 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1037 ${_kerberos5_lib_libroken} \
1038 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1039 ${_lib_libgssapi} ${_lib_libipx} \
1040 lib/libkiconv lib/libkvm lib/libmd \
1041 lib/ncurses/ncurses lib/ncurses/ncursesw \
1042 lib/libopie lib/libpam ${_default_thread_lib} \
1043 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1044 ${_lib_libypclnt} lib/libz lib/msun \
1045 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1046 ${_secure_lib_libssl}
1048 .if ${MK_LIBTHR} != "no" && ${MK_LIBKSE} != "no"
1049 _default_thread_lib= lib/${DEFAULT_THREAD_LIB}
1050 .elif ${MK_LIBTHR} != "no"
1051 _default_thread_lib= lib/libthr
1052 .elif ${MK_LIBKSE} != "no"
1053 _default_thread_lib= lib/libkse
1056 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1058 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1060 .if ${MK_CDDL} != "no"
1064 .if ${MK_CRYPT} != "no"
1065 .if ${MK_OPENSSL} != "no"
1066 _secure_lib_libcrypto= secure/lib/libcrypto
1067 _secure_lib_libssl= secure/lib/libssl
1068 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1069 .if ${MK_OPENSSH} != "no"
1070 _secure_lib_libssh= secure/lib/libssh
1071 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1072 .if ${MK_KERBEROS} != "no"
1073 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1074 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1075 kerberos5/lib/libroken__L
1079 _secure_lib= secure/lib
1082 .if ${MK_IPX} != "no"
1083 _lib_libipx= lib/libipx
1086 .if ${MK_KERBEROS} != "no"
1087 _kerberos5_lib= kerberos5/lib
1088 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1089 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1090 _kerberos5_lib_libroken= kerberos5/lib/libroken
1091 _lib_libgssapi= lib/libgssapi
1094 .if ${MK_NIS} != "no"
1095 _lib_libypclnt= lib/libypclnt
1098 .if ${MK_OPENSSL} == "no"
1099 lib/libradius__L: lib/libmd__L
1102 .for _lib in ${_prereq_libs}
1104 .if exists(${.CURDIR}/${_lib})
1105 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1106 cd ${.CURDIR}/${_lib}; \
1107 ${MAKE} DIRPRFX=${_lib}/ obj; \
1108 ${MAKE} DIRPRFX=${_lib}/ depend; \
1109 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1110 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1114 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1116 .if exists(${.CURDIR}/${_lib})
1117 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1118 cd ${.CURDIR}/${_lib}; \
1119 ${MAKE} DIRPRFX=${_lib}/ obj; \
1120 ${MAKE} DIRPRFX=${_lib}/ depend; \
1121 ${MAKE} DIRPRFX=${_lib}/ all; \
1122 ${MAKE} DIRPRFX=${_lib}/ install
1126 # libpam is special: we need to build static PAM modules before
1127 # static PAM library, and dynamic PAM library before dynamic PAM
1129 lib/libpam__L: .PHONY
1130 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1131 cd ${.CURDIR}/lib/libpam; \
1132 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1133 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1134 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1135 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1137 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1138 _startup_libs: ${_startup_libs:S/$/__L/}
1139 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1140 _generic_libs: ${_generic_libs:S/$/__L/}
1142 .for __target in all clean cleandepend cleandir depend includes obj
1143 .for entry in ${SUBDIR}
1144 ${entry}.${__target}__D: .PHONY
1145 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1146 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1147 edir=${entry}.${MACHINE_ARCH}; \
1148 cd ${.CURDIR}/$${edir}; \
1150 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1152 cd ${.CURDIR}/$${edir}; \
1154 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1156 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1159 .include <bsd.subdir.mk>
1161 .if make(check-old) || make(check-old-dirs) || \
1162 make(check-old-files) || make(check-old-libs) || \
1163 make(delete-old) || make(delete-old-dirs) || \
1164 make(delete-old-files) || make(delete-old-libs)
1167 # check for / delete old files section
1170 .include "ObsoleteFiles.inc"
1172 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1173 else you can not start such an application. Consult UPDATING for more \
1174 information regarding how to cope with the removal/revision bump of a \
1177 .if !defined(BATCH_DELETE_OLD_FILES)
1184 @echo ">>> Removing old files (only deletes safe to delete libs)"
1185 # Ask for every old file if the user really wants to remove it.
1186 # It's annoying, but better safe than sorry.
1187 @for file in ${OLD_FILES}; do \
1188 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1189 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1190 rm ${RM_I} "${DESTDIR}/$${file}"; \
1193 # Remove catpages without corresponding manpages.
1195 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1196 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1197 while read catpage; do \
1199 if [ ! -e "$${manpage}" ]; then \
1200 rm ${RM_I} $${catpage} <&3 ; \
1203 @echo ">>> Old files removed"
1206 @echo ">>> Checking for old files"
1207 @for file in ${OLD_FILES}; do \
1208 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1209 echo "${DESTDIR}/$${file}"; \
1212 # Check for catpages without corresponding manpages.
1213 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1214 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1215 while read catpage; do \
1217 if [ ! -e "$${manpage}" ]; then \
1218 echo $${catpage} ; \
1223 @echo ">>> Removing old libraries"
1224 @echo "${OLD_LIBS_MESSAGE}" | fmt
1225 @for file in ${OLD_LIBS}; do \
1226 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1227 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1228 rm ${RM_I} "${DESTDIR}/$${file}"; \
1231 @echo ">>> Old libraries removed"
1234 @echo ">>> Checking for old libraries"
1235 @for file in ${OLD_LIBS}; do \
1236 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1237 echo "${DESTDIR}/$${file}"; \
1242 @echo ">>> Removing old directories"
1243 @for dir in ${OLD_DIRS}; do \
1244 if [ -d "${DESTDIR}/$${dir}" ]; then \
1245 rmdir -v "${DESTDIR}/$${dir}" || true; \
1246 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1247 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1250 @echo ">>> Old directories removed"
1253 @echo ">>> Checking for old directories"
1254 @for dir in ${OLD_DIRS}; do \
1255 if [ -d "${DESTDIR}/$${dir}" ]; then \
1256 echo "${DESTDIR}/$${dir}"; \
1257 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1258 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1262 delete-old: delete-old-files delete-old-dirs
1263 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1265 check-old: check-old-files check-old-libs check-old-dirs
1266 @echo "To remove old files and directories run '${MAKE} delete-old'."
1267 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1272 # showconfig - show build configuration.
1275 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort