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 lib/ and libexec/ before bin/, because if installworld
54 # installs a new /bin/sh, the 'make' command will *immediately*
55 # use that new version. And the new (dynamically-linked) /bin/sh
56 # will expect to find appropriate libraries in /lib and /libexec.
59 .if defined(SUBDIR_OVERRIDE)
60 SUBDIR= ${SUBDIR_OVERRIDE}
64 .if ${MK_GAMES} != "no"
67 .if ${MK_CDDL} != "no"
71 .if ${MK_KERBEROS} != "no"
74 .if ${MK_RESCUE} != "no"
78 .if ${MK_CRYPT} != "no"
81 .if !defined(NO_SHARE)
84 SUBDIR+=sys usr.bin usr.sbin
85 .if ${MK_TESTS} != "no"
88 .if ${MK_OFED} != "no"
92 # We must do etc/ last for install/distribute to work.
96 # Local directories are last, since it is nice to at least get the base
97 # system rebuilt before you do them.
98 .for _DIR in ${LOCAL_DIRS}
99 .if exists(${.CURDIR}/${_DIR}/Makefile)
103 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
104 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
105 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
106 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
107 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
109 .for _DIR in ${LOCAL_LIB_DIRS}
110 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
113 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
121 .if defined(NO_CLEANDIR)
122 CLEANDIR= clean cleandepend
129 BUILDENV_SHELL?=/bin/sh
131 SVN?= /usr/local/bin/svn
134 MAKEOBJDIRPREFIX?= /usr/obj
135 .if !defined(OSRELDATE)
136 .if exists(/usr/include/osreldate.h)
137 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
138 /usr/include/osreldate.h
144 .if !defined(VERSION)
145 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
146 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
147 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
148 ${SRCDIR}/sys/sys/param.h
149 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
152 .if !defined(PKG_VERSION)
153 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
154 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
155 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
156 ${SRCDIR}/sys/sys/param.h
157 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
158 TIMENOW!= TZ=UTC date +%Y%m%d%H%M%S
159 EXTRA_REVISION= .s${TIMENOW}
162 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
164 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
167 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
168 .if ${TARGET} == ${TARGET_ARCH}
171 _t= ${TARGET_ARCH}/${TARGET}
174 .if empty(KNOWN_ARCHES:M${_t})
175 .error Unknown target ${TARGET_ARCH}:${TARGET}.
179 .if ${TARGET} == ${MACHINE}
180 TARGET_CPUTYPE?=${CPUTYPE}
185 .if !empty(TARGET_CPUTYPE)
186 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
188 _TARGET_CPUTYPE=dummy
190 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
191 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
192 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
193 .error CPUTYPE global should be set with ?=.
196 BUILD_ARCH!= uname -p
197 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
198 .error To cross-build, set TARGET_ARCH.
201 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
202 OBJTREE= ${MAKEOBJDIRPREFIX}
204 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
206 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
207 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
208 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
209 STRICTTMPPATH= ${BPATH}:${XPATH}
210 TMPPATH= ${STRICTTMPPATH}:${PATH}
213 # Avoid running mktemp(1) unless actually needed.
214 # It may not be functional, e.g., due to new ABI
215 # when in the middle of installing over this system.
217 .if make(distributeworld) || make(installworld) || make(stageworld)
218 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
222 # Building a world goes through the following stages
224 # 1. legacy stage [BMAKE]
225 # This stage is responsible for creating compatibility
226 # shims that are needed by the bootstrap-tools,
227 # build-tools and cross-tools stages.
228 # 1. bootstrap-tools stage [BMAKE]
229 # This stage is responsible for creating programs that
230 # are needed for backward compatibility reasons. They
231 # are not built as cross-tools.
232 # 2. build-tools stage [TMAKE]
233 # This stage is responsible for creating the object
234 # tree and building any tools that are needed during
236 # 3. cross-tools stage [XMAKE]
237 # This stage is responsible for creating any tools that
238 # are needed for cross-builds. A cross-compiler is one
240 # 4. world stage [WMAKE]
241 # This stage actually builds the world.
242 # 5. install stage (optional) [IMAKE]
243 # This stage installs a previously built world.
248 # Common environment for world related stages
249 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
250 MACHINE_ARCH=${TARGET_ARCH} \
252 CPUTYPE=${TARGET_CPUTYPE}
253 .if ${MK_GROFF} != "no"
254 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
255 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
256 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
258 .if defined(TARGET_CFLAGS)
259 CROSSENV+= ${TARGET_CFLAGS}
262 # bootstrap-tools stage
263 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
264 PATH=${BPATH}:${PATH} \
265 WORLDTMP=${WORLDTMP} \
266 VERSION="${VERSION}" \
267 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
268 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
269 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
271 BOOTSTRAPPING=${OSRELDATE} \
273 MK_HTML=no NO_LINT=yes MK_MAN=no \
274 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
275 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
276 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
277 MK_LLDB=no MK_TESTS=no
280 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
281 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
282 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
284 BOOTSTRAPPING=${OSRELDATE} \
287 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
288 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
289 MK_LLDB=no MK_TESTS=no
292 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
293 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
294 MK_GDB=no MK_TESTS=no
297 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
298 PATH=${BPATH}:${PATH} \
299 WORLDTMP=${WORLDTMP} \
301 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
302 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
304 BOOTSTRAPPING=${OSRELDATE} \
306 MK_HTML=no -DNO_LINT MK_MAN=no \
307 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
308 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
311 WMAKEENV= ${CROSSENV} \
312 _SHLIBDIRPREFIX=${WORLDTMP} \
314 VERSION="${VERSION}" \
315 INSTALL="sh ${.CURDIR}/tools/install.sh" \
319 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
321 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
324 .if ${MK_CDDL} == "no"
328 .if defined(CROSS_TOOLCHAIN)
329 LOCALBASE?= /usr/local
330 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
332 .if defined(CROSS_TOOLCHAIN_PREFIX)
333 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
334 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
336 XCOMPILERS= CC CXX CPP
337 .for COMPILER in ${XCOMPILERS}
338 .if defined(CROSS_COMPILER_PREFIX)
339 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
341 X${COMPILER}?= ${${COMPILER}}
344 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
345 .for BINUTIL in ${XBINUTILS}
346 .if defined(CROSS_BINUTILS_PREFIX)
347 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
349 X${BINUTIL}?= ${${BINUTIL}}
352 WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
353 DEPFLAGS="${DEPFLAGS}" \
354 CPP="${XCPP} ${XCFLAGS}" \
355 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
356 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
357 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
361 .if defined(CROSS_BINUTILS_PREFIX)
362 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
363 # directory, but the compiler will look in the right place for it's
364 # tools so we don't need to tell it where to look.
365 .if exists(${CROSS_BINUTILS_PREFIX})
366 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
369 BFLAGS+= -B${WORLDTMP}/usr/bin
371 .if ${TARGET} == "arm"
372 .if ${TARGET_ARCH:M*hf*} != ""
373 TARGET_ABI= gnueabihf
378 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
379 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
380 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
381 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
384 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
385 XCFLAGS+= -target ${TARGET_TRIPLE}
386 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
387 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
390 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
391 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
393 XCXXFLAGS+= ${BFLAGS}
397 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
399 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
401 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
402 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
404 .if ${TARGET_ARCH} == "amd64"
405 .if empty(TARGET_CPUTYPE)
406 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
408 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
410 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
411 MACHINE_CPU="i686 mmx sse sse2"
414 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
416 .elif ${TARGET_ARCH} == "powerpc64"
417 .if empty(TARGET_CPUTYPE)
418 LIB32CPUFLAGS= -mcpu=powerpc
420 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
422 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
424 LD="${LD} -m elf32ppc_fbsd"
428 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
429 -isystem ${LIB32TMP}/usr/include/ \
430 -L${LIB32TMP}/usr/lib32 \
431 -B${LIB32TMP}/usr/lib32
433 LIB32FLAGS+= --sysroot=${WORLDTMP}
436 # Yes, the flags are redundant.
437 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
438 _SHLIBDIRPREFIX=${LIB32TMP} \
439 _LDSCRIPTROOT=${LIB32TMP} \
440 VERSION="${VERSION}" \
441 INSTALL="sh ${.CURDIR}/tools/install.sh" \
444 SHLIBDIR=/usr/lib32 \
445 LIBPRIVATEDIR=/usr/lib32/private \
446 DTRACE="${DTRACE} -32"
447 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
448 CXX="${XCXX} ${LIB32FLAGS}" \
449 DESTDIR=${LIB32TMP} \
457 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
459 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
460 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
463 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
464 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
465 ${IMAKE_INSTALL} ${IMAKE_MTREE}
466 .if empty(.MAKEFLAGS:M-n)
467 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
468 LD_LIBRARY_PATH=${INSTALLTMP} \
469 PATH_LOCALE=${INSTALLTMP}/locale
470 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
472 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
474 .if defined(DB_FROM_SRC)
475 INSTALLFLAGS+= -N ${.CURDIR}/etc
476 MTREEFLAGS+= -N ${.CURDIR}/etc
478 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
479 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
481 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
482 IMAKE+= -DNO_ROOT METALOG=${METALOG}
483 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
486 .if defined(BUILD_PKGS)
487 INSTALLFLAGS+= -h sha256
489 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
490 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
491 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
495 KMAKEENV= ${WMAKEENV}
496 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
501 # Attempt to rebuild the entire system, with reasonable chance of
502 # success, regardless of how old your existing system is.
505 .if ${.CURDIR:C/[^,]//g} != ""
506 # The m4 build of sendmail files doesn't like it if ',' is used
507 # anywhere in the path of it's files.
509 @echo "*** Error: path to source tree contains a comma ','"
514 @echo "--------------------------------------------------------------"
515 @echo ">>> Rebuilding the temporary build tree"
516 @echo "--------------------------------------------------------------"
517 .if !defined(NO_CLEAN)
519 .if defined(LIB32TMP)
523 rm -rf ${WORLDTMP}/legacy/usr/include
524 # XXX - These three can depend on any header file.
525 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
526 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
527 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
530 lib usr legacy/bin legacy/usr
531 mkdir -p ${WORLDTMP}/${_dir}
533 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
534 -p ${WORLDTMP}/legacy/usr >/dev/null
535 .if ${MK_GROFF} != "no"
536 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
537 -p ${WORLDTMP}/legacy/usr >/dev/null
539 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
540 -p ${WORLDTMP}/usr >/dev/null
541 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
542 -p ${WORLDTMP}/usr/include >/dev/null
543 ln -sf ${.CURDIR}/sys ${WORLDTMP}
544 .if ${MK_DEBUG_FILES} != "no"
545 # We could instead disable debug files for these build stages
546 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
547 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
548 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
549 -p ${WORLDTMP}/usr/lib >/dev/null
551 .if ${MK_TESTS} != "no"
552 mkdir -p ${WORLDTMP}${TESTSBASE}
553 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
554 -p ${WORLDTMP}${TESTSBASE} >/dev/null
556 .for _mtree in ${LOCAL_MTREE}
557 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
561 @echo "--------------------------------------------------------------"
562 @echo ">>> stage 1.1: legacy release compatibility shims"
563 @echo "--------------------------------------------------------------"
564 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
567 @echo "--------------------------------------------------------------"
568 @echo ">>> stage 1.2: bootstrap tools"
569 @echo "--------------------------------------------------------------"
570 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
572 .if !defined(NO_CLEAN)
574 @echo "--------------------------------------------------------------"
575 @echo ">>> stage 2.1: cleaning up the object tree"
576 @echo "--------------------------------------------------------------"
577 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
578 .if defined(LIB32TMP)
579 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
584 @echo "--------------------------------------------------------------"
585 @echo ">>> stage 2.2: rebuilding the object tree"
586 @echo "--------------------------------------------------------------"
587 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
590 @echo "--------------------------------------------------------------"
591 @echo ">>> stage 2.3: build tools"
592 @echo "--------------------------------------------------------------"
593 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
596 @echo "--------------------------------------------------------------"
597 @echo ">>> stage 3: cross tools"
598 @echo "--------------------------------------------------------------"
599 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
600 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
603 @echo "--------------------------------------------------------------"
604 @echo ">>> stage 4.1: building includes"
605 @echo "--------------------------------------------------------------"
606 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
609 @echo "--------------------------------------------------------------"
610 @echo ">>> stage 4.2: building libraries"
611 @echo "--------------------------------------------------------------"
612 ${_+_}cd ${.CURDIR}; \
613 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
614 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
617 @echo "--------------------------------------------------------------"
618 @echo ">>> stage 4.3: make dependencies"
619 @echo "--------------------------------------------------------------"
620 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
623 @echo "--------------------------------------------------------------"
624 @echo ">>> stage 4.4: building everything"
625 @echo "--------------------------------------------------------------"
626 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
627 .if defined(LIB32TMP)
630 @echo "--------------------------------------------------------------"
631 @echo ">>> stage 5.1: building 32 bit shim libraries"
632 @echo "--------------------------------------------------------------"
633 mkdir -p ${LIB32TMP}/usr/include
634 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
635 -p ${LIB32TMP}/usr >/dev/null
636 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
637 -p ${LIB32TMP}/usr/include >/dev/null
638 .if ${MK_DEBUG_FILES} != "no"
639 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
640 -p ${LIB32TMP}/usr/lib >/dev/null
643 ln -sf ${.CURDIR}/sys ${WORLDTMP}
644 .for _t in obj includes
645 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
646 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
647 .if ${MK_CDDL} != "no"
648 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
650 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
651 .if ${MK_CRYPT} != "no"
652 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
654 .if ${MK_KERBEROS} != "no"
655 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
658 .for _dir in usr.bin/lex/lib
659 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
661 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
662 cd ${.CURDIR}/${_dir}; \
663 WORLDTMP=${WORLDTMP} \
664 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
665 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
666 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
670 ${LIB32WMAKE} -f Makefile.inc1 libraries
671 .for _t in obj depend all
672 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
673 DIRPRFX=libexec/rtld-elf/ ${_t}
674 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
675 DIRPRFX=usr.bin/ldd ${_t}
678 distribute32 install32:
679 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
680 .if ${MK_CDDL} != "no"
681 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
683 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
684 .if ${MK_CRYPT} != "no"
685 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
687 .if ${MK_KERBEROS} != "no"
688 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
690 cd ${.CURDIR}/libexec/rtld-elf; \
691 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
692 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
696 .if !defined(SUBDIR_OVERRIDE)
697 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
699 WMAKE_TGTS+= _cleanobj _obj _build-tools
700 .if !defined(SUBDIR_OVERRIDE)
701 WMAKE_TGTS+= _cross-tools
703 WMAKE_TGTS+= _includes _libraries _depend everything
704 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
708 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
709 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
712 @echo "--------------------------------------------------------------"
713 @echo ">>> World build started on `LC_ALL=C date`"
714 @echo "--------------------------------------------------------------"
718 @echo "--------------------------------------------------------------"
719 @echo ">>> World build completed on `LC_ALL=C date`"
720 @echo "--------------------------------------------------------------"
723 # We need to have this as a target because the indirection between Makefile
724 # and Makefile.inc1 causes the correct PATH to be used, rather than a
725 # modification of the current environment's PATH. In addition, we need
726 # to quote multiword values.
731 .if ${.TARGETS:Mbuildenv}
732 .if ${.MAKEFLAGS:M-j}
733 .error The buildenv target is incompatible with -j
737 @echo Entering world for ${TARGET_ARCH}:${TARGET}
738 @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
740 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
741 toolchain: ${TOOLCHAIN_TGTS}
742 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
747 # Checks to be sure system is ready for installworld/installkernel.
749 installcheck: _installcheck_world _installcheck_kernel
751 _installcheck_kernel:
754 # Require DESTDIR to be set if installing for a different architecture or
755 # using the user/group database in the source tree.
757 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
759 .if !make(distributeworld)
760 _installcheck_world: __installcheck_DESTDIR
761 _installcheck_kernel: __installcheck_DESTDIR
762 __installcheck_DESTDIR:
763 .if !defined(DESTDIR) || empty(DESTDIR)
764 @echo "ERROR: Please set DESTDIR!"; \
770 .if !defined(DB_FROM_SRC)
772 # Check for missing UIDs/GIDs.
774 CHECK_UIDS= auditdistd
776 .if ${MK_SENDMAIL} != "no"
782 CHECK_GIDS+= proxy authpf
784 .if ${MK_UNBOUND} != "no"
788 _installcheck_world: __installcheck_UGID
790 .for uid in ${CHECK_UIDS}
791 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
792 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
796 .for gid in ${CHECK_GIDS}
797 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
798 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
805 # Required install tools to be saved in a scratch dir for safety.
807 .if ${MK_ZONEINFO} != "no"
808 _zoneinfo= zic tzsetup
811 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
812 date echo egrep find grep id install ${_install-info} \
813 ln lockf make mkdir mtree mv pwd_mkdb \
814 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
817 # Needed for share/man
818 .if ${MK_MAN} != "no"
825 # Distributes everything compiled by a `buildworld'.
829 # Installs everything compiled by a 'buildworld'.
832 # Non-base distributions produced by the base system
833 EXTRA_DISTRIBUTIONS= doc
834 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
835 EXTRA_DISTRIBUTIONS+= lib32
837 .if ${MK_TESTS} != "no"
838 EXTRA_DISTRIBUTIONS+= tests
842 .if ${MK_DEBUG_FILES} != "no"
843 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
846 MTREE_MAGIC?= mtree 2.0
848 distributeworld installworld stageworld: _installcheck_world
849 mkdir -p ${INSTALLTMP}
850 progs=$$(for prog in ${ITOOLS}; do \
851 if progpath=`which $$prog`; then \
854 echo "Required tool $$prog not found in PATH." >&2; \
858 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
859 while read line; do \
861 if [ "$$2 $$3" != "not found" ]; then \
864 echo "Required library $$1 not found." >&2; \
868 cp $$libs $$progs ${INSTALLTMP}
869 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
871 echo "#${MTREE_MAGIC}" > ${METALOG}
873 .if make(distributeworld)
874 .for dist in ${EXTRA_DISTRIBUTIONS}
875 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
876 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
877 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
878 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
879 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
880 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
881 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
882 .if ${MK_DEBUG_FILES} != "no"
883 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
884 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
886 .if ${MK_TESTS} != "no" && ${dist} == "tests"
887 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
888 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
889 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
892 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
893 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
894 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
895 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
896 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
897 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
900 -mkdir ${DESTDIR}/${DISTDIR}/base
901 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
902 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
903 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
904 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
906 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
907 ${IMAKEENV} rm -rf ${INSTALLTMP}
908 .if make(distributeworld)
909 .for dist in ${EXTRA_DISTRIBUTIONS}
910 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
913 .for dist in base ${EXTRA_DISTRIBUTIONS}
914 @# For each file that exists in this dist, print the corresponding
915 @# line from the METALOG. This relies on the fact that
916 @# a line containing only the filename will sort immediatly before
917 @# the relevant mtree line.
918 cd ${DESTDIR}/${DISTDIR}; \
919 find ./${dist} | sort -u ${METALOG} - | \
920 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
921 ${DESTDIR}/${DISTDIR}/${dist}.meta
923 .for dist in ${DEBUG_DISTRIBUTIONS}
924 @# For each file that exists in this dist, print the corresponding
925 @# line from the METALOG. This relies on the fact that
926 @# a line containing only the filename will sort immediatly before
927 @# the relevant mtree line.
928 cd ${DESTDIR}/${DISTDIR}; \
929 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
930 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
931 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
937 .for dist in base ${EXTRA_DISTRIBUTIONS}
939 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
940 tar cvf - --exclude usr/lib/debug \
941 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
942 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz
944 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
945 tar cvf - --exclude usr/lib/debug . | \
946 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz
950 .for dist in ${DEBUG_DISTRIBUTIONS}
951 . if defined(NO_ROOT)
952 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
953 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
954 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz
956 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
957 tar cvLf - usr/lib/debug | \
958 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz
965 # If you have a build server, you can NFS mount the source and obj directories
966 # and do a 'make reinstall' on the *client* to install new binaries from the
967 # most recent server build.
970 @echo "--------------------------------------------------------------"
971 @echo ">>> Making hierarchy"
972 @echo "--------------------------------------------------------------"
973 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
974 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
976 @echo "--------------------------------------------------------------"
977 @echo ">>> Installing everything"
978 @echo "--------------------------------------------------------------"
979 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
980 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
981 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
985 @echo "--------------------------------------------------------------"
986 @echo ">>> Making hierarchy"
987 @echo "--------------------------------------------------------------"
988 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
989 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
991 @echo "--------------------------------------------------------------"
992 @echo ">>> Installing everything"
993 @echo "--------------------------------------------------------------"
994 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
995 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
996 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
999 @echo "--------------------------------------------------------------"
1000 @echo ">>> Distributing everything"
1001 @echo "--------------------------------------------------------------"
1002 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1003 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1004 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1008 distrib-dirs distribution: .MAKE
1009 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1010 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1013 # buildkernel and installkernel
1015 # Which kernels to build and/or install is specified by setting
1016 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1017 # Only the existing (depending TARGET) config files are used
1018 # for building kernels and only the first of these is designated
1019 # as the one being installed.
1021 # Note that we have to use TARGET instead of TARGET_ARCH when
1022 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1023 # be set to cross-build, we have to make sure TARGET is set
1026 .if defined(KERNFAST)
1031 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1032 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1033 KERNCONF=${KERNFAST}
1036 .if ${TARGET_ARCH} == "powerpc64"
1037 KERNCONF?= GENERIC64
1041 INSTKERNNAME?= kernel
1043 KERNSRCDIR?= ${.CURDIR}/sys
1044 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1045 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1046 KERNCONFDIR?= ${KRNLCONFDIR}
1050 .for _kernel in ${KERNCONF}
1051 .if exists(${KERNCONFDIR}/${_kernel})
1052 BUILDKERNELS+= ${_kernel}
1053 .if empty(INSTALLKERNEL)
1054 INSTALLKERNEL= ${_kernel}
1059 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
1064 # Builds all kernels defined by BUILDKERNELS.
1067 .if empty(BUILDKERNELS)
1068 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1072 .for _kernel in ${BUILDKERNELS}
1073 @echo "--------------------------------------------------------------"
1074 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1075 @echo "--------------------------------------------------------------"
1076 @echo "===> ${_kernel}"
1077 mkdir -p ${KRNLOBJDIR}
1078 .if !defined(NO_KERNELCONFIG)
1080 @echo "--------------------------------------------------------------"
1081 @echo ">>> stage 1: configuring the kernel"
1082 @echo "--------------------------------------------------------------"
1083 cd ${KRNLCONFDIR}; \
1085 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1086 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1088 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1090 @echo "--------------------------------------------------------------"
1091 @echo ">>> stage 2.1: cleaning up the object tree"
1092 @echo "--------------------------------------------------------------"
1093 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1095 .if !defined(NO_KERNELOBJ)
1097 @echo "--------------------------------------------------------------"
1098 @echo ">>> stage 2.2: rebuilding the object tree"
1099 @echo "--------------------------------------------------------------"
1100 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1103 @echo "--------------------------------------------------------------"
1104 @echo ">>> stage 2.3: build tools"
1105 @echo "--------------------------------------------------------------"
1106 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1107 .if !defined(NO_KERNELDEPEND)
1109 @echo "--------------------------------------------------------------"
1110 @echo ">>> stage 3.1: making dependencies"
1111 @echo "--------------------------------------------------------------"
1112 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1115 @echo "--------------------------------------------------------------"
1116 @echo ">>> stage 3.2: building everything"
1117 @echo "--------------------------------------------------------------"
1118 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1119 @echo "--------------------------------------------------------------"
1120 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1121 @echo "--------------------------------------------------------------"
1125 # installkernel, etc.
1127 # Install the kernel defined by INSTALLKERNEL
1129 installkernel installkernel.debug \
1130 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1131 .if empty(INSTALLKERNEL)
1132 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1135 @echo "--------------------------------------------------------------"
1136 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1137 @echo "--------------------------------------------------------------"
1138 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1139 ${CROSSENV} PATH=${TMPPATH} \
1140 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1142 distributekernel distributekernel.debug:
1143 .if empty(INSTALLKERNEL)
1144 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1147 mkdir -p ${DESTDIR}/${DISTDIR}
1148 .if defined(NO_ROOT)
1149 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1151 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1152 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1153 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1154 DESTDIR=${INSTALL_DDIR}/kernel \
1155 ${.TARGET:S/distributekernel/install/}
1156 .if defined(NO_ROOT)
1157 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1158 ${DESTDIR}/${DISTDIR}/kernel.meta
1160 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1161 .if defined(NO_ROOT)
1162 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1164 cd ${KRNLOBJDIR}/${_kernel}; \
1165 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1166 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1167 KERNEL=${INSTKERNNAME}.${_kernel} \
1168 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1169 ${.TARGET:S/distributekernel/install/}
1170 .if defined(NO_ROOT)
1171 sed -e 's|^./kernel|.|' \
1172 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1173 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1178 .if defined(NO_ROOT)
1179 cd ${DESTDIR}/${DISTDIR}/kernel; \
1180 tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \
1181 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
1182 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1183 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1184 tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1185 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
1188 cd ${DESTDIR}/${DISTDIR}/kernel; \
1190 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
1191 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1192 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1194 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
1198 create-world-packages:
1199 .if !defined(NO_ROOT)
1200 @echo "ERROR: create-world-package can only be done with -DNO_ROOT"; \
1204 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1206 @for plist in ${DESTDIR}/*.plist; do \
1207 plist=$${plist##*/} ; \
1208 test -d ${SRCDIR}/release/packages/$${plist%.plist} || \
1209 ( echo "Unkown package FreeBSD-$${plist%.plist}" ; false ) ; \
1211 @for plist in ${DESTDIR}/*.plist; do \
1212 plist=$${plist##*/} ; \
1213 pkgname=$${plist%.plist} ; \
1214 rm -rf ${DESTDIR}/$${pkgname}-manifestdir ; \
1215 cp -r ${SRCDIR}/release/packages/$${pkgname} \
1216 ${DESTDIR}/$${pkgname}-manifestdir ; \
1217 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \
1218 -e "s/%PKGNAME%/$${pkgname}/" \
1219 -e "s/%COMMENT%/Generic comment for $${pkgname}/" \
1220 -e "s/%DESC%/Generic description for $${pkgname}/" \
1221 ${DESTDIR}/$${pkgname}-manifestdir/+MANIFEST ; \
1222 awk -F\" '/name/ { printf("===> Creating %s-", $$2) } /version/ {print $$2 }' \
1223 ${DESTDIR}/$${pkgname}-manifestdir/+MANIFEST ; \
1224 pkg create -m ${DESTDIR}/$${pkgname}-manifestdir \
1225 -p ${DESTDIR}/$${pkgname}.plist \
1226 -r ${DESTDIR} -o ${DESTDIR} ; \
1230 .if !defined(NO_ROOT)
1231 @echo "ERROR: kernel-pkgs can only be done with -DNO_ROOT"; \
1234 @cd ${DESTDIR}/${DISTDIR} ; \
1235 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1236 ${DESTDIR}/${DISTDIR}/kernel.meta
1237 .for flavor in release debug
1238 .if exists(${DESTDIR}/${DISTDIR}/${flavor}.plist)
1239 @rm -rf ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1240 @cp -r ${SRCDIR}/release/packages/kernel \
1241 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1242 @cd ${DESTDIR}/${DISTDIR} ; \
1243 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \
1244 -e "s/%PKGNAME%/kernel-${flavor}/" \
1245 -e "s/%COMMENT%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1246 -e "s/%DESC%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1247 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1248 @awk -F\" '/name/ { printf("===> Creating %s-", $$2) } /version/ {print $$2 }' \
1249 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1250 @pkg create -m ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir \
1251 -p ${DESTDIR}/${DISTDIR}/${flavor}.plist \
1252 -r ${DESTDIR}/${DISTDIR}/kernel \
1256 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1257 @cd ${DESTDIR}/${DISTDIR} ; \
1258 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1259 ${DESTDIR}/${DISTDIR}/kernel${_kernel}.meta
1260 .for flavor in release debug
1261 .if exists(${DESTDIR}/${DISTDIR}/${flavor}.plist)
1262 @rm -rf ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1263 @cp -r ${SRCDIR}/release/packages/kernel \
1264 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1265 @cd ${DESTDIR}/${DISTDIR} ; \
1266 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \
1267 -e "s/%PKGNAME%/kernel-${flavor}/" \
1268 -e "s/%COMMENT%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1269 -e "s/%DESC%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1270 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1271 @awk -F\" '/name/ { printf("===> Creating %s-", $$2) } /version/ {print $$2 }' \
1272 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1273 @pkg create -m ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir \
1274 -p ${DESTDIR}/${DISTDIR}/${flavor}.plist \
1275 -r ${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
1284 # Build the API documentation with doxygen
1287 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1288 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1291 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1296 # Update the source tree(s), by running svn/svnup to update to the
1300 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1301 @echo "--------------------------------------------------------------"
1302 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1303 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1304 @echo "--------------------------------------------------------------"
1307 .if defined(SVN_UPDATE)
1308 @echo "--------------------------------------------------------------"
1309 @echo ">>> Updating ${.CURDIR} using Subversion"
1310 @echo "--------------------------------------------------------------"
1311 @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1315 # ------------------------------------------------------------------------
1317 # From here onwards are utility targets used by the 'make world' and
1318 # related targets. If your 'world' breaks, you may like to try to fix
1319 # the problem and manually run the following targets to attempt to
1320 # complete the build. Beware, this is *not* guaranteed to work, you
1321 # need to have a pretty good grip on the current state of the system
1322 # to attempt to manually finish it. If in doubt, 'make world' again.
1326 # legacy: Build compatibility shims for the next three targets
1329 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1330 @echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
1333 .for _tool in tools/build
1334 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1335 cd ${.CURDIR}/${_tool} && \
1336 ${MAKE} DIRPRFX=${_tool}/ obj && \
1337 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1338 ${MAKE} DIRPRFX=${_tool}/ depend && \
1339 ${MAKE} DIRPRFX=${_tool}/ all && \
1340 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1344 # bootstrap-tools: Build tools needed for compatibility
1346 _bt= _bootstrap-tools
1348 .if ${MK_GAMES} != "no"
1349 _strfile= games/fortune/strfile
1352 .if ${MK_CXX} != "no"
1353 _gperf= gnu/usr.bin/gperf
1356 .if ${MK_GROFF} != "no"
1357 _groff= gnu/usr.bin/groff
1360 .if ${MK_VT} != "no"
1361 _vtfontcvt= usr.bin/vtfontcvt
1364 .if ${BOOTSTRAPPING} < 900002
1368 .if ${BOOTSTRAPPING} < 1000002
1372 ${_bt}-usr.bin/m4: ${_bt}-lib/libohash
1375 .if ${BOOTSTRAPPING} < 1000014
1376 _crunch= usr.sbin/crunch
1379 .if ${BOOTSTRAPPING} < 1000026
1380 _nmtree= lib/libnetbsd \
1383 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1386 .if ${BOOTSTRAPPING} < 1000027
1390 .if ${BOOTSTRAPPING} < 1000033
1394 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1398 .if ${BOOTSTRAPPING} < 1001506
1402 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1405 .if ${MK_BSNMP} != "no"
1406 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1409 # We need to build tblgen when we're building clang either as
1410 # the bootstrap compiler, or as the part of the normal build.
1411 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1413 lib/clang/libllvmsupport \
1414 lib/clang/libllvmtablegen \
1415 usr.bin/clang/tblgen \
1416 usr.bin/clang/clang-tblgen
1418 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1419 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1422 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1423 # dtrace tools are required for older bootstrap env and cross-build
1425 .if ${BOOTSTRAPPING} < 1100006 || (${MACHINE} != ${TARGET} || \
1426 ${MACHINE_ARCH} != ${TARGET_ARCH})
1427 _elftoolchain_libs= lib/libelf lib/libdwarf
1428 .if ${MK_CDDL} != "no"
1429 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \
1430 cddl/usr.bin/ctfmerge
1432 ${_bt}-cddl/usr.bin/ctfconvert: ${_bt}-lib/libelf ${_bt}-lib/libdwarf ${_bt}-cddl/lib/libctf
1433 ${_bt}-cddl/usr.bin/ctfmerge: ${_bt}-lib/libelf ${_bt}-lib/libdwarf ${_bt}-cddl/lib/libctf
1437 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1440 .if ${MK_GPL_DTC} != "no"
1441 _dtc= gnu/usr.bin/dtc
1444 .if ${MK_KERBEROS} != "no"
1445 _kerberos5_bootstrap_tools= \
1446 kerberos5/tools/make-roken \
1447 kerberos5/lib/libroken \
1448 kerberos5/lib/libvers \
1449 kerberos5/tools/asn1_compile \
1450 kerberos5/tools/slc \
1453 ${_bt}-kerberos5/tools/slc: ${_bt}-kerberos5/lib/libroken
1454 ${_bt}-kerberos5/tools/asn1_compile: ${_bt}-kerberos5/lib/libroken
1457 bootstrap-tools: .PHONY
1459 # Please document (add comment) why something is in 'bootstrap-tools'.
1460 # Try to bound the building of the bootstrap-tool to just the
1461 # FreeBSD versions that need the tool built at this stage of the build.
1464 ${_kerberos5_bootstrap_tools} \
1465 ${_elftoolchain_libs} \
1474 usr.bin/makewhatis \
1487 ${_bt}-${_tool}: .PHONY .MAKE
1488 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1489 cd ${.CURDIR}/${_tool} && \
1490 ${MAKE} DIRPRFX=${_tool}/ obj && \
1491 ${MAKE} DIRPRFX=${_tool}/ depend && \
1492 ${MAKE} DIRPRFX=${_tool}/ all && \
1493 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1495 bootstrap-tools: ${_bt}-${_tool}
1499 # build-tools: Build special purpose build tools
1501 .if !defined(NO_SHARE)
1502 _share= share/syscons/scrnmaps
1505 .if ${MK_GCC} != "no"
1506 _gcc_tools= gnu/usr.bin/cc/cc_tools
1509 .if ${MK_RESCUE} != "no"
1510 _rescue= rescue/rescue
1518 ${LOCAL_TOOL_DIRS} \
1519 lib/ncurses/ncurses \
1520 lib/ncurses/ncursesw \
1524 usr.bin/mkesdb_static \
1525 usr.bin/mkcsmapper_static \
1527 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1528 cd ${.CURDIR}/${_tool} && \
1529 ${MAKE} DIRPRFX=${_tool}/ obj && \
1530 ${MAKE} DIRPRFX=${_tool}/ build-tools
1534 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1535 cd ${.CURDIR}/${_tool} && \
1536 ${MAKE} DIRPRFX=${_tool}/ obj && \
1537 ${MAKE} DIRPRFX=${_tool}/ depend && \
1538 ${MAKE} DIRPRFX=${_tool}/ all
1542 # kernel-tools: Build kernel-building tools
1545 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1546 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1547 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1550 # cross-tools: Build cross-building tools
1552 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1553 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1554 _btxld= usr.sbin/btxld
1557 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1558 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1559 _crunchide= usr.sbin/crunch/crunchide
1561 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1562 _kgzip= usr.sbin/kgzip
1566 # If we're given an XAS, don't build binutils.
1567 .if ${XAS:M/*} == ""
1568 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1569 _binutils= gnu/usr.bin/binutils
1571 .if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
1572 _elftctools= lib/libelftc \
1577 # These are not required by the build, but can be useful for developers who
1578 # cross-build on a FreeBSD 10 host:
1579 _elftctools+= usr.bin/addr2line
1583 # If an full path to an external cross compiler is given, don't build
1585 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1586 .if ${MK_CLANG_BOOTSTRAP} != "no"
1587 _clang= usr.bin/clang
1588 _clang_libs= lib/clang
1590 .if ${MK_GCC_BOOTSTRAP} != "no"
1602 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1607 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1608 cd ${.CURDIR}/${_tool} && \
1609 ${MAKE} DIRPRFX=${_tool}/ obj && \
1610 ${MAKE} DIRPRFX=${_tool}/ depend && \
1611 ${MAKE} DIRPRFX=${_tool}/ all && \
1612 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1615 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1616 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1617 VERSION="${VERSION}"
1618 NXBMAKE= ${NXBENV} ${MAKE} \
1619 TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
1620 CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
1621 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1622 MK_GDB=no MK_TESTS=no \
1624 MK_HTML=no NO_LINT=yes MK_MAN=no \
1625 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1626 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1627 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1630 native-xtools: .MAKE
1631 mkdir -p ${OBJTREE}/nxb-bin/bin
1632 mkdir -p ${OBJTREE}/nxb-bin/sbin
1633 mkdir -p ${OBJTREE}/nxb-bin/usr
1634 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1635 -p ${OBJTREE}/nxb-bin/usr >/dev/null
1636 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1637 -p ${OBJTREE}/nxb-bin/usr/include >/dev/null
1697 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1698 cd ${.CURDIR}/${_tool} && \
1699 ${NXBMAKE} DIRPRFX=${_tool}/ obj && \
1700 ${NXBMAKE} DIRPRFX=${_tool}/ depend && \
1701 ${NXBMAKE} DIRPRFX=${_tool}/ all && \
1702 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install
1706 # hierarchy - ensure that all the needed directories are present
1708 hierarchy hier: .MAKE
1709 cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1712 # libraries - build all libraries, and install them under ${DESTDIR}.
1714 # The list of libraries with dependents (${_prebuild_libs}) and their
1715 # interdependencies (__L) are built automatically by the
1716 # ${.CURDIR}/tools/make_libdeps.sh script.
1720 ${MAKE} -f Makefile.inc1 _prereq_libs && \
1721 ${MAKE} -f Makefile.inc1 _startup_libs && \
1722 ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1723 ${MAKE} -f Makefile.inc1 _generic_libs
1726 # static libgcc.a prerequisite for shared libc
1728 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1730 # These dependencies are not automatically generated:
1732 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1733 # all shared libraries for ELF.
1735 _startup_libs= gnu/lib/csu
1736 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1737 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1738 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1739 _startup_libs+= lib/csu/${MACHINE_ARCH}
1741 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1743 _startup_libs+= gnu/lib/libgcc
1744 _startup_libs+= lib/libcompiler_rt
1745 _startup_libs+= lib/libc
1746 _startup_libs+= lib/libc_nonshared
1747 .if ${MK_LIBCPLUSPLUS} != "no"
1748 _startup_libs+= lib/libcxxrt
1751 gnu/lib/libgcc__L: lib/libc__L
1752 gnu/lib/libgcc__L: lib/libc_nonshared__L
1753 .if ${MK_LIBCPLUSPLUS} != "no"
1754 lib/libcxxrt__L: gnu/lib/libgcc__L
1757 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1758 ${_kerberos5_lib_libhdb} \
1759 ${_kerberos5_lib_libheimbase} \
1760 ${_kerberos5_lib_libheimntlm} \
1761 ${_kerberos5_lib_libheimsqlite} \
1762 ${_kerberos5_lib_libheimipcc} \
1763 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1764 ${_kerberos5_lib_libroken} \
1765 ${_kerberos5_lib_libwind} \
1766 lib/libbz2 ${_libcom_err} lib/libcrypt \
1767 lib/libelf lib/libexpat \
1770 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1771 ${_lib_libcapsicum} \
1772 lib/ncurses/ncurses lib/ncurses/ncursesw \
1773 lib/libopie lib/libpam ${_lib_libthr} \
1774 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1776 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1777 ${_cddl_lib_libuutil} \
1778 ${_cddl_lib_libavl} \
1779 ${_cddl_lib_libzfs_core} \
1780 ${_cddl_lib_libctf} \
1781 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1782 ${_secure_lib_libcrypto} ${_lib_libldns} \
1783 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1785 .if ${MK_GNUCXX} != "no"
1786 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1787 gnu/lib/libstdc++__L: lib/msun__L
1788 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1791 lib/libgeom__L: lib/libexpat__L
1793 .if ${MK_LIBTHR} != "no"
1794 _lib_libthr= lib/libthr
1797 .if ${MK_RADIUS_SUPPORT} != "no"
1798 _lib_libradius= lib/libradius
1801 .if ${MK_OFED} != "no"
1802 _ofed_lib= contrib/ofed/usr.lib/
1805 .if ${MK_CASPER} != "no"
1806 _lib_libcapsicum=lib/libcapsicum
1809 lib/libcapsicum__L: lib/libnv__L
1810 lib/libpjdlog__L: lib/libutil__L
1811 lib/liblzma__L: lib/libthr__L
1813 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1814 .for _DIR in ${LOCAL_LIB_DIRS}
1815 .if exists(${.CURDIR}/${_DIR}/Makefile)
1816 _generic_libs+= ${_DIR}
1820 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1822 .if ${MK_CDDL} != "no"
1823 _cddl_lib_libumem= cddl/lib/libumem
1824 _cddl_lib_libnvpair= cddl/lib/libnvpair
1825 _cddl_lib_libavl= cddl/lib/libavl
1826 _cddl_lib_libuutil= cddl/lib/libuutil
1827 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1828 _cddl_lib_libctf= cddl/lib/libctf
1830 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1831 cddl/lib/libzfs__L: lib/libgeom__L
1832 cddl/lib/libctf__L: lib/libz__L
1835 .if ${MK_CRYPT} != "no"
1836 .if ${MK_OPENSSL} != "no"
1837 _secure_lib_libcrypto= secure/lib/libcrypto
1838 _secure_lib_libssl= secure/lib/libssl
1839 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1840 .if ${MK_LDNS} != "no"
1841 _lib_libldns= lib/libldns
1842 lib/libldns__L: secure/lib/libcrypto__L
1844 .if ${MK_OPENSSH} != "no"
1845 _secure_lib_libssh= secure/lib/libssh
1846 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1847 .if ${MK_LDNS} != "no"
1848 secure/lib/libssh__L: lib/libldns__L
1850 .if ${MK_KERBEROS_SUPPORT} != "no"
1851 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1852 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1853 lib/libmd__L kerberos5/lib/libroken__L
1857 _secure_lib= secure/lib
1860 .if ${MK_KERBEROS} != "no"
1861 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1862 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1863 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1864 kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
1865 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1866 kerberos5/lib/libroken__L lib/libcom_err__L
1867 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1868 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1869 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1870 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1871 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1872 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1873 kerberos5/lib/libroken__L: lib/libcrypt__L
1874 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1875 kerberos5/lib/libheimbase__L: lib/libthr__L
1876 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1877 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1880 .if ${MK_GSSAPI} != "no"
1881 _lib_libgssapi= lib/libgssapi
1884 .if ${MK_KERBEROS} != "no"
1885 _kerberos5_lib= kerberos5/lib
1886 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1887 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1888 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1889 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1890 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1891 _kerberos5_lib_libroken= kerberos5/lib/libroken
1892 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1893 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1894 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1895 _kerberos5_lib_libwind= kerberos5/lib/libwind
1896 _libcom_err= lib/libcom_err
1899 .if ${MK_NIS} != "no"
1900 _lib_libypclnt= lib/libypclnt
1903 .if ${MK_OPENSSL} == "no"
1904 lib/libradius__L: lib/libmd__L
1907 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
1909 .for _lib in ${_prereq_libs}
1910 ${_lib}__PL: .PHONY .MAKE
1911 .if exists(${.CURDIR}/${_lib})
1912 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1913 cd ${.CURDIR}/${_lib} && \
1914 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1915 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1916 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1917 DIRPRFX=${_lib}/ all && \
1918 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1919 DIRPRFX=${_lib}/ install
1923 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1924 ${_lib}__L: .PHONY .MAKE
1925 .if exists(${.CURDIR}/${_lib})
1926 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1927 cd ${.CURDIR}/${_lib} && \
1928 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1929 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1930 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all && \
1931 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1935 # libpam is special: we need to build static PAM modules before
1936 # static PAM library, and dynamic PAM library before dynamic PAM
1938 lib/libpam__L: .PHONY .MAKE
1939 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1940 cd ${.CURDIR}/lib/libpam && \
1941 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj && \
1942 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend && \
1943 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1944 -D_NO_LIBPAM_SO_YET all && \
1945 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1946 -D_NO_LIBPAM_SO_YET install
1948 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1949 _startup_libs: ${_startup_libs:S/$/__L/}
1950 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1951 _generic_libs: ${_generic_libs:S/$/__L/}
1953 .for __target in all clean cleandepend cleandir depend includes obj
1954 .for entry in ${SUBDIR}
1955 ${entry}.${__target}__D: .PHONY .MAKE
1956 ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1957 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1958 edir=${entry}.${MACHINE_ARCH}; \
1959 cd ${.CURDIR}/$${edir}; \
1961 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1963 cd ${.CURDIR}/$${edir}; \
1965 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1967 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1970 .include <bsd.subdir.mk>
1972 .if make(check-old) || make(check-old-dirs) || \
1973 make(check-old-files) || make(check-old-libs) || \
1974 make(delete-old) || make(delete-old-dirs) || \
1975 make(delete-old-files) || make(delete-old-libs)
1978 # check for / delete old files section
1981 .include "ObsoleteFiles.inc"
1983 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1984 else you can not start such an application. Consult UPDATING for more \
1985 information regarding how to cope with the removal/revision bump of a \
1988 .if !defined(BATCH_DELETE_OLD_FILES)
1995 @echo ">>> Removing old files (only deletes safe to delete libs)"
1996 # Ask for every old file if the user really wants to remove it.
1997 # It's annoying, but better safe than sorry.
1998 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1999 # argument list will get too long. Using .for/.endfor make "loops" will make
2000 # the Makefile parser segfault.
2003 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2004 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2005 while read file; do \
2006 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2007 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2008 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2011 # Remove catpages without corresponding manpages.
2013 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2014 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2015 while read catpage; do \
2017 if [ ! -e "$${manpage}" ]; then \
2018 rm ${RM_I} $${catpage} <&3; \
2021 @echo ">>> Old files removed"
2024 @echo ">>> Checking for old files"
2026 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2027 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2028 while read file; do \
2029 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2030 echo "${DESTDIR}/$${file}"; \
2033 # Check for catpages without corresponding manpages.
2034 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2035 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2036 while read catpage; do \
2038 if [ ! -e "$${manpage}" ]; then \
2044 @echo ">>> Removing old libraries"
2045 @echo "${OLD_LIBS_MESSAGE}" | fmt
2048 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2049 -V OLD_LIBS | xargs -n1 | \
2050 while read file; do \
2051 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2052 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2053 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2055 for ext in debug symbols; do \
2056 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2057 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2058 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2063 @echo ">>> Old libraries removed"
2066 @echo ">>> Checking for old libraries"
2068 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2069 -V OLD_LIBS | xargs -n1 | \
2070 while read file; do \
2071 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2072 echo "${DESTDIR}/$${file}"; \
2074 for ext in debug symbols; do \
2075 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2076 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2082 @echo ">>> Removing old directories"
2084 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2085 -V OLD_DIRS | xargs -n1 | sort -r | \
2086 while read dir; do \
2087 if [ -d "${DESTDIR}/$${dir}" ]; then \
2088 rmdir -v "${DESTDIR}/$${dir}" || true; \
2089 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2090 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2093 @echo ">>> Old directories removed"
2096 @echo ">>> Checking for old directories"
2098 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2099 -V OLD_DIRS | xargs -n1 | \
2100 while read dir; do \
2101 if [ -d "${DESTDIR}/$${dir}" ]; then \
2102 echo "${DESTDIR}/$${dir}"; \
2103 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2104 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2108 delete-old: delete-old-files delete-old-dirs
2109 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2111 check-old: check-old-files check-old-libs check-old-dirs
2112 @echo "To remove old files and directories run '${MAKE} delete-old'."
2113 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2118 # showconfig - show build configuration.
2121 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2122 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2124 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2125 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2127 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2128 .if exists(${KERNCONFDIR}/${KERNCONF})
2129 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2130 '${KERNCONFDIR}/${KERNCONF}' ; echo
2136 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2137 DTBOUTPUTPATH= ${.CURDIR}
2141 # Build 'standalone' Device Tree Blob
2144 @PATH=${TMPPATH} MACHINE=${TARGET} \
2145 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2146 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2150 .if defined(TARGET) && defined(TARGET_ARCH)
2152 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2153 XDEV_CPUTYPE?=${CPUTYPE}
2155 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2158 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2159 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2160 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2161 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2162 CPUTYPE=${XDEV_CPUTYPE}
2164 XDDIR=${TARGET_ARCH}-freebsd
2167 .error XDTP variable should be an absolute path
2170 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2171 INSTALL="sh ${.CURDIR}/tools/install.sh"
2173 _SHLIBDIRPREFIX=${XDDESTDIR} \
2174 TOOLS_PREFIX=${XDTP}
2175 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2176 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2177 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2178 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2179 CPP="${CPP} ${CD2CFLAGS}" \
2180 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2182 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2183 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2184 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2185 XDDESTDIR=${DESTDIR}/${XDTP}
2187 OSREL!= uname -r | sed -e 's/[-(].*//'
2190 .ORDER: xdev-build xdev-install xdev-links
2191 xdev: xdev-build xdev-install
2193 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2194 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2197 mkdir -p ${CDTMP}/usr
2198 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2199 -p ${CDTMP}/usr >/dev/null
2201 _xb-bootstrap-tools:
2205 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2206 cd ${.CURDIR}/${_tool} && \
2207 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2208 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2209 ${CDMAKE} DIRPRFX=${_tool}/ all && \
2210 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2214 ${_+_}@cd ${.CURDIR}; \
2215 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2225 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2226 cd ${.CURDIR}/${_tool} && \
2227 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2228 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2229 ${CDMAKE} DIRPRFX=${_tool}/ all
2233 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2234 mkdir -p ${XDDESTDIR}
2235 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2236 -p ${XDDESTDIR} >/dev/null
2237 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2238 -p ${XDDESTDIR}/usr >/dev/null
2239 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2240 -p ${XDDESTDIR}/usr/include >/dev/null
2241 .if ${MK_TESTS} != "no"
2242 mkdir -p ${XDDESTDIR}${TESTSBASE}
2243 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2244 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2247 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2248 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2251 @echo "_xi-cross-tools"
2259 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2260 cd ${.CURDIR}/${_tool}; \
2261 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2265 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2266 DESTDIR=${XDDESTDIR}
2269 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2270 DESTDIR=${XDDESTDIR}
2273 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2274 mkdir -p ../../../../usr/bin; \
2276 ln -sf ../../${XDTP}/usr/bin/$$i \
2277 ../../../../usr/bin/${XDDIR}-$$i; \
2278 ln -sf ../../${XDTP}/usr/bin/$$i \
2279 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2282 xdev xdev-build xdev-install xdev-links:
2283 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"