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:${SHELL})
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
33 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34 # All libraries and includes, and some build tools will still build.
37 # The intended user-driven targets are:
38 # buildworld - rebuild *everything*, including glue to help do upgrades
39 # installworld- install everything built by "buildworld"
40 # checkworld - run test suite on installed world
41 # doxygen - build API documentation of the kernel
42 # update - convenient way to update your source tree (eg: svn/svnup)
44 # Standard targets (not defined here) are documented in the makefiles in
45 # /usr/share/mk. These include:
46 # obj depend all install clean cleandepend cleanobj
48 .if !defined(TARGET) || !defined(TARGET_ARCH)
49 .error "Both TARGET and TARGET_ARCH must be defined."
52 LOCALBASE?= /usr/local
54 # Cross toolchain changes must be in effect before bsd.compiler.mk
55 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56 .if defined(CROSS_TOOLCHAIN)
57 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
60 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
61 .include "share/mk/src.opts.mk"
63 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
64 # keep the users system reasonably usable. For static->dynamic root upgrades,
65 # we don't want to install a dynamic binary without rtld and the needed
66 # libraries. More commonly, for dynamic root, we don't want to install a
67 # binary that requires a newer library version that hasn't been installed yet.
68 # This ordering is not a guarantee though. The only guarantee of a working
69 # system here would require fine-grained ordering of all components based
70 # on their dependencies.
72 .if !empty(SUBDIR_OVERRIDE)
73 SUBDIR= ${SUBDIR_OVERRIDE}
76 .if !defined(NO_ROOT) && (make(installworld) || make(install))
77 # Ensure libraries are installed before progressing.
81 .if ${MK_CDDL} != "no"
85 .if ${MK_KERBEROS} != "no"
88 .if ${MK_RESCUE} != "no"
92 .if ${MK_CRYPT} != "no"
95 .if !defined(NO_SHARE)
98 SUBDIR+=sys usr.bin usr.sbin
99 .if ${MK_TESTS} != "no"
102 .if ${MK_OFED} != "no"
106 # Local directories are last, since it is nice to at least get the base
107 # system rebuilt before you do them.
108 .for _DIR in ${LOCAL_DIRS}
109 .if exists(${.CURDIR}/${_DIR}/Makefile)
113 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
114 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
115 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
116 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
117 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
119 .for _DIR in ${LOCAL_LIB_DIRS}
120 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
123 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
127 # We must do etc/ last as it hooks into building the man whatis file
128 # by calling 'makedb' in share/man. This is only relevant for
129 # install/distribute so they build the whatis file after every manpage is
131 .if make(installworld) || make(install)
136 .endif # !empty(SUBDIR_OVERRIDE)
139 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
142 .if defined(NO_CLEANDIR)
143 CLEANDIR= clean cleandepend
148 # FAST_DEPEND can skip depend tree-walks.
149 .if ${MK_FAST_DEPEND} == "yes"
153 # Ensure shell checks later have a value.
154 .if defined(NO_DEPEND)
159 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
161 .if empty(SHELL:M*csh*)
162 BUILDENV_SHELL?=${SHELL}
164 BUILDENV_SHELL?=/bin/sh
167 SVN?= /usr/local/bin/svn
170 MAKEOBJDIRPREFIX?= /usr/obj
171 .if !defined(OSRELDATE)
172 .if exists(/usr/include/osreldate.h)
173 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
174 /usr/include/osreldate.h
181 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
182 .if !defined(VERSION) && !make(showconfig)
183 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
184 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
185 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
186 ${SRCDIR}/sys/sys/param.h
187 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
191 KNOWN_ARCHES?= aarch64/arm64 \
210 .if ${TARGET} == ${TARGET_ARCH}
213 _t= ${TARGET_ARCH}/${TARGET}
216 .if empty(KNOWN_ARCHES:M${_t})
217 .error Unknown target ${TARGET_ARCH}:${TARGET}.
221 .if ${TARGET} == ${MACHINE}
222 TARGET_CPUTYPE?=${CPUTYPE}
227 .if !empty(TARGET_CPUTYPE)
228 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
230 _TARGET_CPUTYPE=dummy
232 # Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
233 .if !make(showconfig)
234 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
235 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
236 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
237 .error CPUTYPE global should be set with ?=.
241 BUILD_ARCH!= uname -p
242 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
243 .error To cross-build, set TARGET_ARCH.
246 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
247 OBJTREE= ${MAKEOBJDIRPREFIX}
249 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
251 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
252 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
253 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
254 STRICTTMPPATH= ${BPATH}:${XPATH}
255 TMPPATH= ${STRICTTMPPATH}:${PATH}
258 # Avoid running mktemp(1) unless actually needed.
259 # It may not be functional, e.g., due to new ABI
260 # when in the middle of installing over this system.
262 .if make(distributeworld) || make(installworld)
263 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
267 # Building a world goes through the following stages
269 # 1. legacy stage [BMAKE]
270 # This stage is responsible for creating compatibility
271 # shims that are needed by the bootstrap-tools,
272 # build-tools and cross-tools stages. These are generally
273 # APIs that tools from one of those three stages need to
274 # build that aren't present on the host.
275 # 1. bootstrap-tools stage [BMAKE]
276 # This stage is responsible for creating programs that
277 # are needed for backward compatibility reasons. They
278 # are not built as cross-tools.
279 # 2. build-tools stage [TMAKE]
280 # This stage is responsible for creating the object
281 # tree and building any tools that are needed during
282 # the build process. Some programs are listed during
283 # this phase because they build binaries to generate
284 # files needed to build these programs. This stage also
285 # builds the 'build-tools' target rather than 'all'.
286 # 3. cross-tools stage [XMAKE]
287 # This stage is responsible for creating any tools that
288 # are needed for building the system. A cross-compiler is one
289 # of them. This differs from build tools in two ways:
290 # 1. the 'all' target is built rather than 'build-tools'
291 # 2. these tools are installed into TMPPATH for stage 4.
292 # 4. world stage [WMAKE]
293 # This stage actually builds the world.
294 # 5. install stage (optional) [IMAKE]
295 # This stage installs a previously built world.
300 # Common environment for world related stages
301 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
302 MACHINE_ARCH=${TARGET_ARCH} \
304 CPUTYPE=${TARGET_CPUTYPE}
305 .if ${MK_GROFF} != "no"
306 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
307 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
308 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
310 .if defined(TARGET_CFLAGS)
311 CROSSENV+= ${TARGET_CFLAGS}
314 # bootstrap-tools stage
315 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
316 PATH=${BPATH}:${PATH} \
317 WORLDTMP=${WORLDTMP} \
318 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
319 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
321 BOOTSTRAPPING=${OSRELDATE} \
323 MK_HTML=no NO_LINT=yes MK_MAN=no \
324 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
325 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
326 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
327 MK_LLDB=no MK_TESTS=no \
330 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
331 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
335 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
336 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
337 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
339 BOOTSTRAPPING=${OSRELDATE} \
342 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
343 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
344 MK_LLDB=no MK_TESTS=no
347 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
348 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
349 MK_GDB=no MK_TESTS=no
352 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
353 PATH=${BPATH}:${PATH} \
355 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
356 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
358 BOOTSTRAPPING=${OSRELDATE} \
360 MK_HTML=no -DNO_LINT MK_MAN=no \
361 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
362 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
365 WMAKEENV= ${CROSSENV} \
367 INSTALL="sh ${.CURDIR}/tools/install.sh" \
371 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
373 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
376 .if defined(CROSS_TOOLCHAIN_PREFIX)
377 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
378 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
381 # If we do not have a bootstrap binutils (because the in-tree one does not
382 # support the target architecture), provide a default cross-binutils prefix.
383 # This allows aarch64 builds, for example, to automatically use the
384 # aarch64-binutils port or package.
385 .if !make(showconfig)
386 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
387 !defined(CROSS_BINUTILS_PREFIX)
388 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
389 .if !exists(${CROSS_BINUTILS_PREFIX})
390 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
395 XCOMPILERS= CC CXX CPP
396 .for COMPILER in ${XCOMPILERS}
397 .if defined(CROSS_COMPILER_PREFIX)
398 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
400 X${COMPILER}?= ${${COMPILER}}
403 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
404 .for BINUTIL in ${XBINUTILS}
405 .if defined(CROSS_BINUTILS_PREFIX) && \
406 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
407 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
409 X${BINUTIL}?= ${${BINUTIL}}
412 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
413 DEPFLAGS="${DEPFLAGS}" \
414 CPP="${XCPP} ${XCFLAGS}" \
415 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
416 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
417 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
420 .if ${XCC:N${CCACHE_BIN}:M/*}
421 .if defined(CROSS_BINUTILS_PREFIX)
422 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
423 # directory, but the compiler will look in the right place for it's
424 # tools so we don't need to tell it where to look.
425 .if exists(${CROSS_BINUTILS_PREFIX})
426 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
429 BFLAGS+= -B${WORLDTMP}/usr/bin
431 .if ${TARGET} == "arm"
432 .if ${TARGET_ARCH:M*hf*} != ""
433 TARGET_ABI= gnueabihf
438 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
439 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
440 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
441 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
442 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
443 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
444 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
447 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
448 XCFLAGS+= -target ${TARGET_TRIPLE}
450 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
451 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
453 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
454 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
456 XCXXFLAGS+= ${BFLAGS}
460 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
462 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
464 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
465 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
467 .if ${TARGET_ARCH} == "amd64"
468 .if empty(TARGET_CPUTYPE)
469 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
471 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
473 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
474 MACHINE_CPU="i686 mmx sse sse2"
477 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
478 OBJCOPY="${XOBJCOPY}"
480 .elif ${TARGET_ARCH} == "powerpc64"
481 .if empty(TARGET_CPUTYPE)
482 LIB32CPUFLAGS= -mcpu=powerpc
484 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
486 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
488 LD="${XLD} -m elf32ppc_fbsd" \
489 OBJCOPY="${XOBJCOPY}"
493 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
494 -isystem ${LIB32TMP}/usr/include/ \
495 -L${LIB32TMP}/usr/lib32 \
496 -B${LIB32TMP}/usr/lib32
497 .if ${XCC:N${CCACHE_BIN}:M/*}
498 LIB32FLAGS+= --sysroot=${WORLDTMP}
501 # Yes, the flags are redundant.
502 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
503 _LDSCRIPTROOT=${LIB32TMP} \
504 INSTALL="sh ${.CURDIR}/tools/install.sh" \
507 SHLIBDIR=/usr/lib32 \
508 DTRACE="${DTRACE} -32"
509 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
510 CXX="${XCXX} ${LIB32FLAGS}" \
511 DESTDIR=${LIB32TMP} \
519 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
521 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
522 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
525 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
526 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
527 ${IMAKE_INSTALL} ${IMAKE_MTREE}
528 .if empty(.MAKEFLAGS:M-n)
529 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
530 LD_LIBRARY_PATH=${INSTALLTMP} \
531 PATH_LOCALE=${INSTALLTMP}/locale
532 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
534 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
536 .if defined(DB_FROM_SRC)
537 INSTALLFLAGS+= -N ${.CURDIR}/etc
538 MTREEFLAGS+= -N ${.CURDIR}/etc
540 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
541 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
543 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
544 IMAKE+= -DNO_ROOT METALOG=${METALOG}
545 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
548 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
549 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
550 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
554 KMAKEENV= ${WMAKEENV}
555 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
560 # Attempt to rebuild the entire system, with reasonable chance of
561 # success, regardless of how old your existing system is.
564 .if ${.CURDIR:C/[^,]//g} != ""
565 # The m4 build of sendmail files doesn't like it if ',' is used
566 # anywhere in the path of it's files.
568 @echo "*** Error: path to source tree contains a comma ','"
573 @echo "--------------------------------------------------------------"
574 @echo ">>> Rebuilding the temporary build tree"
575 @echo "--------------------------------------------------------------"
576 .if !defined(NO_CLEAN)
578 .if defined(LIB32TMP)
582 rm -rf ${WORLDTMP}/legacy/usr/include
583 # XXX - These can depend on any header file.
584 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
585 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
588 lib lib/casper usr legacy/bin legacy/usr
589 mkdir -p ${WORLDTMP}/${_dir}
591 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
592 -p ${WORLDTMP}/legacy/usr >/dev/null
593 .if ${MK_GROFF} != "no"
594 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
595 -p ${WORLDTMP}/legacy/usr >/dev/null
597 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
598 -p ${WORLDTMP}/usr >/dev/null
599 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
600 -p ${WORLDTMP}/usr/include >/dev/null
601 ln -sf ${.CURDIR}/sys ${WORLDTMP}
602 .if ${MK_DEBUG_FILES} != "no"
603 # We could instead disable debug files for these build stages
604 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
605 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
606 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
607 -p ${WORLDTMP}/usr/lib >/dev/null
609 .if ${MK_LIB32} != "no"
610 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
611 -p ${WORLDTMP}/usr >/dev/null
612 .if ${MK_DEBUG_FILES} != "no"
613 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
614 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
615 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
616 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
619 .if ${MK_TESTS} != "no"
620 mkdir -p ${WORLDTMP}${TESTSBASE}
621 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
622 -p ${WORLDTMP}${TESTSBASE} >/dev/null
623 .if ${MK_DEBUG_FILES} != "no"
624 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
625 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
626 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
629 .for _mtree in ${LOCAL_MTREE}
630 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
634 @echo "--------------------------------------------------------------"
635 @echo ">>> stage 1.1: legacy release compatibility shims"
636 @echo "--------------------------------------------------------------"
637 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
640 @echo "--------------------------------------------------------------"
641 @echo ">>> stage 1.2: bootstrap tools"
642 @echo "--------------------------------------------------------------"
643 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
645 .if !defined(NO_CLEAN)
647 @echo "--------------------------------------------------------------"
648 @echo ">>> stage 2.1: cleaning up the object tree"
649 @echo "--------------------------------------------------------------"
650 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
651 .if defined(LIB32TMP)
652 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 2.2: rebuilding the object tree"
659 @echo "--------------------------------------------------------------"
660 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
663 @echo "--------------------------------------------------------------"
664 @echo ">>> stage 2.3: build tools"
665 @echo "--------------------------------------------------------------"
666 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
669 @echo "--------------------------------------------------------------"
670 @echo ">>> stage 3: cross tools"
671 @echo "--------------------------------------------------------------"
672 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
673 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
676 @echo "--------------------------------------------------------------"
677 @echo ">>> stage 4.1: building includes"
678 @echo "--------------------------------------------------------------"
679 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
680 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
681 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
683 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
684 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
688 @echo "--------------------------------------------------------------"
689 @echo ">>> stage 4.2: building libraries"
690 @echo "--------------------------------------------------------------"
691 ${_+_}cd ${.CURDIR}; \
692 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
693 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
696 @echo "--------------------------------------------------------------"
697 @echo ">>> stage 4.3: make dependencies"
698 @echo "--------------------------------------------------------------"
699 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
702 @echo "--------------------------------------------------------------"
703 @echo ">>> stage 4.4: building everything"
704 @echo "--------------------------------------------------------------"
705 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
706 .if defined(LIB32TMP)
709 @echo "--------------------------------------------------------------"
710 @echo ">>> stage 5.1: building 32 bit shim libraries"
711 @echo "--------------------------------------------------------------"
712 mkdir -p ${LIB32TMP}/usr/include
713 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
714 -p ${LIB32TMP}/usr >/dev/null
715 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
716 -p ${LIB32TMP}/usr/include >/dev/null
717 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
718 -p ${LIB32TMP}/usr >/dev/null
719 .if ${MK_DEBUG_FILES} != "no"
720 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
721 -p ${LIB32TMP}/usr/lib >/dev/null
722 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
723 -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
726 ln -sf ${.CURDIR}/sys ${WORLDTMP}
727 .for _t in obj includes
728 ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
729 ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
730 .if ${MK_CDDL} != "no"
731 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
733 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
734 .if ${MK_CRYPT} != "no"
735 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
737 .if ${MK_KERBEROS} != "no"
738 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
741 .for _dir in usr.bin/lex/lib
742 ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
744 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
745 ${_+_}cd ${.CURDIR}/${_dir}; \
746 WORLDTMP=${WORLDTMP} \
747 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
748 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
749 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
752 ${_+_}cd ${.CURDIR}; \
753 ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
754 .for _t in obj depend all
755 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
756 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
757 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
758 DIRPRFX=usr.bin/ldd ${_t}
761 distribute32 install32: .MAKE .PHONY
762 ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
763 .if ${MK_CDDL} != "no"
764 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
766 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
767 .if ${MK_CRYPT} != "no"
768 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
770 .if ${MK_KERBEROS} != "no"
771 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
773 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
774 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
775 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
780 WMAKE_TGTS+= _worldtmp _legacy
781 .if empty(SUBDIR_OVERRIDE)
782 WMAKE_TGTS+= _bootstrap-tools
784 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
785 WMAKE_TGTS+= _includes _libraries
786 .if !defined(NO_DEPEND)
789 WMAKE_TGTS+= everything
790 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
794 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
795 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
798 @echo "--------------------------------------------------------------"
799 @echo ">>> World build started on `LC_ALL=C date`"
800 @echo "--------------------------------------------------------------"
804 @echo "--------------------------------------------------------------"
805 @echo ">>> World build completed on `LC_ALL=C date`"
806 @echo "--------------------------------------------------------------"
809 # We need to have this as a target because the indirection between Makefile
810 # and Makefile.inc1 causes the correct PATH to be used, rather than a
811 # modification of the current environment's PATH. In addition, we need
812 # to quote multiword values.
815 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
817 .if ${.TARGETS:Mbuildenv}
818 .if ${.MAKEFLAGS:M-j}
819 .error The buildenv target is incompatible with -j
822 BUILDENV_DIR?= ${.CURDIR}
824 @echo Entering world for ${TARGET_ARCH}:${TARGET}
825 .if ${BUILDENV_SHELL:M*zsh*}
826 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
828 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
831 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
832 toolchain: ${TOOLCHAIN_TGTS}
833 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
838 # Checks to be sure system is ready for installworld/installkernel.
840 installcheck: _installcheck_world _installcheck_kernel
842 _installcheck_kernel:
845 # Require DESTDIR to be set if installing for a different architecture or
846 # using the user/group database in the source tree.
848 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
850 .if !make(distributeworld)
851 _installcheck_world: __installcheck_DESTDIR
852 _installcheck_kernel: __installcheck_DESTDIR
853 __installcheck_DESTDIR:
854 .if !defined(DESTDIR) || empty(DESTDIR)
855 @echo "ERROR: Please set DESTDIR!"; \
861 .if !defined(DB_FROM_SRC)
863 # Check for missing UIDs/GIDs.
865 CHECK_UIDS= auditdistd
867 .if ${MK_SENDMAIL} != "no"
873 CHECK_GIDS+= proxy authpf
875 .if ${MK_UNBOUND} != "no"
879 _installcheck_world: __installcheck_UGID
881 .for uid in ${CHECK_UIDS}
882 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
883 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
887 .for gid in ${CHECK_GIDS}
888 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
889 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
896 # Required install tools to be saved in a scratch dir for safety.
898 .if ${MK_ZONEINFO} != "no"
899 _zoneinfo= zic tzsetup
902 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
903 date echo egrep find grep id install ${_install-info} \
904 ln make mkdir mtree mv pwd_mkdb \
905 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
908 # Needed for share/man
909 .if ${MK_MAN} != "no"
916 # Distributes everything compiled by a `buildworld'.
920 # Installs everything compiled by a 'buildworld'.
923 # Non-base distributions produced by the base system
924 EXTRA_DISTRIBUTIONS= doc
925 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
926 EXTRA_DISTRIBUTIONS+= lib32
928 .if ${MK_TESTS} != "no"
929 EXTRA_DISTRIBUTIONS+= tests
933 .if ${MK_DEBUG_FILES} != "no"
934 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
937 MTREE_MAGIC?= mtree 2.0
939 distributeworld installworld: _installcheck_world
940 mkdir -p ${INSTALLTMP}
941 progs=$$(for prog in ${ITOOLS}; do \
942 if progpath=`which $$prog`; then \
945 echo "Required tool $$prog not found in PATH." >&2; \
949 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
950 while read line; do \
952 if [ "$$2 $$3" != "not found" ]; then \
955 echo "Required library $$1 not found." >&2; \
959 cp $$libs $$progs ${INSTALLTMP}
960 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
962 echo "#${MTREE_MAGIC}" > ${METALOG}
964 .if make(distributeworld)
965 .for dist in ${EXTRA_DISTRIBUTIONS}
966 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
967 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
968 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
969 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
970 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
971 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
972 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
973 .if ${MK_DEBUG_FILES} != "no"
974 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
975 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
977 .if ${MK_LIB32} != "no"
978 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
979 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
980 .if ${MK_DEBUG_FILES} != "no"
981 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
982 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
985 .if ${MK_TESTS} != "no" && ${dist} == "tests"
986 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
987 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
988 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
989 .if ${MK_DEBUG_FILES} != "no"
990 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
991 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
995 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
996 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
997 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
998 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
999 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1000 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1001 .if ${MK_LIB32} != "no"
1002 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1003 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1007 -mkdir ${DESTDIR}/${DISTDIR}/base
1008 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1009 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1010 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1011 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1013 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1014 ${IMAKEENV} rm -rf ${INSTALLTMP}
1015 .if make(distributeworld)
1016 .for dist in ${EXTRA_DISTRIBUTIONS}
1017 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1019 .if defined(NO_ROOT)
1020 .for dist in base ${EXTRA_DISTRIBUTIONS}
1021 @# For each file that exists in this dist, print the corresponding
1022 @# line from the METALOG. This relies on the fact that
1023 @# a line containing only the filename will sort immediatly before
1024 @# the relevant mtree line.
1025 cd ${DESTDIR}/${DISTDIR}; \
1026 find ./${dist} | sort -u ${METALOG} - | \
1027 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1028 ${DESTDIR}/${DISTDIR}/${dist}.meta
1030 .for dist in ${DEBUG_DISTRIBUTIONS}
1031 @# For each file that exists in this dist, print the corresponding
1032 @# line from the METALOG. This relies on the fact that
1033 @# a line containing only the filename will sort immediatly before
1034 @# the relevant mtree line.
1035 cd ${DESTDIR}/${DISTDIR}; \
1036 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1037 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1038 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1044 .for dist in base ${EXTRA_DISTRIBUTIONS}
1045 .if defined(NO_ROOT)
1046 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1047 tar cvf - --exclude usr/lib/debug \
1048 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1049 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1051 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1052 tar cvf - --exclude usr/lib/debug . | \
1053 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1057 .for dist in ${DEBUG_DISTRIBUTIONS}
1058 . if defined(NO_ROOT)
1059 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1060 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1061 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1063 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1064 tar cvLf - usr/lib/debug | \
1065 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1072 # If you have a build server, you can NFS mount the source and obj directories
1073 # and do a 'make reinstall' on the *client* to install new binaries from the
1074 # most recent server build.
1076 reinstall: .MAKE .PHONY
1077 @echo "--------------------------------------------------------------"
1078 @echo ">>> Making hierarchy"
1079 @echo "--------------------------------------------------------------"
1080 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1081 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1083 @echo "--------------------------------------------------------------"
1084 @echo ">>> Installing everything"
1085 @echo "--------------------------------------------------------------"
1086 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1087 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1088 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1091 redistribute: .MAKE .PHONY
1092 @echo "--------------------------------------------------------------"
1093 @echo ">>> Distributing everything"
1094 @echo "--------------------------------------------------------------"
1095 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1096 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1097 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1101 distrib-dirs distribution: .MAKE .PHONY
1102 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1103 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1104 .if make(distribution)
1105 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1106 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1107 METALOG=${METALOG} MK_TESTS=no installconfig
1111 # buildkernel and installkernel
1113 # Which kernels to build and/or install is specified by setting
1114 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1115 # Only the existing (depending TARGET) config files are used
1116 # for building kernels and only the first of these is designated
1117 # as the one being installed.
1119 # Note that we have to use TARGET instead of TARGET_ARCH when
1120 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1121 # be set to cross-build, we have to make sure TARGET is set
1124 .if defined(KERNFAST)
1129 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1130 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1131 KERNCONF=${KERNFAST}
1134 .if ${TARGET_ARCH} == "powerpc64"
1135 KERNCONF?= GENERIC64
1139 INSTKERNNAME?= kernel
1141 KERNSRCDIR?= ${.CURDIR}/sys
1142 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1143 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1144 KERNCONFDIR?= ${KRNLCONFDIR}
1148 .if defined(NO_INSTALLKERNEL)
1149 # All of the BUILDKERNELS loops start at index 1.
1150 BUILDKERNELS+= dummy
1152 .for _kernel in ${KERNCONF}
1153 .if exists(${KERNCONFDIR}/${_kernel})
1154 BUILDKERNELS+= ${_kernel}
1155 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1156 INSTALLKERNEL= ${_kernel}
1161 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1166 # Builds all kernels defined by BUILDKERNELS.
1168 buildkernel: .MAKE .PHONY
1169 .if empty(BUILDKERNELS:Ndummy)
1170 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1174 .for _kernel in ${BUILDKERNELS:Ndummy}
1175 @echo "--------------------------------------------------------------"
1176 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1177 @echo "--------------------------------------------------------------"
1178 @echo "===> ${_kernel}"
1179 mkdir -p ${KRNLOBJDIR}
1180 .if !defined(NO_KERNELCONFIG)
1182 @echo "--------------------------------------------------------------"
1183 @echo ">>> stage 1: configuring the kernel"
1184 @echo "--------------------------------------------------------------"
1185 cd ${KRNLCONFDIR}; \
1187 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1188 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1190 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1192 @echo "--------------------------------------------------------------"
1193 @echo ">>> stage 2.1: cleaning up the object tree"
1194 @echo "--------------------------------------------------------------"
1195 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1197 .if !defined(NO_KERNELOBJ)
1199 @echo "--------------------------------------------------------------"
1200 @echo ">>> stage 2.2: rebuilding the object tree"
1201 @echo "--------------------------------------------------------------"
1202 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1205 @echo "--------------------------------------------------------------"
1206 @echo ">>> stage 2.3: build tools"
1207 @echo "--------------------------------------------------------------"
1208 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1209 .if !defined(NO_KERNELDEPEND)
1211 @echo "--------------------------------------------------------------"
1212 @echo ">>> stage 3.1: making dependencies"
1213 @echo "--------------------------------------------------------------"
1214 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1217 @echo "--------------------------------------------------------------"
1218 @echo ">>> stage 3.2: building everything"
1219 @echo "--------------------------------------------------------------"
1220 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1221 @echo "--------------------------------------------------------------"
1222 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1223 @echo "--------------------------------------------------------------"
1227 # installkernel, etc.
1229 # Install the kernel defined by INSTALLKERNEL
1231 installkernel installkernel.debug \
1232 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1233 .if !defined(NO_INSTALLKERNEL)
1234 .if empty(INSTALLKERNEL)
1235 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1238 @echo "--------------------------------------------------------------"
1239 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1240 @echo "--------------------------------------------------------------"
1241 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1242 ${CROSSENV} PATH=${TMPPATH} \
1243 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1245 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1246 .for _kernel in ${BUILDKERNELS:[2..-1]}
1247 @echo "--------------------------------------------------------------"
1248 @echo ">>> Installing kernel ${_kernel}"
1249 @echo "--------------------------------------------------------------"
1250 cd ${KRNLOBJDIR}/${_kernel}; \
1251 ${CROSSENV} PATH=${TMPPATH} \
1252 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1256 distributekernel distributekernel.debug:
1257 .if !defined(NO_INSTALLKERNEL)
1258 .if empty(INSTALLKERNEL)
1259 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1262 mkdir -p ${DESTDIR}/${DISTDIR}
1263 .if defined(NO_ROOT)
1264 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1266 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1267 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1268 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1269 DESTDIR=${INSTALL_DDIR}/kernel \
1270 ${.TARGET:S/distributekernel/install/}
1271 .if defined(NO_ROOT)
1272 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1273 ${DESTDIR}/${DISTDIR}/kernel.meta
1276 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1277 .for _kernel in ${BUILDKERNELS:[2..-1]}
1278 .if defined(NO_ROOT)
1279 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1281 cd ${KRNLOBJDIR}/${_kernel}; \
1282 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1283 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1284 KERNEL=${INSTKERNNAME}.${_kernel} \
1285 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1286 ${.TARGET:S/distributekernel/install/}
1287 .if defined(NO_ROOT)
1288 sed -e 's|^./kernel|.|' \
1289 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1290 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1296 .if defined(NO_ROOT)
1297 .if !defined(NO_INSTALLKERNEL)
1298 cd ${DESTDIR}/${DISTDIR}/kernel; \
1299 tar cvf - --exclude '*.debug' \
1300 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1301 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1303 cd ${DESTDIR}/${DISTDIR}/kernel; \
1304 tar cvf - --include '*/*/*.debug' \
1305 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1306 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1307 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1308 .for _kernel in ${BUILDKERNELS:[2..-1]}
1309 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1310 tar cvf - --exclude '*.debug' \
1311 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1312 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1313 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1314 tar cvf - --include '*/*/*.debug' \
1315 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1316 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1320 .if !defined(NO_INSTALLKERNEL)
1321 cd ${DESTDIR}/${DISTDIR}/kernel; \
1322 tar cvf - --exclude '*.debug' . | \
1323 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1325 cd ${DESTDIR}/${DISTDIR}/kernel; \
1326 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1327 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1328 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1329 .for _kernel in ${BUILDKERNELS:[2..-1]}
1330 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1331 tar cvf - --exclude '*.debug' . | \
1332 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1333 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1334 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1335 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1344 # Run test suite on installed world.
1347 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1348 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1351 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1357 # Build the API documentation with doxygen
1360 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1361 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1364 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1369 # Update the source tree(s), by running svn/svnup to update to the
1373 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1374 @echo "--------------------------------------------------------------"
1375 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1376 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1377 @echo "--------------------------------------------------------------"
1380 .if defined(SVN_UPDATE)
1381 @echo "--------------------------------------------------------------"
1382 @echo ">>> Updating ${.CURDIR} using Subversion"
1383 @echo "--------------------------------------------------------------"
1384 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1388 # ------------------------------------------------------------------------
1390 # From here onwards are utility targets used by the 'make world' and
1391 # related targets. If your 'world' breaks, you may like to try to fix
1392 # the problem and manually run the following targets to attempt to
1393 # complete the build. Beware, this is *not* guaranteed to work, you
1394 # need to have a pretty good grip on the current state of the system
1395 # to attempt to manually finish it. If in doubt, 'make world' again.
1399 # legacy: Build compatibility shims for the next three targets. This is a
1400 # minimal set of tools and shims necessary to compensate for older systems
1401 # which don't have the APIs required by the targets built in bootstrap-tools,
1402 # build-tools or cross-tools.
1405 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1406 .if ${BOOTSTRAPPING} < 1100006
1407 _elftoolchain_libs= lib/libelf lib/libdwarf
1411 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1412 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1415 .for _tool in tools/build ${_elftoolchain_libs}
1416 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1417 cd ${.CURDIR}/${_tool}; \
1418 ${MAKE} DIRPRFX=${_tool}/ obj; \
1419 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1420 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1421 ${MAKE} DIRPRFX=${_tool}/ all; \
1422 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1426 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1427 # are built to build other binaries in the system. However, the focus of these
1428 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1429 # libraries, augmented by -legacy.
1431 _bt= _bootstrap-tools
1433 .if ${MK_GAMES} != "no"
1434 _strfile= usr.bin/fortune/strfile
1437 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1438 _gperf= gnu/usr.bin/gperf
1441 .if ${MK_GROFF} != "no"
1442 _groff= gnu/usr.bin/groff \
1446 .if ${MK_VT} != "no"
1447 _vtfontcvt= usr.bin/vtfontcvt
1450 .if ${BOOTSTRAPPING} < 900002
1454 .if ${BOOTSTRAPPING} < 1000033
1455 _libopenbsd= lib/libopenbsd
1459 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1460 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1463 .if ${BOOTSTRAPPING} < 1000026
1464 _nmtree= lib/libnetbsd \
1467 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1470 .if ${BOOTSTRAPPING} < 1000027
1474 # r277259 crunchide: Correct 64-bit section header offset
1475 # r281674 crunchide: always include both 32- and 64-bit ELF support
1476 # r285986 crunchen: use STRIPBIN rather than STRIP
1477 .if ${BOOTSTRAPPING} < 1100078
1478 _crunch= usr.sbin/crunch
1481 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1488 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1490 .if ${MK_BSNMP} != "no"
1491 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1494 # We need to build tblgen when we're building clang either as
1495 # the bootstrap compiler, or as the part of the normal build.
1496 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1498 lib/clang/libllvmsupport \
1499 lib/clang/libllvmtablegen \
1500 usr.bin/clang/tblgen \
1501 usr.bin/clang/clang-tblgen
1503 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1504 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1507 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1510 .if ${MK_GPL_DTC} != "no"
1511 _dtc= gnu/usr.bin/dtc
1514 .if ${MK_KERBEROS} != "no"
1515 _kerberos5_bootstrap_tools= \
1516 kerberos5/tools/make-roken \
1517 kerberos5/lib/libroken \
1518 kerberos5/lib/libvers \
1519 kerberos5/tools/asn1_compile \
1520 kerberos5/tools/slc \
1523 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1526 .if ${MK_MANDOCDB} != "no"
1527 _libopenbsd?= lib/libopenbsd
1528 _makewhatis= lib/libsqlite3 \
1530 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1532 _makewhatis=usr.bin/makewhatis
1535 bootstrap-tools: .PHONY
1537 # Please document (add comment) why something is in 'bootstrap-tools'.
1538 # Try to bound the building of the bootstrap-tool to just the
1539 # FreeBSD versions that need the tool built at this stage of the build.
1542 ${_kerberos5_bootstrap_tools} \
1564 ${_bt}-${_tool}: .PHONY .MAKE
1565 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1566 cd ${.CURDIR}/${_tool}; \
1567 ${MAKE} DIRPRFX=${_tool}/ obj; \
1568 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1569 ${MAKE} DIRPRFX=${_tool}/ all; \
1570 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1572 bootstrap-tools: ${_bt}-${_tool}
1576 # build-tools: Build special purpose build tools
1578 .if !defined(NO_SHARE)
1579 _share= share/syscons/scrnmaps
1582 .if ${MK_GCC} != "no"
1583 _gcc_tools= gnu/usr.bin/cc/cc_tools
1586 .if ${MK_RESCUE} != "no"
1587 # rescue includes programs that have build-tools targets
1588 _rescue=rescue/rescue
1594 ${LOCAL_TOOL_DIRS} \
1595 lib/ncurses/ncurses \
1596 lib/ncurses/ncursesw \
1601 usr.bin/mkesdb_static \
1602 usr.bin/mkcsmapper_static \
1604 build-tools_${_tool}: .PHONY
1605 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1606 cd ${.CURDIR}/${_tool}; \
1607 ${MAKE} DIRPRFX=${_tool}/ obj; \
1608 ${MAKE} DIRPRFX=${_tool}/ build-tools
1609 build-tools: build-tools_${_tool}
1613 build-tools_${_tool}: .PHONY
1614 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1615 cd ${.CURDIR}/${_tool}; \
1616 ${MAKE} DIRPRFX=${_tool}/ obj; \
1617 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1618 ${MAKE} DIRPRFX=${_tool}/ all
1619 build-tools: build-tools_${_tool}
1623 # kernel-tools: Build kernel-building tools
1626 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1627 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1628 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1631 # cross-tools: All the tools needed to build the rest of the system after
1632 # we get done with the earlier stages. It is the last set of tools needed
1633 # to begin building the target binaries.
1635 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1636 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1637 _btxld= usr.sbin/btxld
1641 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1642 # resulting from missing bug fixes or ELF Toolchain updates.
1643 .if ${MK_CDDL} != "no"
1644 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1645 cddl/usr.bin/ctfmerge
1648 # If we're given an XAS, don't build binutils.
1649 .if ${XAS:M/*} == ""
1650 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1651 _binutils= gnu/usr.bin/binutils
1653 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1654 _elftctools= lib/libelftc \
1660 # These are not required by the build, but can be useful for developers who
1661 # cross-build on a FreeBSD 10 host:
1662 _elftctools+= usr.bin/addr2line
1664 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1665 # If cross-building with an external binutils we still need to build strip for
1666 # the target (for at least crunchide).
1667 _elftctools= lib/libelftc \
1672 # If an full path to an external cross compiler is given, don't build
1674 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1675 .if ${MK_CLANG_BOOTSTRAP} != "no"
1676 _clang= usr.bin/clang
1677 _clang_libs= lib/clang
1679 .if ${MK_GCC_BOOTSTRAP} != "no"
1683 .if ${MK_USB} != "no"
1684 _usb_tools= sys/boot/usb/tools
1687 cross-tools: .MAKE .PHONY
1698 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1699 cd ${.CURDIR}/${_tool}; \
1700 ${MAKE} DIRPRFX=${_tool}/ obj; \
1701 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1702 ${MAKE} DIRPRFX=${_tool}/ all; \
1703 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1706 NXBDESTDIR= ${OBJTREE}/nxb-bin
1707 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1708 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1709 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1710 NXBMAKE= ${NXBENV} ${MAKE} \
1711 TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1712 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1713 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1714 MK_GDB=no MK_TESTS=no \
1716 MK_HTML=no NO_LINT=yes MK_MAN=no \
1717 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1718 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1719 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1720 MK_LLDB=no MK_DEBUG_FILES=no
1722 # native-xtools is the current target for qemu-user cross builds of ports
1723 # via poudriere and the imgact_binmisc kernel module.
1724 # For non-clang enabled targets that are still using the in tree gcc
1725 # we must build a gperf binary for one instance of its Makefiles. On
1726 # clang-enabled systems, the gperf binary is obsolete.
1727 native-xtools: .PHONY
1728 .if ${MK_GCC_BOOTSTRAP} != "no"
1729 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1730 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1731 cd ${.CURDIR}/${_gperf}; \
1732 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1733 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1734 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1735 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1737 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1738 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1739 -p ${NXBDESTDIR}/usr >/dev/null
1740 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1741 -p ${NXBDESTDIR}/usr/include >/dev/null
1742 .if ${MK_DEBUG_FILES} != "no"
1743 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1744 -p ${NXBDESTDIR}/usr/lib >/dev/null
1805 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1806 cd ${.CURDIR}/${_tool}; \
1807 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1808 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1809 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1810 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1814 # hierarchy - ensure that all the needed directories are present
1816 hierarchy hier: .MAKE .PHONY
1817 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1820 # libraries - build all libraries, and install them under ${DESTDIR}.
1822 # The list of libraries with dependents (${_prebuild_libs}) and their
1823 # interdependencies (__L) are built automatically by the
1824 # ${.CURDIR}/tools/make_libdeps.sh script.
1826 libraries: .MAKE .PHONY
1827 ${_+_}cd ${.CURDIR}; \
1828 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1829 ${MAKE} -f Makefile.inc1 _startup_libs; \
1830 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1831 ${MAKE} -f Makefile.inc1 _generic_libs
1834 # static libgcc.a prerequisite for shared libc
1836 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1838 # These dependencies are not automatically generated:
1840 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1841 # all shared libraries for ELF.
1843 _startup_libs= gnu/lib/csu
1844 _startup_libs+= lib/csu
1845 _startup_libs+= gnu/lib/libgcc
1846 _startup_libs+= lib/libcompiler_rt
1847 _startup_libs+= lib/libc
1848 _startup_libs+= lib/libc_nonshared
1849 .if ${MK_LIBCPLUSPLUS} != "no"
1850 _startup_libs+= lib/libcxxrt
1853 gnu/lib/libgcc__L: lib/libc__L
1854 gnu/lib/libgcc__L: lib/libc_nonshared__L
1855 .if ${MK_LIBCPLUSPLUS} != "no"
1856 lib/libcxxrt__L: gnu/lib/libgcc__L
1859 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1860 ${_kerberos5_lib_libhdb} \
1861 ${_kerberos5_lib_libheimbase} \
1862 ${_kerberos5_lib_libheimntlm} \
1864 ${_kerberos5_lib_libheimipcc} \
1865 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1866 ${_kerberos5_lib_libroken} \
1867 ${_kerberos5_lib_libwind} \
1868 lib/libbz2 ${_libcom_err} lib/libcrypt \
1869 lib/libelf lib/libexpat \
1872 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1874 lib/ncurses/ncurses lib/ncurses/ncursesw \
1875 lib/libopie lib/libpam ${_lib_libthr} \
1876 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1878 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1879 ${_cddl_lib_libuutil} \
1880 ${_cddl_lib_libavl} \
1881 ${_cddl_lib_libzfs_core} \
1882 ${_cddl_lib_libctf} \
1883 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1884 ${_secure_lib_libcrypto} ${_lib_libldns} \
1885 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1887 .if ${MK_GNUCXX} != "no"
1888 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1889 gnu/lib/libstdc++__L: lib/msun__L
1890 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1893 .if ${MK_LIBCPLUSPLUS} != "no"
1894 _prebuild_libs+= lib/libc++
1897 lib/libgeom__L: lib/libexpat__L
1898 lib/libkvm__L: lib/libelf__L
1900 .if ${MK_LIBTHR} != "no"
1901 _lib_libthr= lib/libthr
1904 .if ${MK_RADIUS_SUPPORT} != "no"
1905 _lib_libradius= lib/libradius
1908 .if ${MK_OFED} != "no"
1909 _ofed_lib= contrib/ofed/usr.lib/
1912 .if ${MK_CASPER} != "no"
1913 _lib_casper= lib/libcasper
1916 lib/libpjdlog__L: lib/libutil__L
1917 lib/libcasper__L: lib/libnv__L
1918 lib/liblzma__L: lib/libthr__L
1920 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1921 .for _DIR in ${LOCAL_LIB_DIRS}
1922 .if exists(${.CURDIR}/${_DIR}/Makefile)
1923 _generic_libs+= ${_DIR}
1927 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1929 .if ${MK_CDDL} != "no"
1930 _cddl_lib_libumem= cddl/lib/libumem
1931 _cddl_lib_libnvpair= cddl/lib/libnvpair
1932 _cddl_lib_libavl= cddl/lib/libavl
1933 _cddl_lib_libuutil= cddl/lib/libuutil
1934 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1935 _cddl_lib_libctf= cddl/lib/libctf
1937 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1938 cddl/lib/libzfs__L: lib/libgeom__L
1939 cddl/lib/libctf__L: lib/libz__L
1941 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1942 # on select architectures though (see cddl/lib/Makefile)
1943 .if ${MACHINE_CPUARCH} != "sparc64"
1944 _prebuild_libs+= lib/libproc lib/librtld_db
1947 .if ${MK_CRYPT} != "no"
1948 .if ${MK_OPENSSL} != "no"
1949 _secure_lib_libcrypto= secure/lib/libcrypto
1950 _secure_lib_libssl= secure/lib/libssl
1951 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1952 .if ${MK_LDNS} != "no"
1953 _lib_libldns= lib/libldns
1954 lib/libldns__L: secure/lib/libcrypto__L
1956 .if ${MK_OPENSSH} != "no"
1957 _secure_lib_libssh= secure/lib/libssh
1958 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1959 .if ${MK_LDNS} != "no"
1960 secure/lib/libssh__L: lib/libldns__L
1962 .if ${MK_KERBEROS_SUPPORT} != "no"
1963 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1964 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1965 lib/libmd__L kerberos5/lib/libroken__L
1969 _secure_lib= secure/lib
1972 .if ${MK_KERBEROS} != "no"
1973 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1974 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1975 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1976 kerberos5/lib/libwind__L lib/libsqlite3__L
1977 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1978 kerberos5/lib/libroken__L lib/libcom_err__L
1979 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1980 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1981 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1982 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1983 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1984 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1985 kerberos5/lib/libroken__L: lib/libcrypt__L
1986 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1987 kerberos5/lib/libheimbase__L: lib/libthr__L
1988 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1991 lib/libsqlite3__L: lib/libthr__L
1993 .if ${MK_GSSAPI} != "no"
1994 _lib_libgssapi= lib/libgssapi
1997 .if ${MK_KERBEROS} != "no"
1998 _kerberos5_lib= kerberos5/lib
1999 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2000 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2001 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2002 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2003 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2004 _kerberos5_lib_libroken= kerberos5/lib/libroken
2005 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2006 _libsqlite3= lib/libsqlite3
2007 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2008 _kerberos5_lib_libwind= kerberos5/lib/libwind
2009 _libcom_err= lib/libcom_err
2012 .if ${MK_NIS} != "no"
2013 _lib_libypclnt= lib/libypclnt
2016 .if ${MK_OPENSSL} == "no"
2017 lib/libradius__L: lib/libmd__L
2021 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2022 .if ${MK_CXX} != "no"
2023 .if ${MK_LIBCPLUSPLUS} != "no"
2024 lib/libproc__L: lib/libcxxrt__L
2025 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2026 lib/libproc__L: gnu/lib/libsupc++__L
2030 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2032 .for _lib in ${_prereq_libs}
2033 ${_lib}__PL: .PHONY .MAKE
2034 .if exists(${.CURDIR}/${_lib})
2035 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2036 cd ${.CURDIR}/${_lib}; \
2037 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2038 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2039 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2040 DIRPRFX=${_lib}/ all; \
2041 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2042 DIRPRFX=${_lib}/ install
2046 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2047 ${_lib}__L: .PHONY .MAKE
2048 .if exists(${.CURDIR}/${_lib})
2049 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2050 cd ${.CURDIR}/${_lib}; \
2051 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2052 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2053 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2054 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2058 # libpam is special: we need to build static PAM modules before
2059 # static PAM library, and dynamic PAM library before dynamic PAM
2061 lib/libpam__L: .PHONY .MAKE
2062 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2063 cd ${.CURDIR}/lib/libpam; \
2064 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2065 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2066 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2067 -D_NO_LIBPAM_SO_YET all; \
2068 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2069 -D_NO_LIBPAM_SO_YET install
2071 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2072 _startup_libs: ${_startup_libs:S/$/__L/}
2073 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2074 _generic_libs: ${_generic_libs:S/$/__L/}
2076 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2077 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2078 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2079 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2080 # parallel. This is safe for the world stage of buildworld though since it has
2081 # already built libraries in a proper order and installed includes into
2082 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2083 # avoid trashing a system if it crashes mid-install.
2084 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2088 .include <bsd.subdir.mk>
2090 .if make(check-old) || make(check-old-dirs) || \
2091 make(check-old-files) || make(check-old-libs) || \
2092 make(delete-old) || make(delete-old-dirs) || \
2093 make(delete-old-files) || make(delete-old-libs)
2096 # check for / delete old files section
2099 .include "ObsoleteFiles.inc"
2101 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2102 else you can not start such an application. Consult UPDATING for more \
2103 information regarding how to cope with the removal/revision bump of a \
2106 .if !defined(BATCH_DELETE_OLD_FILES)
2113 @echo ">>> Removing old files (only deletes safe to delete libs)"
2114 # Ask for every old file if the user really wants to remove it.
2115 # It's annoying, but better safe than sorry.
2116 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2117 # argument list will get too long. Using .for/.endfor make "loops" will make
2118 # the Makefile parser segfault.
2121 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2122 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2123 while read file; do \
2124 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2125 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2126 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2128 for ext in debug symbols; do \
2129 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2130 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2131 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2136 # Remove catpages without corresponding manpages.
2138 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2139 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2140 while read catpage; do \
2142 if [ ! -e "$${manpage}" ]; then \
2143 rm ${RM_I} $${catpage} <&3; \
2146 @echo ">>> Old files removed"
2149 @echo ">>> Checking for old files"
2151 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2152 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2153 while read file; do \
2154 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2155 echo "${DESTDIR}/$${file}"; \
2157 for ext in debug symbols; do \
2158 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2159 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2163 # Check for catpages without corresponding manpages.
2164 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2165 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2166 while read catpage; do \
2168 if [ ! -e "$${manpage}" ]; then \
2174 @echo ">>> Removing old libraries"
2175 @echo "${OLD_LIBS_MESSAGE}" | fmt
2178 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2179 -V OLD_LIBS | xargs -n1 | \
2180 while read file; do \
2181 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2182 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2183 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2185 for ext in debug symbols; do \
2186 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2187 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2188 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2193 @echo ">>> Old libraries removed"
2196 @echo ">>> Checking for old libraries"
2198 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2199 -V OLD_LIBS | xargs -n1 | \
2200 while read file; do \
2201 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2202 echo "${DESTDIR}/$${file}"; \
2204 for ext in debug symbols; do \
2205 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2206 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2212 @echo ">>> Removing old directories"
2214 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2215 -V OLD_DIRS | xargs -n1 | sort -r | \
2216 while read dir; do \
2217 if [ -d "${DESTDIR}/$${dir}" ]; then \
2218 rmdir -v "${DESTDIR}/$${dir}" || true; \
2219 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2220 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2223 @echo ">>> Old directories removed"
2226 @echo ">>> Checking for old directories"
2228 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2229 -V OLD_DIRS | xargs -n1 | \
2230 while read dir; do \
2231 if [ -d "${DESTDIR}/$${dir}" ]; then \
2232 echo "${DESTDIR}/$${dir}"; \
2233 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2234 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2238 delete-old: delete-old-files delete-old-dirs
2239 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2241 check-old: check-old-files check-old-libs check-old-dirs
2242 @echo "To remove old files and directories run '${MAKE} delete-old'."
2243 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2248 # showconfig - show build configuration.
2251 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2252 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2254 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2255 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2257 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2258 .if exists(${KERNCONFDIR}/${KERNCONF})
2259 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2260 '${KERNCONFDIR}/${KERNCONF}' ; echo
2266 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2267 DTBOUTPUTPATH= ${.CURDIR}
2271 # Build 'standalone' Device Tree Blob
2274 @PATH=${TMPPATH} MACHINE=${TARGET} \
2275 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2276 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2281 # In the following, the first 'rm' in a series will usually remove all
2282 # files and directories. If it does not, then there are probably some
2283 # files with file flags set, so this unsets them and tries the 'rm' a
2284 # second time. There are situations where this target will be cleaning
2285 # some directories via more than one method, but that duplication is
2286 # needed to correctly handle all the possible situations. Removing all
2287 # files without file flags set in the first 'rm' instance saves time,
2288 # because 'chflags' will need to operate on fewer files afterwards.
2290 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2291 # created by bsd.obj.mk, except that we don't want to .include that file
2294 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2296 .if exists(${BW_CANONICALOBJDIR}/)
2297 -rm -rf ${BW_CANONICALOBJDIR}/*
2298 -chflags -R 0 ${BW_CANONICALOBJDIR}
2299 rm -rf ${BW_CANONICALOBJDIR}/*
2301 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2302 # To be safe in this case, fall back to a 'make cleandir'
2303 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2306 .if defined(TARGET) && defined(TARGET_ARCH)
2308 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2309 XDEV_CPUTYPE?=${CPUTYPE}
2311 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2314 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2315 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2316 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2317 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2318 CPUTYPE=${XDEV_CPUTYPE}
2320 XDDIR=${TARGET_ARCH}-freebsd
2323 .error XDTP variable should be an absolute path
2326 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2327 INSTALL="sh ${.CURDIR}/tools/install.sh"
2329 TOOLS_PREFIX=${XDTP}
2330 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2331 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2332 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2333 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2334 CPP="${CPP} ${CD2CFLAGS}" \
2335 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2337 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2338 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2339 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2340 XDDESTDIR=${DESTDIR}/${XDTP}
2342 OSREL!= uname -r | sed -e 's/[-(].*//'
2345 .ORDER: xdev-build xdev-install xdev-links
2346 xdev: xdev-build xdev-install
2348 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2349 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2351 _xb-worldtmp: .PHONY
2352 mkdir -p ${CDTMP}/usr
2353 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2354 -p ${CDTMP}/usr >/dev/null
2356 _xb-bootstrap-tools: .PHONY
2360 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2361 cd ${.CURDIR}/${_tool}; \
2362 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2363 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2364 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2365 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2368 _xb-build-tools: .PHONY
2369 ${_+_}@cd ${.CURDIR}; \
2370 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2372 _xb-cross-tools: .PHONY
2380 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2381 cd ${.CURDIR}/${_tool}; \
2382 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2383 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2384 ${CDMAKE} DIRPRFX=${_tool}/ all
2388 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2389 mkdir -p ${XDDESTDIR}
2390 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2391 -p ${XDDESTDIR} >/dev/null
2392 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2393 -p ${XDDESTDIR}/usr >/dev/null
2394 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2395 -p ${XDDESTDIR}/usr/include >/dev/null
2396 .if ${MK_LIB32} != "no"
2397 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2398 -p ${XDDESTDIR}/usr >/dev/null
2400 .if ${MK_TESTS} != "no"
2401 mkdir -p ${XDDESTDIR}${TESTSBASE}
2402 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2403 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2406 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2407 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2409 _xi-cross-tools: .PHONY
2410 @echo "_xi-cross-tools"
2418 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2419 cd ${.CURDIR}/${_tool}; \
2420 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2423 _xi-includes: .PHONY
2424 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2425 DESTDIR=${XDDESTDIR}
2427 _xi-libraries: .PHONY
2428 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2429 DESTDIR=${XDDESTDIR}
2432 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2433 mkdir -p ../../../../usr/bin; \
2435 ln -sf ../../${XDTP}/usr/bin/$$i \
2436 ../../../../usr/bin/${XDDIR}-$$i; \
2437 ln -sf ../../${XDTP}/usr/bin/$$i \
2438 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2441 xdev xdev-build xdev-install xdev-links:
2442 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"