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 MK_INFO=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_FULL=no MK_LLDB=no MK_TESTS=no
269 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
270 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
271 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
273 BOOTSTRAPPING=${OSRELDATE} \
276 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no MK_CLANG_FULL=no MK_LLDB=no MK_TESTS=no
279 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
280 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
281 MK_GDB=no MK_TESTS=no
284 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
285 PATH=${BPATH}:${PATH} \
286 WORLDTMP=${WORLDTMP} \
288 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
289 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
291 BOOTSTRAPPING=${OSRELDATE} \
293 MK_HTML=no MK_INFO=no -DNO_LINT MK_MAN=no \
294 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
295 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
298 WMAKEENV= ${CROSSENV} \
299 _SHLIBDIRPREFIX=${WORLDTMP} \
301 VERSION="${VERSION}" \
302 INSTALL="sh ${.CURDIR}/tools/install.sh" \
306 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
308 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
311 .if ${MK_CDDL} == "no"
315 .if defined(CROSS_TOOLCHAIN)
316 LOCALBASE?= /usr/local
317 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
319 .if defined(CROSS_TOOLCHAIN_PREFIX)
320 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
321 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
323 XCOMPILERS= CC CXX CPP
324 .for COMPILER in ${XCOMPILERS}
325 .if defined(CROSS_COMPILER_PREFIX)
326 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
328 X${COMPILER}?= ${${COMPILER}}
331 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
332 .for BINUTIL in ${XBINUTILS}
333 .if defined(CROSS_BINUTILS_PREFIX)
334 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
336 X${BINUTIL}?= ${${BINUTIL}}
339 WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
340 DEPFLAGS="${DEPFLAGS}" \
341 CPP="${XCPP} ${XCFLAGS}" \
342 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
343 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
344 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
348 XFLAGS= --sysroot=${WORLDTMP}
349 .if defined(CROSS_BINUTILS_PREFIX)
350 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
351 # directory, but the compiler will look in the right place for it's
352 # tools so we don't need to tell it where to look.
353 .if exists(${CROSS_BINUTILS_PREFIX})
354 XFLAGS+= -B${CROSS_BINUTILS_PREFIX}
357 XFLAGS+= -B${WORLDTMP}/usr/bin
359 .if ${TARGET} == "arm"
360 .if ${TARGET_ARCH:M*hf*} != ""
361 TARGET_ABI= gnueabihf
366 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
367 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
368 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
369 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
372 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
373 XCFLAGS+= -target ${TARGET_TRIPLE}
377 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
379 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
381 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
382 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
384 .if ${TARGET_ARCH} == "amd64"
385 .if empty(TARGET_CPUTYPE)
386 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
388 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
390 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
391 MACHINE_CPU="i686 mmx sse sse2"
394 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
396 .elif ${TARGET_ARCH} == "powerpc64"
397 .if empty(TARGET_CPUTYPE)
398 LIB32CPUFLAGS= -mcpu=powerpc
400 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
402 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
404 LD="${LD} -m elf32ppc_fbsd"
408 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
409 -isystem ${LIB32TMP}/usr/include/ \
410 -L${LIB32TMP}/usr/lib32 \
411 -B${LIB32TMP}/usr/lib32
413 LIB32FLAGS+= --sysroot=${WORLDTMP}
416 # Yes, the flags are redundant.
417 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
418 _SHLIBDIRPREFIX=${LIB32TMP} \
419 _LDSCRIPTROOT=${LIB32TMP} \
420 VERSION="${VERSION}" \
421 INSTALL="sh ${.CURDIR}/tools/install.sh" \
424 SHLIBDIR=/usr/lib32 \
425 LIBPRIVATEDIR=/usr/lib32/private \
426 DTRACE="${DTRACE} -32"
427 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
428 CXX="${XCXX} ${LIB32FLAGS}" \
429 DESTDIR=${LIB32TMP} \
437 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
438 MK_MAN=no MK_INFO=no MK_HTML=no
439 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
440 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
443 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
444 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
445 ${IMAKE_INSTALL} ${IMAKE_MTREE}
446 .if empty(.MAKEFLAGS:M-n)
447 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
448 LD_LIBRARY_PATH=${INSTALLTMP} \
449 PATH_LOCALE=${INSTALLTMP}/locale
450 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
452 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
454 .if defined(DB_FROM_SRC)
455 INSTALLFLAGS+= -N ${.CURDIR}/etc
456 MTREEFLAGS+= -N ${.CURDIR}/etc
458 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
459 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
461 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
462 IMAKE+= -DNO_ROOT METALOG=${METALOG}
463 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
466 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
467 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
468 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
472 KMAKEENV= ${WMAKEENV}
473 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
478 # Attempt to rebuild the entire system, with reasonable chance of
479 # success, regardless of how old your existing system is.
482 .if ${.CURDIR:C/[^,]//g} != ""
483 # The m4 build of sendmail files doesn't like it if ',' is used
484 # anywhere in the path of it's files.
486 @echo "*** Error: path to source tree contains a comma ','"
491 @echo "--------------------------------------------------------------"
492 @echo ">>> Rebuilding the temporary build tree"
493 @echo "--------------------------------------------------------------"
494 .if !defined(NO_CLEAN)
496 .if defined(LIB32TMP)
500 rm -rf ${WORLDTMP}/legacy/usr/include
501 # XXX - These three can depend on any header file.
502 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
503 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
504 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
507 lib usr legacy/bin legacy/usr
508 mkdir -p ${WORLDTMP}/${_dir}
510 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
511 -p ${WORLDTMP}/legacy/usr >/dev/null
512 .if ${MK_GROFF} != "no"
513 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
514 -p ${WORLDTMP}/legacy/usr >/dev/null
516 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
517 -p ${WORLDTMP}/usr >/dev/null
518 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
519 -p ${WORLDTMP}/usr/include >/dev/null
520 ln -sf ${.CURDIR}/sys ${WORLDTMP}
521 .if ${MK_DEBUG_FILES} != "no"
522 # We could instead disable debug files for these build stages
523 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
524 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
525 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
526 -p ${WORLDTMP}/usr/lib >/dev/null
528 .if ${MK_TESTS} != "no"
529 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
530 -p ${WORLDTMP}/usr >/dev/null
532 .for _mtree in ${LOCAL_MTREE}
533 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
537 @echo "--------------------------------------------------------------"
538 @echo ">>> stage 1.1: legacy release compatibility shims"
539 @echo "--------------------------------------------------------------"
540 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
543 @echo "--------------------------------------------------------------"
544 @echo ">>> stage 1.2: bootstrap tools"
545 @echo "--------------------------------------------------------------"
546 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
548 .if !defined(NO_CLEAN)
550 @echo "--------------------------------------------------------------"
551 @echo ">>> stage 2.1: cleaning up the object tree"
552 @echo "--------------------------------------------------------------"
553 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
554 .if defined(LIB32TMP)
555 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
560 @echo "--------------------------------------------------------------"
561 @echo ">>> stage 2.2: rebuilding the object tree"
562 @echo "--------------------------------------------------------------"
563 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
566 @echo "--------------------------------------------------------------"
567 @echo ">>> stage 2.3: build tools"
568 @echo "--------------------------------------------------------------"
569 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
572 @echo "--------------------------------------------------------------"
573 @echo ">>> stage 3: cross tools"
574 @echo "--------------------------------------------------------------"
575 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
576 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
579 @echo "--------------------------------------------------------------"
580 @echo ">>> stage 4.1: building includes"
581 @echo "--------------------------------------------------------------"
582 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
585 @echo "--------------------------------------------------------------"
586 @echo ">>> stage 4.2: building libraries"
587 @echo "--------------------------------------------------------------"
588 ${_+_}cd ${.CURDIR}; \
589 ${WMAKE} -DNO_FSCHG MK_HTML=no MK_INFO=no -DNO_LINT MK_MAN=no \
590 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
593 @echo "--------------------------------------------------------------"
594 @echo ">>> stage 4.3: make dependencies"
595 @echo "--------------------------------------------------------------"
596 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
599 @echo "--------------------------------------------------------------"
600 @echo ">>> stage 4.4: building everything"
601 @echo "--------------------------------------------------------------"
602 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
603 .if defined(LIB32TMP)
606 @echo "--------------------------------------------------------------"
607 @echo ">>> stage 5.1: building 32 bit shim libraries"
608 @echo "--------------------------------------------------------------"
609 mkdir -p ${LIB32TMP}/usr/include
610 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
611 -p ${LIB32TMP}/usr >/dev/null
612 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
613 -p ${LIB32TMP}/usr/include >/dev/null
614 .if ${MK_DEBUG_FILES} != "no"
615 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
616 -p ${LIB32TMP}/usr/lib >/dev/null
619 ln -sf ${.CURDIR}/sys ${WORLDTMP}
620 .for _t in obj includes
621 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
622 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
623 .if ${MK_CDDL} != "no"
624 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
626 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
627 .if ${MK_CRYPT} != "no"
628 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
630 .if ${MK_KERBEROS} != "no"
631 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
634 .for _dir in usr.bin/lex/lib
635 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
637 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
638 cd ${.CURDIR}/${_dir}; \
639 WORLDTMP=${WORLDTMP} \
640 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
641 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
642 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
646 ${LIB32WMAKE} -f Makefile.inc1 libraries
647 .for _t in obj depend all
648 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
649 DIRPRFX=libexec/rtld-elf/ ${_t}
650 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
651 DIRPRFX=usr.bin/ldd ${_t}
654 distribute32 install32:
655 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
656 .if ${MK_CDDL} != "no"
657 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
659 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
660 .if ${MK_CRYPT} != "no"
661 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
663 .if ${MK_KERBEROS} != "no"
664 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
666 cd ${.CURDIR}/libexec/rtld-elf; \
667 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
668 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
672 .if !defined(SUBDIR_OVERRIDE)
673 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
675 WMAKE_TGTS+= _cleanobj _obj _build-tools
676 .if !defined(SUBDIR_OVERRIDE)
677 WMAKE_TGTS+= _cross-tools
679 WMAKE_TGTS+= _includes _libraries _depend everything
680 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
684 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
685 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
688 @echo "--------------------------------------------------------------"
689 @echo ">>> World build started on `LC_ALL=C date`"
690 @echo "--------------------------------------------------------------"
694 @echo "--------------------------------------------------------------"
695 @echo ">>> World build completed on `LC_ALL=C date`"
696 @echo "--------------------------------------------------------------"
699 # We need to have this as a target because the indirection between Makefile
700 # and Makefile.inc1 causes the correct PATH to be used, rather than a
701 # modification of the current environment's PATH. In addition, we need
702 # to quote multiword values.
707 .if ${.TARGETS:Mbuildenv}
708 .if ${.MAKEFLAGS:M-j}
709 .error The buildenv target is incompatible with -j
713 @echo Entering world for ${TARGET_ARCH}:${TARGET}
714 @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
716 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
717 toolchain: ${TOOLCHAIN_TGTS}
718 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
723 # Checks to be sure system is ready for installworld/installkernel.
725 installcheck: _installcheck_world _installcheck_kernel
727 _installcheck_kernel:
730 # Require DESTDIR to be set if installing for a different architecture or
731 # using the user/group database in the source tree.
733 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
735 .if !make(distributeworld)
736 _installcheck_world: __installcheck_DESTDIR
737 _installcheck_kernel: __installcheck_DESTDIR
738 __installcheck_DESTDIR:
739 .if !defined(DESTDIR) || empty(DESTDIR)
740 @echo "ERROR: Please set DESTDIR!"; \
746 .if !defined(DB_FROM_SRC)
748 # Check for missing UIDs/GIDs.
750 CHECK_UIDS= auditdistd
752 .if ${MK_SENDMAIL} != "no"
758 CHECK_GIDS+= proxy authpf
760 .if ${MK_UNBOUND} != "no"
764 _installcheck_world: __installcheck_UGID
766 .for uid in ${CHECK_UIDS}
767 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
768 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
772 .for gid in ${CHECK_GIDS}
773 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
774 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
781 # Required install tools to be saved in a scratch dir for safety.
783 .if ${MK_INFO} != "no"
784 _install-info= install-info
786 .if ${MK_ZONEINFO} != "no"
787 _zoneinfo= zic tzsetup
790 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
791 date echo egrep find grep id install ${_install-info} \
792 ln lockf make mkdir mtree mv pwd_mkdb \
793 rm sed services_mkdb sh sysctl test true uname wc ${_zoneinfo} \
796 # Needed for share/man
797 .if ${MK_MAN} != "no"
804 # Distributes everything compiled by a `buildworld'.
808 # Installs everything compiled by a 'buildworld'.
811 # Non-base distributions produced by the base system
812 EXTRA_DISTRIBUTIONS= doc
813 .if ${MK_GAMES} != "no"
814 EXTRA_DISTRIBUTIONS+= games
816 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
817 EXTRA_DISTRIBUTIONS+= lib32
819 .if ${MK_TESTS} != "no"
820 EXTRA_DISTRIBUTIONS+= tests
824 .if ${MK_DEBUG_FILES} != "no"
825 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,}
828 MTREE_MAGIC?= mtree 2.0
830 distributeworld installworld: _installcheck_world
831 mkdir -p ${INSTALLTMP}
832 progs=$$(for prog in ${ITOOLS}; do \
833 if progpath=`which $$prog`; then \
836 echo "Required tool $$prog not found in PATH." >&2; \
840 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
841 while read line; do \
843 if [ "$$2 $$3" != "not found" ]; then \
846 echo "Required library $$1 not found." >&2; \
850 cp $$libs $$progs ${INSTALLTMP}
851 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
853 echo "#${MTREE_MAGIC}" > ${METALOG}
855 .if make(distributeworld)
856 .for dist in ${EXTRA_DISTRIBUTIONS}
857 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
858 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
859 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
860 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
861 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
862 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
863 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
864 .if ${MK_DEBUG_FILES} != "no"
865 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
866 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
868 .if ${MK_TESTS} != "no" && ${dist} == "tests"
869 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
870 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
873 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
874 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
875 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
876 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
877 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
878 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
881 -mkdir ${DESTDIR}/${DISTDIR}/base
882 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
883 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
884 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
885 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
887 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
888 ${IMAKEENV} rm -rf ${INSTALLTMP}
889 .if make(distributeworld)
890 .for dist in ${EXTRA_DISTRIBUTIONS}
891 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
894 .for dist in base ${EXTRA_DISTRIBUTIONS}
895 @# For each file that exists in this dist, print the corresponding
896 @# line from the METALOG. This relies on the fact that
897 @# a line containing only the filename will sort immediatly before
898 @# the relevant mtree line.
899 cd ${DESTDIR}/${DISTDIR}; \
900 find ./${dist} | sort -u ${METALOG} - | \
901 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
902 ${DESTDIR}/${DISTDIR}/${dist}.meta
904 .for dist in ${DEBUG_DISTRIBUTIONS}
905 @# For each file that exists in this dist, print the corresponding
906 @# line from the METALOG. This relies on the fact that
907 @# a line containing only the filename will sort immediatly before
908 @# the relevant mtree line.
909 cd ${DESTDIR}/${DISTDIR}; \
910 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
911 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
912 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
918 .for dist in base ${EXTRA_DISTRIBUTIONS}
920 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
921 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
922 --exclude usr/lib/debug \
923 @${DESTDIR}/${DISTDIR}/${dist}.meta
925 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
926 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
927 --exclude usr/lib/debug .
931 .for dist in ${DEBUG_DISTRIBUTIONS}
932 . if defined(NO_ROOT)
933 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
934 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \
935 @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
937 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
938 tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz \
946 # If you have a build server, you can NFS mount the source and obj directories
947 # and do a 'make reinstall' on the *client* to install new binaries from the
948 # most recent server build.
951 @echo "--------------------------------------------------------------"
952 @echo ">>> Making hierarchy"
953 @echo "--------------------------------------------------------------"
954 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
955 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
957 @echo "--------------------------------------------------------------"
958 @echo ">>> Installing everything"
959 @echo "--------------------------------------------------------------"
960 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
961 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
962 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
966 @echo "--------------------------------------------------------------"
967 @echo ">>> Distributing everything"
968 @echo "--------------------------------------------------------------"
969 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
970 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
971 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
975 distrib-dirs distribution: .MAKE
976 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
977 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
980 # buildkernel and installkernel
982 # Which kernels to build and/or install is specified by setting
983 # KERNCONF. If not defined a GENERIC kernel is built/installed.
984 # Only the existing (depending TARGET) config files are used
985 # for building kernels and only the first of these is designated
986 # as the one being installed.
988 # Note that we have to use TARGET instead of TARGET_ARCH when
989 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
990 # be set to cross-build, we have to make sure TARGET is set
993 .if defined(KERNFAST)
998 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
999 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1000 KERNCONF=${KERNFAST}
1003 .if ${TARGET_ARCH} == "powerpc64"
1004 KERNCONF?= GENERIC64
1008 INSTKERNNAME?= kernel
1010 KERNSRCDIR?= ${.CURDIR}/sys
1011 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1012 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1013 KERNCONFDIR?= ${KRNLCONFDIR}
1017 .for _kernel in ${KERNCONF}
1018 .if exists(${KERNCONFDIR}/${_kernel})
1019 BUILDKERNELS+= ${_kernel}
1020 .if empty(INSTALLKERNEL)
1021 INSTALLKERNEL= ${_kernel}
1026 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
1031 # Builds all kernels defined by BUILDKERNELS.
1034 .if empty(BUILDKERNELS)
1035 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1039 .for _kernel in ${BUILDKERNELS}
1040 @echo "--------------------------------------------------------------"
1041 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1042 @echo "--------------------------------------------------------------"
1043 @echo "===> ${_kernel}"
1044 mkdir -p ${KRNLOBJDIR}
1045 .if !defined(NO_KERNELCONFIG)
1047 @echo "--------------------------------------------------------------"
1048 @echo ">>> stage 1: configuring the kernel"
1049 @echo "--------------------------------------------------------------"
1050 cd ${KRNLCONFDIR}; \
1052 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1053 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1055 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1057 @echo "--------------------------------------------------------------"
1058 @echo ">>> stage 2.1: cleaning up the object tree"
1059 @echo "--------------------------------------------------------------"
1060 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1062 .if !defined(NO_KERNELOBJ)
1064 @echo "--------------------------------------------------------------"
1065 @echo ">>> stage 2.2: rebuilding the object tree"
1066 @echo "--------------------------------------------------------------"
1067 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1070 @echo "--------------------------------------------------------------"
1071 @echo ">>> stage 2.3: build tools"
1072 @echo "--------------------------------------------------------------"
1073 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1074 .if !defined(NO_KERNELDEPEND)
1076 @echo "--------------------------------------------------------------"
1077 @echo ">>> stage 3.1: making dependencies"
1078 @echo "--------------------------------------------------------------"
1079 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1082 @echo "--------------------------------------------------------------"
1083 @echo ">>> stage 3.2: building everything"
1084 @echo "--------------------------------------------------------------"
1085 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1086 @echo "--------------------------------------------------------------"
1087 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1088 @echo "--------------------------------------------------------------"
1092 # installkernel, etc.
1094 # Install the kernel defined by INSTALLKERNEL
1096 installkernel installkernel.debug \
1097 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1098 .if empty(INSTALLKERNEL)
1099 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1102 @echo "--------------------------------------------------------------"
1103 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1104 @echo "--------------------------------------------------------------"
1105 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1106 ${CROSSENV} PATH=${TMPPATH} \
1107 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1109 distributekernel distributekernel.debug:
1110 .if empty(INSTALLKERNEL)
1111 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1114 mkdir -p ${DESTDIR}/${DISTDIR}
1115 .if defined(NO_ROOT)
1116 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1118 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1119 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1120 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1121 DESTDIR=${INSTALL_DDIR}/kernel \
1122 ${.TARGET:S/distributekernel/install/}
1123 .if defined(NO_ROOT)
1124 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1125 ${DESTDIR}/${DISTDIR}/kernel.meta
1127 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1128 .if defined(NO_ROOT)
1129 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1131 cd ${KRNLOBJDIR}/${_kernel}; \
1132 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1133 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1134 KERNEL=${INSTKERNNAME}.${_kernel} \
1135 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1136 ${.TARGET:S/distributekernel/install/}
1137 .if defined(NO_ROOT)
1138 sed -e 's|^./kernel|.|' \
1139 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1140 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1145 .if defined(NO_ROOT)
1146 cd ${DESTDIR}/${DISTDIR}/kernel; \
1147 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
1148 @${DESTDIR}/${DISTDIR}/kernel.meta
1149 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1150 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1151 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
1152 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1155 cd ${DESTDIR}/${DISTDIR}/kernel; \
1156 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1157 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1158 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1159 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1166 # Build the API documentation with doxygen
1169 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1170 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1173 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1178 # Update the source tree(s), by running svn/svnup to update to the
1182 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1183 @echo "--------------------------------------------------------------"
1184 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1185 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1186 @echo "--------------------------------------------------------------"
1189 .if defined(SVN_UPDATE)
1190 @echo "--------------------------------------------------------------"
1191 @echo ">>> Updating ${.CURDIR} using Subversion"
1192 @echo "--------------------------------------------------------------"
1193 @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1197 # ------------------------------------------------------------------------
1199 # From here onwards are utility targets used by the 'make world' and
1200 # related targets. If your 'world' breaks, you may like to try to fix
1201 # the problem and manually run the following targets to attempt to
1202 # complete the build. Beware, this is *not* guaranteed to work, you
1203 # need to have a pretty good grip on the current state of the system
1204 # to attempt to manually finish it. If in doubt, 'make world' again.
1208 # legacy: Build compatibility shims for the next three targets
1211 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1212 @echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
1215 .for _tool in tools/build
1216 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1217 cd ${.CURDIR}/${_tool} && \
1218 ${MAKE} DIRPRFX=${_tool}/ obj && \
1219 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1220 ${MAKE} DIRPRFX=${_tool}/ depend && \
1221 ${MAKE} DIRPRFX=${_tool}/ all && \
1222 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1226 # bootstrap-tools: Build tools needed for compatibility
1228 .if ${MK_GAMES} != "no"
1229 _strfile= games/fortune/strfile
1232 .if ${MK_CXX} != "no"
1233 _gperf= gnu/usr.bin/gperf
1236 .if ${MK_GROFF} != "no"
1237 _groff= gnu/usr.bin/groff
1240 .if ${MK_VT} != "no"
1241 _vtfontcvt= usr.bin/vtfontcvt
1244 .if ${BOOTSTRAPPING} < 900002
1248 .if ${BOOTSTRAPPING} < 1000002
1253 .if ${BOOTSTRAPPING} < 1000013
1258 .if ${BOOTSTRAPPING} < 1000014
1259 _crunch= usr.sbin/crunch
1262 .if ${BOOTSTRAPPING} < 1000026
1263 _nmtree= lib/libnetbsd \
1267 .if ${BOOTSTRAPPING} < 1000027
1271 .if ${BOOTSTRAPPING} < 1000033
1275 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1279 .if ${MK_BSNMP} != "no"
1280 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1283 # We need to build tblgen when we're building clang either as
1284 # the bootstrap compiler, or as the part of the normal build.
1285 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1287 lib/clang/libllvmsupport \
1288 lib/clang/libllvmtablegen \
1289 usr.bin/clang/tblgen \
1290 usr.bin/clang/clang-tblgen
1293 # dtrace tools are required for older bootstrap env and cross-build
1295 .if ${MK_CDDL} != "no" && (${BOOTSTRAPPING} < 1100006 \
1296 || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1297 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1298 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1301 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1304 .if ${MK_GPL_DTC} != "no"
1305 _dtc= gnu/usr.bin/dtc
1308 .if ${MK_KERBEROS} != "no"
1309 _kerberos5_bootstrap_tools= \
1310 kerberos5/tools/make-roken \
1311 kerberos5/lib/libroken \
1312 kerberos5/lib/libvers \
1313 kerberos5/tools/asn1_compile \
1314 kerberos5/tools/slc \
1318 # Please document (add comment) why something is in 'bootstrap-tools'.
1319 # Try to bound the building of the bootstrap-tool to just the
1320 # FreeBSD versions that need the tool built at this stage of the build.
1321 bootstrap-tools: .MAKE
1324 ${_kerberos5_bootstrap_tools} \
1333 usr.bin/makewhatis \
1346 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1347 cd ${.CURDIR}/${_tool} && \
1348 ${MAKE} DIRPRFX=${_tool}/ obj && \
1349 ${MAKE} DIRPRFX=${_tool}/ depend && \
1350 ${MAKE} DIRPRFX=${_tool}/ all && \
1351 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1355 # build-tools: Build special purpose build tools
1357 .if !defined(NO_SHARE)
1358 _share= share/syscons/scrnmaps
1361 .if ${MK_GCC} != "no"
1362 _gcc_tools= gnu/usr.bin/cc/cc_tools
1365 .if ${MK_RESCUE} != "no"
1366 _rescue= rescue/rescue
1374 ${LOCAL_TOOL_DIRS} \
1375 lib/ncurses/ncurses \
1376 lib/ncurses/ncursesw \
1380 usr.bin/mkesdb_static \
1381 usr.bin/mkcsmapper_static \
1383 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1384 cd ${.CURDIR}/${_tool} && \
1385 ${MAKE} DIRPRFX=${_tool}/ obj && \
1386 ${MAKE} DIRPRFX=${_tool}/ build-tools
1390 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1391 cd ${.CURDIR}/${_tool} && \
1392 ${MAKE} DIRPRFX=${_tool}/ obj && \
1393 ${MAKE} DIRPRFX=${_tool}/ depend && \
1394 ${MAKE} DIRPRFX=${_tool}/ all
1398 # kernel-tools: Build kernel-building tools
1401 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1402 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1403 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1406 # cross-tools: Build cross-building tools
1408 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1409 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1410 _btxld= usr.sbin/btxld
1413 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1414 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1415 _crunchide= usr.sbin/crunch/crunchide
1417 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1418 _kgzip= usr.sbin/kgzip
1422 # If we're given an XAS, don't build binutils.
1423 .if ${XAS:M/*} == "" && ${MK_BINUTILS_BOOTSTRAP} != "no"
1424 _binutils= gnu/usr.bin/binutils
1425 .if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
1426 _elftctools= lib/libelftc \
1435 # If an full path to an external cross compiler is given, don't build
1437 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1438 .if ${MK_CLANG_BOOTSTRAP} != "no"
1439 _clang= usr.bin/clang
1440 _clang_libs= lib/clang
1442 .if ${MK_GCC_BOOTSTRAP} != "no"
1454 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1459 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1460 cd ${.CURDIR}/${_tool} && \
1461 ${MAKE} DIRPRFX=${_tool}/ obj && \
1462 ${MAKE} DIRPRFX=${_tool}/ depend && \
1463 ${MAKE} DIRPRFX=${_tool}/ all && \
1464 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1467 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1468 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1469 VERSION="${VERSION}"
1470 NXBMAKE= ${NXBENV} ${MAKE} \
1471 TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
1472 CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
1473 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1474 MK_GDB=no MK_TESTS=no \
1476 MK_HTML=no MK_INFO=no NO_LINT=yes MK_MAN=no \
1477 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1478 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1479 MK_CLANG_FULL=no MK_LLDB=no
1481 native-xtools: .MAKE
1482 mkdir -p ${OBJTREE}/nxb-bin/bin
1483 mkdir -p ${OBJTREE}/nxb-bin/sbin
1484 mkdir -p ${OBJTREE}/nxb-bin/usr
1485 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1486 -p ${OBJTREE}/nxb-bin/usr >/dev/null
1487 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1488 -p ${OBJTREE}/nxb-bin/usr/include >/dev/null
1548 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1549 cd ${.CURDIR}/${_tool} && \
1550 ${NXBMAKE} DIRPRFX=${_tool}/ obj && \
1551 ${NXBMAKE} DIRPRFX=${_tool}/ depend && \
1552 ${NXBMAKE} DIRPRFX=${_tool}/ all && \
1553 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install
1557 # hierarchy - ensure that all the needed directories are present
1559 hierarchy hier: .MAKE
1560 cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1563 # libraries - build all libraries, and install them under ${DESTDIR}.
1565 # The list of libraries with dependents (${_prebuild_libs}) and their
1566 # interdependencies (__L) are built automatically by the
1567 # ${.CURDIR}/tools/make_libdeps.sh script.
1571 ${MAKE} -f Makefile.inc1 _prereq_libs && \
1572 ${MAKE} -f Makefile.inc1 _startup_libs && \
1573 ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1574 ${MAKE} -f Makefile.inc1 _generic_libs
1577 # static libgcc.a prerequisite for shared libc
1579 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1581 # These dependencies are not automatically generated:
1583 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1584 # all shared libraries for ELF.
1586 _startup_libs= gnu/lib/csu
1587 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1588 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1589 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1590 _startup_libs+= lib/csu/${MACHINE_ARCH}
1592 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1594 _startup_libs+= gnu/lib/libgcc
1595 _startup_libs+= lib/libcompiler_rt
1596 _startup_libs+= lib/libc
1597 _startup_libs+= lib/libc_nonshared
1598 .if ${MK_LIBCPLUSPLUS} != "no"
1599 _startup_libs+= lib/libcxxrt
1602 gnu/lib/libgcc__L: lib/libc__L
1603 gnu/lib/libgcc__L: lib/libc_nonshared__L
1604 .if ${MK_LIBCPLUSPLUS} != "no"
1605 lib/libcxxrt__L: gnu/lib/libgcc__L
1608 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1609 ${_kerberos5_lib_libhdb} \
1610 ${_kerberos5_lib_libheimbase} \
1611 ${_kerberos5_lib_libheimntlm} \
1612 ${_kerberos5_lib_libheimsqlite} \
1613 ${_kerberos5_lib_libheimipcc} \
1614 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1615 ${_kerberos5_lib_libroken} \
1616 ${_kerberos5_lib_libwind} \
1617 lib/libbz2 ${_libcom_err} lib/libcrypt \
1618 lib/libelf lib/libexpat \
1621 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1622 ${_lib_libcapsicum} \
1623 lib/ncurses/ncurses lib/ncurses/ncursesw \
1624 lib/libopie lib/libpam ${_lib_libthr} \
1625 lib/libradius lib/libsbuf lib/libtacplus \
1627 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1628 ${_cddl_lib_libuutil} \
1629 ${_cddl_lib_libavl} \
1630 ${_cddl_lib_libzfs_core} \
1631 ${_cddl_lib_libctf} \
1632 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1633 ${_secure_lib_libcrypto} ${_lib_libldns} \
1634 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1636 .if ${MK_GNUCXX} != "no"
1637 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1638 gnu/lib/libstdc++__L: lib/msun__L
1639 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1642 lib/libgeom__L: lib/libexpat__L
1644 .if ${MK_LIBTHR} != "no"
1645 _lib_libthr= lib/libthr
1648 .if ${MK_OFED} != "no"
1649 _ofed_lib= contrib/ofed/usr.lib/
1652 .if ${MK_CASPER} != "no"
1653 _lib_libcapsicum=lib/libcapsicum
1656 lib/libcapsicum__L: lib/libnv__L
1657 lib/libpjdlog__L: lib/libutil__L
1659 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1660 .for _DIR in ${LOCAL_LIB_DIRS}
1661 .if exists(${.CURDIR}/${_DIR}/Makefile)
1662 _generic_libs+= ${_DIR}
1666 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1668 .if ${MK_CDDL} != "no"
1669 _cddl_lib_libumem= cddl/lib/libumem
1670 _cddl_lib_libnvpair= cddl/lib/libnvpair
1671 _cddl_lib_libavl= cddl/lib/libavl
1672 _cddl_lib_libuutil= cddl/lib/libuutil
1673 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1674 _cddl_lib_libctf= cddl/lib/libctf
1676 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1677 cddl/lib/libzfs__L: lib/libgeom__L
1678 cddl/lib/libctf__L: lib/libz__L
1681 .if ${MK_CRYPT} != "no"
1682 .if ${MK_OPENSSL} != "no"
1683 _secure_lib_libcrypto= secure/lib/libcrypto
1684 _secure_lib_libssl= secure/lib/libssl
1685 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1686 .if ${MK_LDNS} != "no"
1687 _lib_libldns= lib/libldns
1688 lib/libldns__L: secure/lib/libcrypto__L
1690 .if ${MK_OPENSSH} != "no"
1691 _secure_lib_libssh= secure/lib/libssh
1692 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1693 .if ${MK_LDNS} != "no"
1694 secure/lib/libssh__L: lib/libldns__L
1696 .if ${MK_KERBEROS_SUPPORT} != "no"
1697 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1698 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1699 lib/libmd__L kerberos5/lib/libroken__L
1703 _secure_lib= secure/lib
1706 .if ${MK_KERBEROS} != "no"
1707 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1708 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1709 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1710 kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
1711 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1712 kerberos5/lib/libroken__L lib/libcom_err__L
1713 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1714 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1715 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1716 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1717 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1718 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1719 kerberos5/lib/libroken__L: lib/libcrypt__L
1720 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1721 kerberos5/lib/libheimbase__L: lib/libthr__L
1722 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1723 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1726 .if ${MK_GSSAPI} != "no"
1727 _lib_libgssapi= lib/libgssapi
1730 .if ${MK_KERBEROS} != "no"
1731 _kerberos5_lib= kerberos5/lib
1732 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1733 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1734 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1735 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1736 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1737 _kerberos5_lib_libroken= kerberos5/lib/libroken
1738 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1739 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1740 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1741 _kerberos5_lib_libwind= kerberos5/lib/libwind
1742 _libcom_err= lib/libcom_err
1745 .if ${MK_NIS} != "no"
1746 _lib_libypclnt= lib/libypclnt
1749 .if ${MK_OPENSSL} == "no"
1750 lib/libradius__L: lib/libmd__L
1753 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
1755 .for _lib in ${_prereq_libs}
1756 ${_lib}__PL: .PHONY .MAKE
1757 .if exists(${.CURDIR}/${_lib})
1758 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1759 cd ${.CURDIR}/${_lib} && \
1760 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1761 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1762 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1763 DIRPRFX=${_lib}/ all && \
1764 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1765 DIRPRFX=${_lib}/ install
1769 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1770 ${_lib}__L: .PHONY .MAKE
1771 .if exists(${.CURDIR}/${_lib})
1772 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1773 cd ${.CURDIR}/${_lib} && \
1774 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1775 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1776 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all && \
1777 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1781 # libpam is special: we need to build static PAM modules before
1782 # static PAM library, and dynamic PAM library before dynamic PAM
1784 lib/libpam__L: .PHONY .MAKE
1785 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1786 cd ${.CURDIR}/lib/libpam && \
1787 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj && \
1788 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend && \
1789 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1790 -D_NO_LIBPAM_SO_YET all && \
1791 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1792 -D_NO_LIBPAM_SO_YET install
1794 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1795 _startup_libs: ${_startup_libs:S/$/__L/}
1796 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1797 _generic_libs: ${_generic_libs:S/$/__L/}
1799 .for __target in all clean cleandepend cleandir depend includes obj
1800 .for entry in ${SUBDIR}
1801 ${entry}.${__target}__D: .PHONY .MAKE
1802 ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1803 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1804 edir=${entry}.${MACHINE_ARCH}; \
1805 cd ${.CURDIR}/$${edir}; \
1807 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1809 cd ${.CURDIR}/$${edir}; \
1811 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1813 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1816 .include <bsd.subdir.mk>
1818 .if make(check-old) || make(check-old-dirs) || \
1819 make(check-old-files) || make(check-old-libs) || \
1820 make(delete-old) || make(delete-old-dirs) || \
1821 make(delete-old-files) || make(delete-old-libs)
1824 # check for / delete old files section
1827 .include "ObsoleteFiles.inc"
1829 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1830 else you can not start such an application. Consult UPDATING for more \
1831 information regarding how to cope with the removal/revision bump of a \
1834 .if !defined(BATCH_DELETE_OLD_FILES)
1841 @echo ">>> Removing old files (only deletes safe to delete libs)"
1842 # Ask for every old file if the user really wants to remove it.
1843 # It's annoying, but better safe than sorry.
1844 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1845 # argument list will get too long. Using .for/.endfor make "loops" will make
1846 # the Makefile parser segfault.
1849 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1850 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1851 while read file; do \
1852 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1853 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1854 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1857 # Remove catpages without corresponding manpages.
1859 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1860 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1861 while read catpage; do \
1863 if [ ! -e "$${manpage}" ]; then \
1864 rm ${RM_I} $${catpage} <&3; \
1867 @echo ">>> Old files removed"
1870 @echo ">>> Checking for old files"
1872 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1873 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1874 while read file; do \
1875 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1876 echo "${DESTDIR}/$${file}"; \
1879 # Check for catpages without corresponding manpages.
1880 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1881 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1882 while read catpage; do \
1884 if [ ! -e "$${manpage}" ]; then \
1890 @echo ">>> Removing old libraries"
1891 @echo "${OLD_LIBS_MESSAGE}" | fmt
1894 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1895 -V OLD_LIBS | xargs -n1 | \
1896 while read file; do \
1897 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1898 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1899 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1901 for ext in debug symbols; do \
1902 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1903 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1904 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1909 @echo ">>> Old libraries removed"
1912 @echo ">>> Checking for old libraries"
1914 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1915 -V OLD_LIBS | xargs -n1 | \
1916 while read file; do \
1917 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1918 echo "${DESTDIR}/$${file}"; \
1920 for ext in debug symbols; do \
1921 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1922 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1928 @echo ">>> Removing old directories"
1930 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1931 -V OLD_DIRS | xargs -n1 | sort -r | \
1932 while read dir; do \
1933 if [ -d "${DESTDIR}/$${dir}" ]; then \
1934 rmdir -v "${DESTDIR}/$${dir}" || true; \
1935 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1936 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1939 @echo ">>> Old directories removed"
1942 @echo ">>> Checking for old directories"
1944 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1945 -V OLD_DIRS | xargs -n1 | \
1946 while read dir; do \
1947 if [ -d "${DESTDIR}/$${dir}" ]; then \
1948 echo "${DESTDIR}/$${dir}"; \
1949 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1950 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1954 delete-old: delete-old-files delete-old-dirs
1955 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1957 check-old: check-old-files check-old-libs check-old-dirs
1958 @echo "To remove old files and directories run '${MAKE} delete-old'."
1959 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1964 # showconfig - show build configuration.
1967 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
1968 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
1970 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1971 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1973 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1974 .if exists(${KERNCONFDIR}/${KERNCONF})
1975 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1976 '${KERNCONFDIR}/${KERNCONF}' ; echo
1982 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1983 DTBOUTPUTPATH= ${.CURDIR}
1987 # Build 'standalone' Device Tree Blob
1990 @PATH=${TMPPATH} MACHINE=${TARGET} \
1991 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
1992 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
1996 .if defined(TARGET) && defined(TARGET_ARCH)
1998 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
1999 XDEV_CPUTYPE?=${CPUTYPE}
2001 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2004 NOFUN=-DNO_FSCHG MK_HTML=no MK_INFO=no -DNO_LINT \
2005 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2006 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2007 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2008 CPUTYPE=${XDEV_CPUTYPE}
2010 XDDIR=${TARGET_ARCH}-freebsd
2013 .error XDTP variable should be an absolute path
2016 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2017 INSTALL="sh ${.CURDIR}/tools/install.sh"
2019 _SHLIBDIRPREFIX=${XDDESTDIR} \
2020 TOOLS_PREFIX=${XDTP}
2021 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2022 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2023 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2024 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2025 CPP="${CPP} ${CD2CFLAGS}" \
2026 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2028 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2029 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2030 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2031 XDDESTDIR=${DESTDIR}/${XDTP}
2033 OSREL!= uname -r | sed -e 's/[-(].*//'
2036 .ORDER: xdev-build xdev-install xdev-links
2037 xdev: xdev-build xdev-install
2039 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2040 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2043 mkdir -p ${CDTMP}/usr
2044 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2045 -p ${CDTMP}/usr >/dev/null
2047 _xb-bootstrap-tools:
2051 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2052 cd ${.CURDIR}/${_tool} && \
2053 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2054 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2055 ${CDMAKE} DIRPRFX=${_tool}/ all && \
2056 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2060 ${_+_}@cd ${.CURDIR}; \
2061 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2071 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2072 cd ${.CURDIR}/${_tool} && \
2073 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2074 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2075 ${CDMAKE} DIRPRFX=${_tool}/ all
2079 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2080 mkdir -p ${XDDESTDIR}
2081 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2082 -p ${XDDESTDIR} >/dev/null
2083 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2084 -p ${XDDESTDIR}/usr >/dev/null
2085 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2086 -p ${XDDESTDIR}/usr/include >/dev/null
2087 .if ${MK_TESTS} != "no"
2088 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2089 -p ${XDDESTDIR}/usr >/dev/null
2092 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2093 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2096 @echo "_xi-cross-tools"
2104 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2105 cd ${.CURDIR}/${_tool}; \
2106 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2110 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2111 DESTDIR=${XDDESTDIR}
2114 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2115 DESTDIR=${XDDESTDIR}
2118 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2119 mkdir -p ../../../../usr/bin; \
2121 ln -sf ../../${XDTP}/usr/bin/$$i \
2122 ../../../../usr/bin/${XDDIR}-$$i; \
2123 ln -sf ../../${XDTP}/usr/bin/$$i \
2124 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2127 xdev xdev-build xdev-install xdev-links:
2128 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"