4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 # -DNO_ROOT install without using root privilege
17 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
19 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22 # LOCAL_MTREE="list of mtree files" to process to allow local directories
23 # to be created before files are installed
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # METALOG="path to metadata log" to write permission and ownership
27 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
28 # TARGET="machine" to crossbuild world for a different machine type
29 # TARGET_ARCH= may be required when a TARGET supports multiple endians
30 # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
35 # The intended user-driven targets are:
36 # buildworld - rebuild *everything*, including glue to help do upgrades
37 # installworld- install everything built by "buildworld"
38 # doxygen - build API documentation of the kernel
39 # update - convenient way to update your source tree (eg: svn/svnup)
41 # Standard targets (not defined here) are documented in the makefiles in
42 # /usr/share/mk. These include:
43 # obj depend all install clean cleandepend cleanobj
45 .if !defined(TARGET) || !defined(TARGET_ARCH)
46 .error "Both TARGET and TARGET_ARCH must be defined."
49 .include "share/mk/src.opts.mk"
50 .include <bsd.arch.inc.mk>
51 .include <bsd.compiler.mk>
53 # We must do share/info early so that installation of info `dir'
54 # entries works correctly. Do it first since it is less likely to
55 # grow dependencies on include and lib than vice versa.
57 # We must do lib/ and libexec/ before bin/, because if installworld
58 # installs a new /bin/sh, the 'make' command will *immediately*
59 # use that new version. And the new (dynamically-linked) /bin/sh
60 # will expect to find appropriate libraries in /lib and /libexec.
63 .if defined(SUBDIR_OVERRIDE)
64 SUBDIR= ${SUBDIR_OVERRIDE}
66 SUBDIR= share/info lib libexec
68 .if ${MK_GAMES} != "no"
71 .if ${MK_CDDL} != "no"
75 .if ${MK_KERBEROS} != "no"
78 .if ${MK_RESCUE} != "no"
82 .if ${MK_CRYPT} != "no"
85 .if !defined(NO_SHARE)
88 SUBDIR+=sys usr.bin usr.sbin
89 .if ${MK_TESTS} != "no"
92 .if ${MK_OFED} != "no"
96 # We must do etc/ last for install/distribute to work.
100 # Local directories are last, since it is nice to at least get the base
101 # system rebuilt before you do them.
102 .for _DIR in ${LOCAL_DIRS}
103 .if exists(${.CURDIR}/${_DIR}/Makefile)
107 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
108 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
109 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
110 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
111 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
113 .for _DIR in ${LOCAL_LIB_DIRS}
114 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
117 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
125 .if defined(NO_CLEANDIR)
126 CLEANDIR= clean cleandepend
133 BUILDENV_SHELL?=/bin/sh
135 SVN?= /usr/local/bin/svn
138 MAKEOBJDIRPREFIX?= /usr/obj
139 .if !defined(OSRELDATE)
140 .if exists(/usr/include/osreldate.h)
141 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
142 /usr/include/osreldate.h
148 .if !defined(VERSION)
149 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
150 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
151 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
152 ${SRCDIR}/sys/sys/param.h
153 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
156 KNOWN_ARCHES?= amd64 arm armeb/arm armv6/arm armv6hf/arm i386 i386/pc98 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
157 .if ${TARGET} == ${TARGET_ARCH}
160 _t= ${TARGET_ARCH}/${TARGET}
163 .if empty(KNOWN_ARCHES:M${_t})
164 .error Unknown target ${TARGET_ARCH}:${TARGET}.
168 .if ${TARGET} == ${MACHINE}
169 TARGET_CPUTYPE?=${CPUTYPE}
174 .if !empty(TARGET_CPUTYPE)
175 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
177 _TARGET_CPUTYPE=dummy
179 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
180 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
181 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
182 .error CPUTYPE global should be set with ?=.
185 BUILD_ARCH!= uname -p
186 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
187 .error To cross-build, set TARGET_ARCH.
190 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
191 OBJTREE= ${MAKEOBJDIRPREFIX}
193 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
195 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
196 # /usr/games added for fortune which depend on strfile
197 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
198 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
199 STRICTTMPPATH= ${BPATH}:${XPATH}
200 TMPPATH= ${STRICTTMPPATH}:${PATH}
203 # Avoid running mktemp(1) unless actually needed.
204 # It may not be functional, e.g., due to new ABI
205 # when in the middle of installing over this system.
207 .if make(distributeworld) || make(installworld)
208 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
212 # Building a world goes through the following stages
214 # 1. legacy stage [BMAKE]
215 # This stage is responsible for creating compatibility
216 # shims that are needed by the bootstrap-tools,
217 # build-tools and cross-tools stages.
218 # 1. bootstrap-tools stage [BMAKE]
219 # This stage is responsible for creating programs that
220 # are needed for backward compatibility reasons. They
221 # are not built as cross-tools.
222 # 2. build-tools stage [TMAKE]
223 # This stage is responsible for creating the object
224 # tree and building any tools that are needed during
226 # 3. cross-tools stage [XMAKE]
227 # This stage is responsible for creating any tools that
228 # are needed for cross-builds. A cross-compiler is one
230 # 4. world stage [WMAKE]
231 # This stage actually builds the world.
232 # 5. install stage (optional) [IMAKE]
233 # This stage installs a previously built world.
238 # Common environment for world related stages
239 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
240 MACHINE_ARCH=${TARGET_ARCH} \
242 CPUTYPE=${TARGET_CPUTYPE}
243 .if ${MK_GROFF} != "no"
244 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
245 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
246 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
248 .if defined(TARGET_CFLAGS)
249 CROSSENV+= ${TARGET_CFLAGS}
252 # bootstrap-tools stage
253 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
254 PATH=${BPATH}:${PATH} \
255 WORLDTMP=${WORLDTMP} \
256 VERSION="${VERSION}" \
257 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
258 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
259 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
261 BOOTSTRAPPING=${OSRELDATE} \
263 MK_HTML=no NO_LINT=yes MK_MAN=no \
264 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
265 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
266 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
268 MK_LLDB=no MK_TESTS=no
271 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
272 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
273 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
275 BOOTSTRAPPING=${OSRELDATE} \
280 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
282 MK_LLDB=no MK_MAN=no \
283 MK_SHAREDOCS=no MK_TESTS=no \
287 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
288 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
289 MK_DEBUG_FILES=no MK_GDB=no MK_TESTS=no
292 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
293 PATH=${BPATH}:${PATH} \
294 WORLDTMP=${WORLDTMP} \
296 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
297 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
299 BOOTSTRAPPING=${OSRELDATE} \
301 MK_HTML=no -DNO_LINT MK_MAN=no \
302 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
303 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
306 WMAKEENV= ${CROSSENV} \
307 _SHLIBDIRPREFIX=${WORLDTMP} \
309 VERSION="${VERSION}" \
310 INSTALL="sh ${.CURDIR}/tools/install.sh" \
314 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
316 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
319 .if ${MK_CDDL} == "no"
323 .if defined(CROSS_TOOLCHAIN)
324 LOCALBASE?= /usr/local
325 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
327 .if defined(CROSS_TOOLCHAIN_PREFIX)
328 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
329 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
331 XCOMPILERS= CC CXX CPP
332 .for COMPILER in ${XCOMPILERS}
333 .if defined(CROSS_COMPILER_PREFIX)
334 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
336 X${COMPILER}?= ${${COMPILER}}
339 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
340 .for BINUTIL in ${XBINUTILS}
341 .if defined(CROSS_BINUTILS_PREFIX)
342 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
344 X${BINUTIL}?= ${${BINUTIL}}
347 WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
348 DEPFLAGS="${DEPFLAGS}" \
349 CPP="${XCPP} ${XCFLAGS}" \
350 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
351 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
352 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
356 XFLAGS= --sysroot=${WORLDTMP}
357 .if defined(CROSS_BINUTILS_PREFIX)
358 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
359 # directory, but the compiler will look in the right place for it's
360 # tools so we don't need to tell it where to look.
361 .if exists(${CROSS_BINUTILS_PREFIX})
362 XFLAGS+= -B${CROSS_BINUTILS_PREFIX}
365 XFLAGS+= -B${WORLDTMP}/usr/bin
367 .if ${TARGET} == "arm"
368 .if ${TARGET_ARCH:M*hf*} != ""
369 TARGET_ABI= gnueabihf
374 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
375 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
376 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
377 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
380 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
381 XCFLAGS+= -target ${TARGET_TRIPLE}
385 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
387 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
389 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
390 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
392 .if ${TARGET_ARCH} == "amd64"
393 .if empty(TARGET_CPUTYPE)
394 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
396 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
398 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
399 MACHINE_CPU="i686 mmx sse sse2"
402 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
404 .elif ${TARGET_ARCH} == "powerpc64"
405 .if empty(TARGET_CPUTYPE)
406 LIB32CPUFLAGS= -mcpu=powerpc
408 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
410 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
412 LD="${LD} -m elf32ppc_fbsd"
416 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
417 -isystem ${LIB32TMP}/usr/include/ \
418 -L${LIB32TMP}/usr/lib32 \
419 -B${LIB32TMP}/usr/lib32
421 LIB32FLAGS+= --sysroot=${WORLDTMP}
424 # Yes, the flags are redundant.
425 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
426 _SHLIBDIRPREFIX=${LIB32TMP} \
427 _LDSCRIPTROOT=${LIB32TMP} \
428 VERSION="${VERSION}" \
429 INSTALL="sh ${.CURDIR}/tools/install.sh" \
432 SHLIBDIR=/usr/lib32 \
433 LIBPRIVATEDIR=/usr/lib32/private \
434 DTRACE="${DTRACE} -32"
435 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
436 CXX="${XCXX} ${LIB32FLAGS}" \
437 DESTDIR=${LIB32TMP} \
445 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
446 MK_MAN=no MK_HTML=no MK_HYPERV=no MK_BHYVE=no
447 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
448 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
451 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
452 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
453 ${IMAKE_INSTALL} ${IMAKE_MTREE}
454 .if empty(.MAKEFLAGS:M-n)
455 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
456 LD_LIBRARY_PATH=${INSTALLTMP} \
457 PATH_LOCALE=${INSTALLTMP}/locale
458 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
460 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
462 .if defined(DB_FROM_SRC)
463 INSTALLFLAGS+= -N ${.CURDIR}/etc
464 MTREEFLAGS+= -N ${.CURDIR}/etc
466 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
467 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
469 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
470 IMAKE+= -DNO_ROOT METALOG=${METALOG}
471 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
474 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
475 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
476 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
480 KMAKEENV= ${WMAKEENV}
481 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
486 # Attempt to rebuild the entire system, with reasonable chance of
487 # success, regardless of how old your existing system is.
490 .if ${.CURDIR:C/[^,]//g} != ""
491 # The m4 build of sendmail files doesn't like it if ',' is used
492 # anywhere in the path of it's files.
494 @echo "*** Error: path to source tree contains a comma ','"
499 @echo "--------------------------------------------------------------"
500 @echo ">>> Rebuilding the temporary build tree"
501 @echo "--------------------------------------------------------------"
502 .if !defined(NO_CLEAN)
504 .if defined(LIB32TMP)
508 rm -rf ${WORLDTMP}/legacy/usr/include
509 # XXX - These three can depend on any header file.
510 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
511 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
512 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
515 lib usr legacy/bin legacy/usr
516 mkdir -p ${WORLDTMP}/${_dir}
518 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
519 -p ${WORLDTMP}/legacy/usr >/dev/null
520 .if ${MK_GROFF} != "no"
521 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
522 -p ${WORLDTMP}/legacy/usr >/dev/null
524 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
525 -p ${WORLDTMP}/usr >/dev/null
526 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
527 -p ${WORLDTMP}/usr/include >/dev/null
528 ln -sf ${.CURDIR}/sys ${WORLDTMP}
529 .if ${MK_DEBUG_FILES} != "no"
530 # We could instead disable debug files for these build stages
531 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
532 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
533 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
534 -p ${WORLDTMP}/usr/lib >/dev/null
536 .if ${MK_TESTS} != "no"
537 mkdir -p ${WORLDTMP}${TESTSBASE}
538 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
539 -p ${WORLDTMP}${TESTSBASE} >/dev/null
541 .for _mtree in ${LOCAL_MTREE}
542 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
546 @echo "--------------------------------------------------------------"
547 @echo ">>> stage 1.1: legacy release compatibility shims"
548 @echo "--------------------------------------------------------------"
549 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
552 @echo "--------------------------------------------------------------"
553 @echo ">>> stage 1.2: bootstrap tools"
554 @echo "--------------------------------------------------------------"
555 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
557 .if !defined(NO_CLEAN)
559 @echo "--------------------------------------------------------------"
560 @echo ">>> stage 2.1: cleaning up the object tree"
561 @echo "--------------------------------------------------------------"
562 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
563 .if defined(LIB32TMP)
564 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
569 @echo "--------------------------------------------------------------"
570 @echo ">>> stage 2.2: rebuilding the object tree"
571 @echo "--------------------------------------------------------------"
572 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
575 @echo "--------------------------------------------------------------"
576 @echo ">>> stage 2.3: build tools"
577 @echo "--------------------------------------------------------------"
578 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
581 @echo "--------------------------------------------------------------"
582 @echo ">>> stage 3: cross tools"
583 @echo "--------------------------------------------------------------"
584 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
585 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
588 @echo "--------------------------------------------------------------"
589 @echo ">>> stage 4.1: building includes"
590 @echo "--------------------------------------------------------------"
591 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
594 @echo "--------------------------------------------------------------"
595 @echo ">>> stage 4.2: building libraries"
596 @echo "--------------------------------------------------------------"
597 ${_+_}cd ${.CURDIR}; \
598 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
599 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
602 @echo "--------------------------------------------------------------"
603 @echo ">>> stage 4.3: make dependencies"
604 @echo "--------------------------------------------------------------"
605 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
608 @echo "--------------------------------------------------------------"
609 @echo ">>> stage 4.4: building everything"
610 @echo "--------------------------------------------------------------"
611 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
612 .if defined(LIB32TMP)
615 @echo "--------------------------------------------------------------"
616 @echo ">>> stage 5.1: building 32 bit shim libraries"
617 @echo "--------------------------------------------------------------"
618 mkdir -p ${LIB32TMP}/usr/include
619 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
620 -p ${LIB32TMP}/usr >/dev/null
621 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
622 -p ${LIB32TMP}/usr/include >/dev/null
623 .if ${MK_DEBUG_FILES} != "no"
624 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
625 -p ${LIB32TMP}/usr/lib >/dev/null
628 ln -sf ${.CURDIR}/sys ${WORLDTMP}
629 .for _t in obj includes
630 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
631 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
632 .if ${MK_CDDL} != "no"
633 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
635 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
636 .if ${MK_CRYPT} != "no"
637 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
639 .if ${MK_KERBEROS} != "no"
640 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
643 .for _dir in usr.bin/lex/lib
644 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
646 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
647 cd ${.CURDIR}/${_dir}; \
648 WORLDTMP=${WORLDTMP} \
649 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
650 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
651 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
655 ${LIB32WMAKE} -f Makefile.inc1 libraries
656 .for _t in obj depend all
657 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
658 DIRPRFX=libexec/rtld-elf/ ${_t}
659 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
660 DIRPRFX=usr.bin/ldd ${_t}
663 distribute32 install32:
664 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
665 .if ${MK_CDDL} != "no"
666 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
668 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
669 .if ${MK_CRYPT} != "no"
670 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
672 .if ${MK_KERBEROS} != "no"
673 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
675 cd ${.CURDIR}/libexec/rtld-elf; \
676 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
677 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
681 .if !defined(SUBDIR_OVERRIDE)
682 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
684 WMAKE_TGTS+= _cleanobj _obj _build-tools
685 .if !defined(SUBDIR_OVERRIDE)
686 WMAKE_TGTS+= _cross-tools
688 WMAKE_TGTS+= _includes _libraries _depend everything
689 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
693 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
694 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
697 @echo "--------------------------------------------------------------"
698 @echo ">>> World build started on `LC_ALL=C date`"
699 @echo "--------------------------------------------------------------"
703 @echo "--------------------------------------------------------------"
704 @echo ">>> World build completed on `LC_ALL=C date`"
705 @echo "--------------------------------------------------------------"
708 # We need to have this as a target because the indirection between Makefile
709 # and Makefile.inc1 causes the correct PATH to be used, rather than a
710 # modification of the current environment's PATH. In addition, we need
711 # to quote multiword values.
716 .if ${.TARGETS:Mbuildenv}
717 .if ${.MAKEFLAGS:M-j}
718 .error The buildenv target is incompatible with -j
722 @echo Entering world for ${TARGET_ARCH}:${TARGET}
723 @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
725 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
726 toolchain: ${TOOLCHAIN_TGTS}
727 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
732 # Checks to be sure system is ready for installworld/installkernel.
734 installcheck: _installcheck_world _installcheck_kernel
736 _installcheck_kernel:
739 # Require DESTDIR to be set if installing for a different architecture or
740 # using the user/group database in the source tree.
742 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
744 .if !make(distributeworld)
745 _installcheck_world: __installcheck_DESTDIR
746 _installcheck_kernel: __installcheck_DESTDIR
747 __installcheck_DESTDIR:
748 .if !defined(DESTDIR) || empty(DESTDIR)
749 @echo "ERROR: Please set DESTDIR!"; \
755 .if !defined(DB_FROM_SRC)
757 # Check for missing UIDs/GIDs.
759 CHECK_UIDS= auditdistd
761 .if ${MK_SENDMAIL} != "no"
767 CHECK_GIDS+= proxy authpf
769 .if ${MK_UNBOUND} != "no"
773 _installcheck_world: __installcheck_UGID
775 .for uid in ${CHECK_UIDS}
776 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
777 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
781 .for gid in ${CHECK_GIDS}
782 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
783 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
790 # Required install tools to be saved in a scratch dir for safety.
792 .if ${MK_ZONEINFO} != "no"
793 _zoneinfo= zic tzsetup
796 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
797 date echo egrep find grep id install ${_install-info} \
798 ln lockf make mkdir mtree mv pwd_mkdb \
799 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
802 # Needed for share/man
803 .if ${MK_MAN} != "no"
810 # Distributes everything compiled by a `buildworld'.
814 # Installs everything compiled by a 'buildworld'.
817 # Non-base distributions produced by the base system
818 EXTRA_DISTRIBUTIONS= doc
819 .if ${MK_GAMES} != "no"
820 EXTRA_DISTRIBUTIONS+= games
822 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
823 EXTRA_DISTRIBUTIONS+= lib32
825 .if ${MK_TESTS} != "no"
826 EXTRA_DISTRIBUTIONS+= tests
830 .if ${MK_DEBUG_FILES} != "no"
831 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,}
834 MTREE_MAGIC?= mtree 2.0
836 distributeworld installworld: _installcheck_world
837 mkdir -p ${INSTALLTMP}
838 progs=$$(for prog in ${ITOOLS}; do \
839 if progpath=`which $$prog`; then \
842 echo "Required tool $$prog not found in PATH." >&2; \
846 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
847 while read line; do \
849 if [ "$$2 $$3" != "not found" ]; then \
852 echo "Required library $$1 not found." >&2; \
856 cp $$libs $$progs ${INSTALLTMP}
857 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
859 echo "#${MTREE_MAGIC}" > ${METALOG}
861 .if make(distributeworld)
862 .for dist in ${EXTRA_DISTRIBUTIONS}
863 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
864 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
865 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
866 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
867 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
868 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
869 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
870 .if ${MK_DEBUG_FILES} != "no"
871 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
872 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
874 .if ${MK_TESTS} != "no" && ${dist} == "tests"
875 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
876 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
877 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
880 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
881 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
882 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
883 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
884 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
885 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
888 -mkdir ${DESTDIR}/${DISTDIR}/base
889 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
890 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
891 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
892 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
894 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
895 ${IMAKEENV} rm -rf ${INSTALLTMP}
896 .if make(distributeworld)
897 .for dist in ${EXTRA_DISTRIBUTIONS}
898 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
901 .for dist in base ${EXTRA_DISTRIBUTIONS}
902 @# For each file that exists in this dist, print the corresponding
903 @# line from the METALOG. This relies on the fact that
904 @# a line containing only the filename will sort immediatly before
905 @# the relevant mtree line.
906 cd ${DESTDIR}/${DISTDIR}; \
907 find ./${dist} | sort -u ${METALOG} - | \
908 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
909 ${DESTDIR}/${DISTDIR}/${dist}.meta
911 .for dist in ${DEBUG_DISTRIBUTIONS}
912 @# For each file that exists in this dist, print the corresponding
913 @# line from the METALOG. This relies on the fact that
914 @# a line containing only the filename will sort immediatly before
915 @# the relevant mtree line.
916 cd ${DESTDIR}/${DISTDIR}; \
917 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
918 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
919 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
925 .for dist in base ${EXTRA_DISTRIBUTIONS}
927 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
928 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
929 --exclude usr/lib/debug \
930 @${DESTDIR}/${DISTDIR}/${dist}.meta
932 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
933 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
934 --exclude usr/lib/debug .
938 .for dist in ${DEBUG_DISTRIBUTIONS}
939 . if defined(NO_ROOT)
940 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
941 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \
942 @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
944 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
945 tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \
953 # If you have a build server, you can NFS mount the source and obj directories
954 # and do a 'make reinstall' on the *client* to install new binaries from the
955 # most recent server build.
958 @echo "--------------------------------------------------------------"
959 @echo ">>> Making hierarchy"
960 @echo "--------------------------------------------------------------"
961 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
962 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
964 @echo "--------------------------------------------------------------"
965 @echo ">>> Installing everything"
966 @echo "--------------------------------------------------------------"
967 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
968 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
969 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
973 @echo "--------------------------------------------------------------"
974 @echo ">>> Distributing everything"
975 @echo "--------------------------------------------------------------"
976 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
977 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
978 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
982 distrib-dirs distribution: .MAKE
983 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
984 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
987 # buildkernel and installkernel
989 # Which kernels to build and/or install is specified by setting
990 # KERNCONF. If not defined a GENERIC kernel is built/installed.
991 # Only the existing (depending TARGET) config files are used
992 # for building kernels and only the first of these is designated
993 # as the one being installed.
995 # Note that we have to use TARGET instead of TARGET_ARCH when
996 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
997 # be set to cross-build, we have to make sure TARGET is set
1000 .if defined(KERNFAST)
1005 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1006 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1007 KERNCONF=${KERNFAST}
1010 .if ${TARGET_ARCH} == "powerpc64"
1011 KERNCONF?= GENERIC64
1015 INSTKERNNAME?= kernel
1017 KERNSRCDIR?= ${.CURDIR}/sys
1018 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1019 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1020 KERNCONFDIR?= ${KRNLCONFDIR}
1024 .for _kernel in ${KERNCONF}
1025 .if exists(${KERNCONFDIR}/${_kernel})
1026 BUILDKERNELS+= ${_kernel}
1027 .if empty(INSTALLKERNEL)
1028 INSTALLKERNEL= ${_kernel}
1033 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
1038 # Builds all kernels defined by BUILDKERNELS.
1041 .if empty(BUILDKERNELS)
1042 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1046 .for _kernel in ${BUILDKERNELS}
1047 @echo "--------------------------------------------------------------"
1048 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1049 @echo "--------------------------------------------------------------"
1050 @echo "===> ${_kernel}"
1051 mkdir -p ${KRNLOBJDIR}
1052 .if !defined(NO_KERNELCONFIG)
1054 @echo "--------------------------------------------------------------"
1055 @echo ">>> stage 1: configuring the kernel"
1056 @echo "--------------------------------------------------------------"
1057 cd ${KRNLCONFDIR}; \
1059 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1060 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1062 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1064 @echo "--------------------------------------------------------------"
1065 @echo ">>> stage 2.1: cleaning up the object tree"
1066 @echo "--------------------------------------------------------------"
1067 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1069 .if !defined(NO_KERNELOBJ)
1071 @echo "--------------------------------------------------------------"
1072 @echo ">>> stage 2.2: rebuilding the object tree"
1073 @echo "--------------------------------------------------------------"
1074 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1077 @echo "--------------------------------------------------------------"
1078 @echo ">>> stage 2.3: build tools"
1079 @echo "--------------------------------------------------------------"
1080 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1081 .if !defined(NO_KERNELDEPEND)
1083 @echo "--------------------------------------------------------------"
1084 @echo ">>> stage 3.1: making dependencies"
1085 @echo "--------------------------------------------------------------"
1086 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1089 @echo "--------------------------------------------------------------"
1090 @echo ">>> stage 3.2: building everything"
1091 @echo "--------------------------------------------------------------"
1092 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1093 @echo "--------------------------------------------------------------"
1094 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1095 @echo "--------------------------------------------------------------"
1099 # installkernel, etc.
1101 # Install the kernel defined by INSTALLKERNEL
1103 installkernel installkernel.debug \
1104 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1105 .if empty(INSTALLKERNEL)
1106 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1109 @echo "--------------------------------------------------------------"
1110 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1111 @echo "--------------------------------------------------------------"
1112 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1113 ${CROSSENV} PATH=${TMPPATH} \
1114 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1116 distributekernel distributekernel.debug:
1117 .if empty(INSTALLKERNEL)
1118 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1121 mkdir -p ${DESTDIR}/${DISTDIR}
1122 .if defined(NO_ROOT)
1123 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1125 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1126 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1127 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1128 DESTDIR=${INSTALL_DDIR}/kernel \
1129 ${.TARGET:S/distributekernel/install/}
1130 .if defined(NO_ROOT)
1131 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1132 ${DESTDIR}/${DISTDIR}/kernel.meta
1134 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1135 .if defined(NO_ROOT)
1136 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1138 cd ${KRNLOBJDIR}/${_kernel}; \
1139 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1140 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1141 KERNEL=${INSTKERNNAME}.${_kernel} \
1142 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1143 ${.TARGET:S/distributekernel/install/}
1144 .if defined(NO_ROOT)
1145 sed -e 's|^./kernel|.|' \
1146 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1147 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1152 .if defined(NO_ROOT)
1153 cd ${DESTDIR}/${DISTDIR}/kernel; \
1154 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
1155 @${DESTDIR}/${DISTDIR}/kernel.meta
1156 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1157 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1158 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
1159 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1162 cd ${DESTDIR}/${DISTDIR}/kernel; \
1163 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1164 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1165 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1166 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1173 # Build the API documentation with doxygen
1176 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1177 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1180 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1185 # Update the source tree(s), by running svn/svnup to update to the
1189 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1190 @echo "--------------------------------------------------------------"
1191 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1192 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1193 @echo "--------------------------------------------------------------"
1196 .if defined(SVN_UPDATE)
1197 @echo "--------------------------------------------------------------"
1198 @echo ">>> Updating ${.CURDIR} using Subversion"
1199 @echo "--------------------------------------------------------------"
1200 @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1204 # ------------------------------------------------------------------------
1206 # From here onwards are utility targets used by the 'make world' and
1207 # related targets. If your 'world' breaks, you may like to try to fix
1208 # the problem and manually run the following targets to attempt to
1209 # complete the build. Beware, this is *not* guaranteed to work, you
1210 # need to have a pretty good grip on the current state of the system
1211 # to attempt to manually finish it. If in doubt, 'make world' again.
1215 # legacy: Build compatibility shims for the next three targets
1218 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1219 @echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
1222 .for _tool in tools/build
1223 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1224 cd ${.CURDIR}/${_tool} && \
1225 ${MAKE} DIRPRFX=${_tool}/ obj && \
1226 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1227 ${MAKE} DIRPRFX=${_tool}/ depend && \
1228 ${MAKE} DIRPRFX=${_tool}/ all && \
1229 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1233 # bootstrap-tools: Build tools needed for compatibility
1235 _bt= _bootstrap-tools
1237 .if ${MK_GAMES} != "no"
1238 _strfile= games/fortune/strfile
1241 .if ${MK_CXX} != "no"
1242 _gperf= gnu/usr.bin/gperf
1245 .if ${MK_GROFF} != "no"
1246 _groff= gnu/usr.bin/groff
1249 .if ${MK_VT} != "no"
1250 _vtfontcvt= usr.bin/vtfontcvt
1253 .if ${BOOTSTRAPPING} < 900002
1257 .if ${BOOTSTRAPPING} < 1000002
1261 ${_bt}-usr.bin/m4: ${_bt}-lib/libohash
1264 .if ${BOOTSTRAPPING} < 1000013
1268 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1271 .if ${BOOTSTRAPPING} < 1000014
1272 _crunch= usr.sbin/crunch
1275 .if ${BOOTSTRAPPING} < 1000026
1276 _nmtree= lib/libnetbsd \
1279 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1282 .if ${BOOTSTRAPPING} < 1000027
1286 .if ${BOOTSTRAPPING} < 1000033
1290 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1294 .if ${MK_BSNMP} != "no"
1295 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1298 # We need to build tblgen when we're building clang either as
1299 # the bootstrap compiler, or as the part of the normal build.
1300 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1302 lib/clang/libllvmsupport \
1303 lib/clang/libllvmtablegen \
1304 usr.bin/clang/tblgen \
1305 usr.bin/clang/clang-tblgen
1307 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1308 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1311 # dtrace tools are required for older bootstrap env and cross-build
1313 .if ${MK_CDDL} != "no" && (${BOOTSTRAPPING} < 1100006 \
1314 || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1315 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1316 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1319 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1322 .if ${MK_GPL_DTC} != "no"
1323 _dtc= gnu/usr.bin/dtc
1326 .if ${MK_KERBEROS} != "no"
1327 _kerberos5_bootstrap_tools= \
1328 kerberos5/tools/make-roken \
1329 kerberos5/lib/libroken \
1330 kerberos5/lib/libvers \
1331 kerberos5/tools/asn1_compile \
1332 kerberos5/tools/slc \
1335 ${_bt}-kerberos5/tools/slc: ${_bt}-kerberos5/lib/libroken
1336 ${_bt}-kerberos5/tools/asn1_compile: ${_bt}-kerberos5/lib/libroken
1339 bootstrap-tools: .PHONY
1341 # Please document (add comment) why something is in 'bootstrap-tools'.
1342 # Try to bound the building of the bootstrap-tool to just the
1343 # FreeBSD versions that need the tool built at this stage of the build.
1346 ${_kerberos5_bootstrap_tools} \
1355 usr.bin/makewhatis \
1368 ${_bt}-${_tool}: .PHONY .MAKE
1369 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1370 cd ${.CURDIR}/${_tool} && \
1371 ${MAKE} DIRPRFX=${_tool}/ obj && \
1372 ${MAKE} DIRPRFX=${_tool}/ depend && \
1373 ${MAKE} DIRPRFX=${_tool}/ all && \
1374 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1376 bootstrap-tools: ${_bt}-${_tool}
1380 # build-tools: Build special purpose build tools
1382 .if !defined(NO_SHARE)
1383 _share= share/syscons/scrnmaps
1386 .if ${MK_GCC} != "no"
1387 _gcc_tools= gnu/usr.bin/cc/cc_tools
1390 .if ${MK_RESCUE} != "no"
1391 _rescue= rescue/rescue
1399 ${LOCAL_TOOL_DIRS} \
1400 lib/ncurses/ncurses \
1401 lib/ncurses/ncursesw \
1405 usr.bin/mkesdb_static \
1406 usr.bin/mkcsmapper_static \
1408 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1409 cd ${.CURDIR}/${_tool} && \
1410 ${MAKE} DIRPRFX=${_tool}/ obj && \
1411 ${MAKE} DIRPRFX=${_tool}/ build-tools
1415 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1416 cd ${.CURDIR}/${_tool} && \
1417 ${MAKE} DIRPRFX=${_tool}/ obj && \
1418 ${MAKE} DIRPRFX=${_tool}/ depend && \
1419 ${MAKE} DIRPRFX=${_tool}/ all
1423 # kernel-tools: Build kernel-building tools
1426 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1427 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1428 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1431 # cross-tools: Build cross-building tools
1433 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1434 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1435 _btxld= usr.sbin/btxld
1438 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1439 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1440 _crunchide= usr.sbin/crunch/crunchide
1442 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1443 _kgzip= usr.sbin/kgzip
1447 # If we're given an XAS, don't build binutils.
1448 .if ${XAS:M/*} == ""
1449 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1450 _binutils= gnu/usr.bin/binutils
1452 .if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
1453 _elftctools= lib/libelftc \
1462 # If an full path to an external cross compiler is given, don't build
1464 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1465 .if ${MK_CLANG_BOOTSTRAP} != "no"
1466 _clang= usr.bin/clang
1467 _clang_libs= lib/clang
1469 .if ${MK_GCC_BOOTSTRAP} != "no"
1481 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1486 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1487 cd ${.CURDIR}/${_tool} && \
1488 ${MAKE} DIRPRFX=${_tool}/ obj && \
1489 ${MAKE} DIRPRFX=${_tool}/ depend && \
1490 ${MAKE} DIRPRFX=${_tool}/ all && \
1491 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1494 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1495 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1496 VERSION="${VERSION}"
1497 NXBMAKE= ${NXBENV} ${MAKE} \
1498 TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
1499 CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
1500 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1501 MK_DEBUG_FILES=no MK_GDB=no MK_TESTS=no \
1503 MK_HTML=no NO_LINT=yes MK_MAN=no \
1504 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1505 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1506 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1509 native-xtools: .MAKE
1510 mkdir -p ${OBJTREE}/nxb-bin/bin
1511 mkdir -p ${OBJTREE}/nxb-bin/sbin
1512 mkdir -p ${OBJTREE}/nxb-bin/usr
1513 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1514 -p ${OBJTREE}/nxb-bin/usr >/dev/null
1515 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1516 -p ${OBJTREE}/nxb-bin/usr/include >/dev/null
1576 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1577 cd ${.CURDIR}/${_tool} && \
1578 ${NXBMAKE} DIRPRFX=${_tool}/ obj && \
1579 ${NXBMAKE} DIRPRFX=${_tool}/ depend && \
1580 ${NXBMAKE} DIRPRFX=${_tool}/ all && \
1581 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install
1585 # hierarchy - ensure that all the needed directories are present
1587 hierarchy hier: .MAKE
1588 cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1591 # libraries - build all libraries, and install them under ${DESTDIR}.
1593 # The list of libraries with dependents (${_prebuild_libs}) and their
1594 # interdependencies (__L) are built automatically by the
1595 # ${.CURDIR}/tools/make_libdeps.sh script.
1599 ${MAKE} -f Makefile.inc1 _prereq_libs && \
1600 ${MAKE} -f Makefile.inc1 _startup_libs && \
1601 ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1602 ${MAKE} -f Makefile.inc1 _generic_libs
1605 # static libgcc.a prerequisite for shared libc
1607 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1609 # These dependencies are not automatically generated:
1611 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1612 # all shared libraries for ELF.
1614 _startup_libs= gnu/lib/csu
1615 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1616 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1617 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1618 _startup_libs+= lib/csu/${MACHINE_ARCH}
1620 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1622 _startup_libs+= gnu/lib/libgcc
1623 _startup_libs+= lib/libcompiler_rt
1624 _startup_libs+= lib/libc
1625 _startup_libs+= lib/libc_nonshared
1626 .if ${MK_LIBCPLUSPLUS} != "no"
1627 _startup_libs+= lib/libcxxrt
1630 gnu/lib/libgcc__L: lib/libc__L
1631 gnu/lib/libgcc__L: lib/libc_nonshared__L
1632 .if ${MK_LIBCPLUSPLUS} != "no"
1633 lib/libcxxrt__L: gnu/lib/libgcc__L
1636 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1637 ${_kerberos5_lib_libhdb} \
1638 ${_kerberos5_lib_libheimbase} \
1639 ${_kerberos5_lib_libheimntlm} \
1640 ${_kerberos5_lib_libheimsqlite} \
1641 ${_kerberos5_lib_libheimipcc} \
1642 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1643 ${_kerberos5_lib_libroken} \
1644 ${_kerberos5_lib_libwind} \
1645 lib/libbz2 ${_libcom_err} lib/libcrypt \
1646 lib/libelf lib/libexpat \
1649 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1650 ${_lib_libcapsicum} \
1651 lib/ncurses/ncurses lib/ncurses/ncursesw \
1652 lib/libopie lib/libpam ${_lib_libthr} \
1653 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1655 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1656 ${_cddl_lib_libuutil} \
1657 ${_cddl_lib_libavl} \
1658 ${_cddl_lib_libzfs_core} \
1659 ${_cddl_lib_libctf} \
1660 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1661 ${_secure_lib_libcrypto} ${_lib_libldns} \
1662 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1664 .if ${MK_GNUCXX} != "no"
1665 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1666 gnu/lib/libstdc++__L: lib/msun__L
1667 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1670 lib/libgeom__L: lib/libexpat__L
1672 .if ${MK_LIBTHR} != "no"
1673 _lib_libthr= lib/libthr
1676 .if ${MK_RADIUS_SUPPORT} != "no"
1677 _lib_libradius= lib/libradius
1680 .if ${MK_OFED} != "no"
1681 _ofed_lib= contrib/ofed/usr.lib/
1684 .if ${MK_CASPER} != "no"
1685 _lib_libcapsicum=lib/libcapsicum
1688 lib/libcapsicum__L: lib/libnv__L
1689 lib/libpjdlog__L: lib/libutil__L
1691 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1692 .for _DIR in ${LOCAL_LIB_DIRS}
1693 .if exists(${.CURDIR}/${_DIR}/Makefile)
1694 _generic_libs+= ${_DIR}
1698 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1700 .if ${MK_CDDL} != "no"
1701 _cddl_lib_libumem= cddl/lib/libumem
1702 _cddl_lib_libnvpair= cddl/lib/libnvpair
1703 _cddl_lib_libavl= cddl/lib/libavl
1704 _cddl_lib_libuutil= cddl/lib/libuutil
1705 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1706 _cddl_lib_libctf= cddl/lib/libctf
1708 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1709 cddl/lib/libzfs__L: lib/libgeom__L
1710 cddl/lib/libctf__L: lib/libz__L
1713 .if ${MK_CRYPT} != "no"
1714 .if ${MK_OPENSSL} != "no"
1715 _secure_lib_libcrypto= secure/lib/libcrypto
1716 _secure_lib_libssl= secure/lib/libssl
1717 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1718 .if ${MK_LDNS} != "no"
1719 _lib_libldns= lib/libldns
1720 lib/libldns__L: secure/lib/libcrypto__L
1722 .if ${MK_OPENSSH} != "no"
1723 _secure_lib_libssh= secure/lib/libssh
1724 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1725 .if ${MK_LDNS} != "no"
1726 secure/lib/libssh__L: lib/libldns__L
1728 .if ${MK_KERBEROS_SUPPORT} != "no"
1729 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1730 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1731 lib/libmd__L kerberos5/lib/libroken__L
1735 _secure_lib= secure/lib
1738 .if ${MK_KERBEROS} != "no"
1739 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1740 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1741 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1742 kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
1743 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1744 kerberos5/lib/libroken__L lib/libcom_err__L
1745 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1746 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1747 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1748 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1749 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1750 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1751 kerberos5/lib/libroken__L: lib/libcrypt__L
1752 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1753 kerberos5/lib/libheimbase__L: lib/libthr__L
1754 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1755 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1758 .if ${MK_GSSAPI} != "no"
1759 _lib_libgssapi= lib/libgssapi
1762 .if ${MK_KERBEROS} != "no"
1763 _kerberos5_lib= kerberos5/lib
1764 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1765 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1766 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1767 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1768 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1769 _kerberos5_lib_libroken= kerberos5/lib/libroken
1770 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1771 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1772 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1773 _kerberos5_lib_libwind= kerberos5/lib/libwind
1774 _libcom_err= lib/libcom_err
1777 .if ${MK_NIS} != "no"
1778 _lib_libypclnt= lib/libypclnt
1781 .if ${MK_OPENSSL} == "no"
1782 lib/libradius__L: lib/libmd__L
1785 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
1787 .for _lib in ${_prereq_libs}
1788 ${_lib}__PL: .PHONY .MAKE
1789 .if exists(${.CURDIR}/${_lib})
1790 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1791 cd ${.CURDIR}/${_lib} && \
1792 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1793 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1794 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1795 DIRPRFX=${_lib}/ all && \
1796 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1797 DIRPRFX=${_lib}/ install
1801 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1802 ${_lib}__L: .PHONY .MAKE
1803 .if exists(${.CURDIR}/${_lib})
1804 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1805 cd ${.CURDIR}/${_lib} && \
1806 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1807 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1808 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all && \
1809 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1813 # libpam is special: we need to build static PAM modules before
1814 # static PAM library, and dynamic PAM library before dynamic PAM
1816 lib/libpam__L: .PHONY .MAKE
1817 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1818 cd ${.CURDIR}/lib/libpam && \
1819 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj && \
1820 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend && \
1821 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1822 -D_NO_LIBPAM_SO_YET all && \
1823 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1824 -D_NO_LIBPAM_SO_YET install
1826 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1827 _startup_libs: ${_startup_libs:S/$/__L/}
1828 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1829 _generic_libs: ${_generic_libs:S/$/__L/}
1831 .for __target in all clean cleandepend cleandir depend includes obj
1832 .for entry in ${SUBDIR}
1833 ${entry}.${__target}__D: .PHONY .MAKE
1834 ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1835 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1836 edir=${entry}.${MACHINE_ARCH}; \
1837 cd ${.CURDIR}/$${edir}; \
1839 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1841 cd ${.CURDIR}/$${edir}; \
1843 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1845 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1848 .include <bsd.subdir.mk>
1850 .if make(check-old) || make(check-old-dirs) || \
1851 make(check-old-files) || make(check-old-libs) || \
1852 make(delete-old) || make(delete-old-dirs) || \
1853 make(delete-old-files) || make(delete-old-libs)
1856 # check for / delete old files section
1859 .include "ObsoleteFiles.inc"
1861 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1862 else you can not start such an application. Consult UPDATING for more \
1863 information regarding how to cope with the removal/revision bump of a \
1866 .if !defined(BATCH_DELETE_OLD_FILES)
1873 @echo ">>> Removing old files (only deletes safe to delete libs)"
1874 # Ask for every old file if the user really wants to remove it.
1875 # It's annoying, but better safe than sorry.
1876 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1877 # argument list will get too long. Using .for/.endfor make "loops" will make
1878 # the Makefile parser segfault.
1881 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1882 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1883 while read file; do \
1884 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1885 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1886 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1889 # Remove catpages without corresponding manpages.
1891 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1892 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1893 while read catpage; do \
1895 if [ ! -e "$${manpage}" ]; then \
1896 rm ${RM_I} $${catpage} <&3; \
1899 @echo ">>> Old files removed"
1902 @echo ">>> Checking for old files"
1904 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1905 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1906 while read file; do \
1907 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1908 echo "${DESTDIR}/$${file}"; \
1911 # Check for catpages without corresponding manpages.
1912 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1913 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1914 while read catpage; do \
1916 if [ ! -e "$${manpage}" ]; then \
1922 @echo ">>> Removing old libraries"
1923 @echo "${OLD_LIBS_MESSAGE}" | fmt
1926 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1927 -V OLD_LIBS | xargs -n1 | \
1928 while read file; do \
1929 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1930 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1931 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1933 for ext in debug symbols; do \
1934 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1935 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1936 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1941 @echo ">>> Old libraries removed"
1944 @echo ">>> Checking for old libraries"
1946 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1947 -V OLD_LIBS | xargs -n1 | \
1948 while read file; do \
1949 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1950 echo "${DESTDIR}/$${file}"; \
1952 for ext in debug symbols; do \
1953 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1954 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1960 @echo ">>> Removing old directories"
1962 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1963 -V OLD_DIRS | xargs -n1 | sort -r | \
1964 while read dir; do \
1965 if [ -d "${DESTDIR}/$${dir}" ]; then \
1966 rmdir -v "${DESTDIR}/$${dir}" || true; \
1967 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1968 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1971 @echo ">>> Old directories removed"
1974 @echo ">>> Checking for old directories"
1976 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1977 -V OLD_DIRS | xargs -n1 | \
1978 while read dir; do \
1979 if [ -d "${DESTDIR}/$${dir}" ]; then \
1980 echo "${DESTDIR}/$${dir}"; \
1981 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1982 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1986 delete-old: delete-old-files delete-old-dirs
1987 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1989 check-old: check-old-files check-old-libs check-old-dirs
1990 @echo "To remove old files and directories run '${MAKE} delete-old'."
1991 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1996 # showconfig - show build configuration.
1999 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2000 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2002 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2003 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2005 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2006 .if exists(${KERNCONFDIR}/${KERNCONF})
2007 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2008 '${KERNCONFDIR}/${KERNCONF}' ; echo
2014 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2015 DTBOUTPUTPATH= ${.CURDIR}
2019 # Build 'standalone' Device Tree Blob
2022 @PATH=${TMPPATH} MACHINE=${TARGET} \
2023 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2024 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2028 .if defined(TARGET) && defined(TARGET_ARCH)
2030 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2031 XDEV_CPUTYPE?=${CPUTYPE}
2033 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2036 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2037 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2038 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2040 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2041 CPUTYPE=${XDEV_CPUTYPE} -DNO_SHARE
2043 XDDIR=${TARGET_ARCH}-freebsd
2046 .error XDTP variable should be an absolute path
2049 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2050 INSTALL="sh ${.CURDIR}/tools/install.sh"
2052 _SHLIBDIRPREFIX=${XDDESTDIR} \
2053 TOOLS_PREFIX=${XDTP}
2054 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2055 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2056 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2057 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2058 CPP="${CPP} ${CD2CFLAGS}" \
2059 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2061 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2062 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2063 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2064 XDDESTDIR=${DESTDIR}/${XDTP}
2066 OSREL!= uname -r | sed -e 's/[-(].*//'
2069 .ORDER: xdev-build xdev-install xdev-links
2070 xdev: xdev-build xdev-install
2072 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2073 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2076 mkdir -p ${CDTMP}/usr
2077 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2078 -p ${CDTMP}/usr >/dev/null
2080 _xb-bootstrap-tools:
2084 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2085 cd ${.CURDIR}/${_tool} && \
2086 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2087 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2088 ${CDMAKE} DIRPRFX=${_tool}/ all && \
2089 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2093 ${_+_}@cd ${.CURDIR}; \
2094 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2104 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2105 cd ${.CURDIR}/${_tool} && \
2106 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2107 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2108 ${CDMAKE} DIRPRFX=${_tool}/ all
2112 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2113 mkdir -p ${XDDESTDIR}
2114 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2115 -p ${XDDESTDIR} >/dev/null
2116 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2117 -p ${XDDESTDIR}/usr >/dev/null
2118 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2119 -p ${XDDESTDIR}/usr/include >/dev/null
2120 .if ${MK_TESTS} != "no"
2121 mkdir -p ${XDDESTDIR}${TESTSBASE}
2122 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2123 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2126 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2127 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2130 @echo "_xi-cross-tools"
2138 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2139 cd ${.CURDIR}/${_tool}; \
2140 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2144 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2145 DESTDIR=${XDDESTDIR}
2148 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2149 DESTDIR=${XDDESTDIR}
2152 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2153 mkdir -p ../../../../usr/bin; \
2155 ln -sf ../../${XDTP}/usr/bin/$$i \
2156 ../../../../usr/bin/${XDDIR}-$$i; \
2157 ln -sf ../../${XDTP}/usr/bin/$$i \
2158 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2161 xdev xdev-build xdev-install xdev-links:
2162 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"