4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 # -DNO_ROOT install without using root privilege
17 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
19 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22 # LOCAL_MTREE="list of mtree files" to process to allow local directories
23 # to be created before files are installed
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # METALOG="path to metadata log" to write permission and ownership
27 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
28 # TARGET="machine" to crossbuild world for a different machine type
29 # TARGET_ARCH= may be required when a TARGET supports multiple endians
30 # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
35 # The intended user-driven targets are:
36 # buildworld - rebuild *everything*, including glue to help do upgrades
37 # installworld- install everything built by "buildworld"
38 # doxygen - build API documentation of the kernel
39 # update - convenient way to update your source tree (eg: svn/svnup)
41 # Standard targets (not defined here) are documented in the makefiles in
42 # /usr/share/mk. These include:
43 # obj depend all install clean cleandepend cleanobj
45 .if !defined(TARGET) || !defined(TARGET_ARCH)
46 .error "Both TARGET and TARGET_ARCH must be defined."
49 .include "share/mk/src.opts.mk"
50 .include <bsd.arch.inc.mk>
51 .include <bsd.compiler.mk>
53 # We must do lib/ and libexec/ before bin/, because if installworld
54 # installs a new /bin/sh, the 'make' command will *immediately*
55 # use that new version. And the new (dynamically-linked) /bin/sh
56 # will expect to find appropriate libraries in /lib and /libexec.
59 .if defined(SUBDIR_OVERRIDE)
60 SUBDIR= ${SUBDIR_OVERRIDE}
64 .if ${MK_GAMES} != "no"
67 .if ${MK_CDDL} != "no"
71 .if ${MK_KERBEROS} != "no"
74 .if ${MK_RESCUE} != "no"
78 .if ${MK_CRYPT} != "no"
81 .if !defined(NO_SHARE)
84 SUBDIR+=sys usr.bin usr.sbin
85 .if ${MK_TESTS} != "no"
88 .if ${MK_OFED} != "no"
92 # We must do etc/ last for install/distribute to work.
96 # Local directories are last, since it is nice to at least get the base
97 # system rebuilt before you do them.
98 .for _DIR in ${LOCAL_DIRS}
99 .if exists(${.CURDIR}/${_DIR}/Makefile)
103 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
104 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
105 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
106 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
107 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
109 .for _DIR in ${LOCAL_LIB_DIRS}
110 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
113 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
121 .if defined(NO_CLEANDIR)
122 CLEANDIR= clean cleandepend
129 BUILDENV_SHELL?=/bin/sh
131 SVN?= /usr/local/bin/svn
134 MAKEOBJDIRPREFIX?= /usr/obj
135 .if !defined(OSRELDATE)
136 .if exists(/usr/include/osreldate.h)
137 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
138 /usr/include/osreldate.h
144 .if !defined(VERSION)
145 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
146 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
147 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
148 ${SRCDIR}/sys/sys/param.h
149 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
152 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
153 .if ${TARGET} == ${TARGET_ARCH}
156 _t= ${TARGET_ARCH}/${TARGET}
159 .if empty(KNOWN_ARCHES:M${_t})
160 .error Unknown target ${TARGET_ARCH}:${TARGET}.
164 .if ${TARGET} == ${MACHINE}
165 TARGET_CPUTYPE?=${CPUTYPE}
170 .if !empty(TARGET_CPUTYPE)
171 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
173 _TARGET_CPUTYPE=dummy
175 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
176 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
177 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
178 .error CPUTYPE global should be set with ?=.
181 BUILD_ARCH!= uname -p
182 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
183 .error To cross-build, set TARGET_ARCH.
186 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
187 OBJTREE= ${MAKEOBJDIRPREFIX}
189 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
191 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
192 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
193 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
194 STRICTTMPPATH= ${BPATH}:${XPATH}
195 TMPPATH= ${STRICTTMPPATH}:${PATH}
198 # Avoid running mktemp(1) unless actually needed.
199 # It may not be functional, e.g., due to new ABI
200 # when in the middle of installing over this system.
202 .if make(distributeworld) || make(installworld)
203 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
207 # Building a world goes through the following stages
209 # 1. legacy stage [BMAKE]
210 # This stage is responsible for creating compatibility
211 # shims that are needed by the bootstrap-tools,
212 # build-tools and cross-tools stages.
213 # 1. bootstrap-tools stage [BMAKE]
214 # This stage is responsible for creating programs that
215 # are needed for backward compatibility reasons. They
216 # are not built as cross-tools.
217 # 2. build-tools stage [TMAKE]
218 # This stage is responsible for creating the object
219 # tree and building any tools that are needed during
221 # 3. cross-tools stage [XMAKE]
222 # This stage is responsible for creating any tools that
223 # are needed for cross-builds. A cross-compiler is one
225 # 4. world stage [WMAKE]
226 # This stage actually builds the world.
227 # 5. install stage (optional) [IMAKE]
228 # This stage installs a previously built world.
233 # Common environment for world related stages
234 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
235 MACHINE_ARCH=${TARGET_ARCH} \
237 CPUTYPE=${TARGET_CPUTYPE}
238 .if ${MK_GROFF} != "no"
239 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
240 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
241 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
243 .if defined(TARGET_CFLAGS)
244 CROSSENV+= ${TARGET_CFLAGS}
247 # bootstrap-tools stage
248 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
249 PATH=${BPATH}:${PATH} \
250 WORLDTMP=${WORLDTMP} \
251 VERSION="${VERSION}" \
252 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
253 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
254 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
256 BOOTSTRAPPING=${OSRELDATE} \
258 MK_HTML=no NO_LINT=yes MK_MAN=no \
259 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
260 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
261 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
262 MK_LLDB=no MK_TESTS=no
265 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
266 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
267 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
269 BOOTSTRAPPING=${OSRELDATE} \
272 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
273 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
274 MK_LLDB=no MK_TESTS=no
277 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
278 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
279 MK_GDB=no MK_TESTS=no
282 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
283 PATH=${BPATH}:${PATH} \
284 WORLDTMP=${WORLDTMP} \
286 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
287 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
289 BOOTSTRAPPING=${OSRELDATE} \
291 MK_HTML=no -DNO_LINT MK_MAN=no \
292 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
293 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
296 WMAKEENV= ${CROSSENV} \
297 _SHLIBDIRPREFIX=${WORLDTMP} \
299 VERSION="${VERSION}" \
300 INSTALL="sh ${.CURDIR}/tools/install.sh" \
304 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
306 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
309 .if ${MK_CDDL} == "no"
313 .if defined(CROSS_TOOLCHAIN)
314 LOCALBASE?= /usr/local
315 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
317 .if defined(CROSS_TOOLCHAIN_PREFIX)
318 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
319 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
321 XCOMPILERS= CC CXX CPP
322 .for COMPILER in ${XCOMPILERS}
323 .if defined(CROSS_COMPILER_PREFIX)
324 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
326 X${COMPILER}?= ${${COMPILER}}
329 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
330 .for BINUTIL in ${XBINUTILS}
331 .if defined(CROSS_BINUTILS_PREFIX)
332 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
334 X${BINUTIL}?= ${${BINUTIL}}
337 WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
338 DEPFLAGS="${DEPFLAGS}" \
339 CPP="${XCPP} ${XCFLAGS}" \
340 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
341 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
342 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
346 .if defined(CROSS_BINUTILS_PREFIX)
347 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
348 # directory, but the compiler will look in the right place for it's
349 # tools so we don't need to tell it where to look.
350 .if exists(${CROSS_BINUTILS_PREFIX})
351 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
354 BFLAGS+= -B${WORLDTMP}/usr/bin
356 .if ${TARGET} == "arm"
357 .if ${TARGET_ARCH:M*hf*} != ""
358 TARGET_ABI= gnueabihf
363 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
364 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
365 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
366 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
369 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
370 XCFLAGS+= -target ${TARGET_TRIPLE}
371 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
372 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
375 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
376 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
378 XCXXFLAGS+= ${BFLAGS}
382 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
384 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
386 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
387 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
389 .if ${TARGET_ARCH} == "amd64"
390 .if empty(TARGET_CPUTYPE)
391 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
393 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
395 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
396 MACHINE_CPU="i686 mmx sse sse2"
399 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
401 .elif ${TARGET_ARCH} == "powerpc64"
402 .if empty(TARGET_CPUTYPE)
403 LIB32CPUFLAGS= -mcpu=powerpc
405 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
407 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
409 LD="${LD} -m elf32ppc_fbsd"
413 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
414 -isystem ${LIB32TMP}/usr/include/ \
415 -L${LIB32TMP}/usr/lib32 \
416 -B${LIB32TMP}/usr/lib32
418 LIB32FLAGS+= --sysroot=${WORLDTMP}
421 # Yes, the flags are redundant.
422 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
423 _SHLIBDIRPREFIX=${LIB32TMP} \
424 _LDSCRIPTROOT=${LIB32TMP} \
425 VERSION="${VERSION}" \
426 INSTALL="sh ${.CURDIR}/tools/install.sh" \
429 SHLIBDIR=/usr/lib32 \
430 LIBPRIVATEDIR=/usr/lib32/private \
431 DTRACE="${DTRACE} -32"
432 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
433 CXX="${XCXX} ${LIB32FLAGS}" \
434 DESTDIR=${LIB32TMP} \
442 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
444 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
445 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
448 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
449 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
450 ${IMAKE_INSTALL} ${IMAKE_MTREE}
451 .if empty(.MAKEFLAGS:M-n)
452 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
453 LD_LIBRARY_PATH=${INSTALLTMP} \
454 PATH_LOCALE=${INSTALLTMP}/locale
455 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
457 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
459 .if defined(DB_FROM_SRC)
460 INSTALLFLAGS+= -N ${.CURDIR}/etc
461 MTREEFLAGS+= -N ${.CURDIR}/etc
463 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
464 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
466 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
467 IMAKE+= -DNO_ROOT METALOG=${METALOG}
468 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
471 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
472 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
473 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
477 KMAKEENV= ${WMAKEENV}
478 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
483 # Attempt to rebuild the entire system, with reasonable chance of
484 # success, regardless of how old your existing system is.
487 .if ${.CURDIR:C/[^,]//g} != ""
488 # The m4 build of sendmail files doesn't like it if ',' is used
489 # anywhere in the path of it's files.
491 @echo "*** Error: path to source tree contains a comma ','"
496 @echo "--------------------------------------------------------------"
497 @echo ">>> Rebuilding the temporary build tree"
498 @echo "--------------------------------------------------------------"
499 .if !defined(NO_CLEAN)
501 .if defined(LIB32TMP)
505 rm -rf ${WORLDTMP}/legacy/usr/include
506 # XXX - These three can depend on any header file.
507 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
508 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
509 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
512 lib usr legacy/bin legacy/usr
513 mkdir -p ${WORLDTMP}/${_dir}
515 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
516 -p ${WORLDTMP}/legacy/usr >/dev/null
517 .if ${MK_GROFF} != "no"
518 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
519 -p ${WORLDTMP}/legacy/usr >/dev/null
521 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
522 -p ${WORLDTMP}/usr >/dev/null
523 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
524 -p ${WORLDTMP}/usr/include >/dev/null
525 ln -sf ${.CURDIR}/sys ${WORLDTMP}
526 .if ${MK_DEBUG_FILES} != "no"
527 # We could instead disable debug files for these build stages
528 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
529 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
530 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
531 -p ${WORLDTMP}/usr/lib >/dev/null
533 .if ${MK_TESTS} != "no"
534 mkdir -p ${WORLDTMP}${TESTSBASE}
535 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
536 -p ${WORLDTMP}${TESTSBASE} >/dev/null
538 .for _mtree in ${LOCAL_MTREE}
539 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
543 @echo "--------------------------------------------------------------"
544 @echo ">>> stage 1.1: legacy release compatibility shims"
545 @echo "--------------------------------------------------------------"
546 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
549 @echo "--------------------------------------------------------------"
550 @echo ">>> stage 1.2: bootstrap tools"
551 @echo "--------------------------------------------------------------"
552 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
554 .if !defined(NO_CLEAN)
556 @echo "--------------------------------------------------------------"
557 @echo ">>> stage 2.1: cleaning up the object tree"
558 @echo "--------------------------------------------------------------"
559 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
560 .if defined(LIB32TMP)
561 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
566 @echo "--------------------------------------------------------------"
567 @echo ">>> stage 2.2: rebuilding the object tree"
568 @echo "--------------------------------------------------------------"
569 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
572 @echo "--------------------------------------------------------------"
573 @echo ">>> stage 2.3: build tools"
574 @echo "--------------------------------------------------------------"
575 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
578 @echo "--------------------------------------------------------------"
579 @echo ">>> stage 3: cross tools"
580 @echo "--------------------------------------------------------------"
581 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
582 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
585 @echo "--------------------------------------------------------------"
586 @echo ">>> stage 4.1: building includes"
587 @echo "--------------------------------------------------------------"
588 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
591 @echo "--------------------------------------------------------------"
592 @echo ">>> stage 4.2: building libraries"
593 @echo "--------------------------------------------------------------"
594 ${_+_}cd ${.CURDIR}; \
595 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
596 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
599 @echo "--------------------------------------------------------------"
600 @echo ">>> stage 4.3: make dependencies"
601 @echo "--------------------------------------------------------------"
602 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
605 @echo "--------------------------------------------------------------"
606 @echo ">>> stage 4.4: building everything"
607 @echo "--------------------------------------------------------------"
608 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
609 .if defined(LIB32TMP)
612 @echo "--------------------------------------------------------------"
613 @echo ">>> stage 5.1: building 32 bit shim libraries"
614 @echo "--------------------------------------------------------------"
615 mkdir -p ${LIB32TMP}/usr/include
616 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
617 -p ${LIB32TMP}/usr >/dev/null
618 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
619 -p ${LIB32TMP}/usr/include >/dev/null
620 .if ${MK_DEBUG_FILES} != "no"
621 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
622 -p ${LIB32TMP}/usr/lib >/dev/null
625 ln -sf ${.CURDIR}/sys ${WORLDTMP}
626 .for _t in obj includes
627 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
628 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
629 .if ${MK_CDDL} != "no"
630 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
632 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
633 .if ${MK_CRYPT} != "no"
634 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
636 .if ${MK_KERBEROS} != "no"
637 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
640 .for _dir in usr.bin/lex/lib
641 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
643 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
644 cd ${.CURDIR}/${_dir}; \
645 WORLDTMP=${WORLDTMP} \
646 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
647 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
648 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
652 ${LIB32WMAKE} -f Makefile.inc1 libraries
653 .for _t in obj depend all
654 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
655 DIRPRFX=libexec/rtld-elf/ ${_t}
656 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
657 DIRPRFX=usr.bin/ldd ${_t}
660 distribute32 install32:
661 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
662 .if ${MK_CDDL} != "no"
663 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
665 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
666 .if ${MK_CRYPT} != "no"
667 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
669 .if ${MK_KERBEROS} != "no"
670 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
672 cd ${.CURDIR}/libexec/rtld-elf; \
673 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
674 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
678 .if !defined(SUBDIR_OVERRIDE)
679 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
681 WMAKE_TGTS+= _cleanobj _obj _build-tools
682 .if !defined(SUBDIR_OVERRIDE)
683 WMAKE_TGTS+= _cross-tools
685 WMAKE_TGTS+= _includes _libraries _depend everything
686 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
690 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
691 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
694 @echo "--------------------------------------------------------------"
695 @echo ">>> World build started on `LC_ALL=C date`"
696 @echo "--------------------------------------------------------------"
700 @echo "--------------------------------------------------------------"
701 @echo ">>> World build completed on `LC_ALL=C date`"
702 @echo "--------------------------------------------------------------"
705 # We need to have this as a target because the indirection between Makefile
706 # and Makefile.inc1 causes the correct PATH to be used, rather than a
707 # modification of the current environment's PATH. In addition, we need
708 # to quote multiword values.
713 .if ${.TARGETS:Mbuildenv}
714 .if ${.MAKEFLAGS:M-j}
715 .error The buildenv target is incompatible with -j
719 @echo Entering world for ${TARGET_ARCH}:${TARGET}
720 @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
722 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
723 toolchain: ${TOOLCHAIN_TGTS}
724 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
729 # Checks to be sure system is ready for installworld/installkernel.
731 installcheck: _installcheck_world _installcheck_kernel
733 _installcheck_kernel:
736 # Require DESTDIR to be set if installing for a different architecture or
737 # using the user/group database in the source tree.
739 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
741 .if !make(distributeworld)
742 _installcheck_world: __installcheck_DESTDIR
743 _installcheck_kernel: __installcheck_DESTDIR
744 __installcheck_DESTDIR:
745 .if !defined(DESTDIR) || empty(DESTDIR)
746 @echo "ERROR: Please set DESTDIR!"; \
752 .if !defined(DB_FROM_SRC)
754 # Check for missing UIDs/GIDs.
756 CHECK_UIDS= auditdistd
758 .if ${MK_SENDMAIL} != "no"
764 CHECK_GIDS+= proxy authpf
766 .if ${MK_UNBOUND} != "no"
770 _installcheck_world: __installcheck_UGID
772 .for uid in ${CHECK_UIDS}
773 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
774 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
778 .for gid in ${CHECK_GIDS}
779 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
780 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
787 # Required install tools to be saved in a scratch dir for safety.
789 .if ${MK_ZONEINFO} != "no"
790 _zoneinfo= zic tzsetup
793 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
794 date echo egrep find grep id install ${_install-info} \
795 ln lockf make mkdir mtree mv pwd_mkdb \
796 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
799 # Needed for share/man
800 .if ${MK_MAN} != "no"
807 # Distributes everything compiled by a `buildworld'.
811 # Installs everything compiled by a 'buildworld'.
814 # Non-base distributions produced by the base system
815 EXTRA_DISTRIBUTIONS= doc
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,,:S,tests,,}
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 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
870 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
871 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
874 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
875 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
876 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
877 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
878 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
879 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
882 -mkdir ${DESTDIR}/${DISTDIR}/base
883 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
884 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
885 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
886 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
888 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
889 ${IMAKEENV} rm -rf ${INSTALLTMP}
890 .if make(distributeworld)
891 .for dist in ${EXTRA_DISTRIBUTIONS}
892 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
895 .for dist in base ${EXTRA_DISTRIBUTIONS}
896 @# For each file that exists in this dist, print the corresponding
897 @# line from the METALOG. This relies on the fact that
898 @# a line containing only the filename will sort immediatly before
899 @# the relevant mtree line.
900 cd ${DESTDIR}/${DISTDIR}; \
901 find ./${dist} | sort -u ${METALOG} - | \
902 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
903 ${DESTDIR}/${DISTDIR}/${dist}.meta
905 .for dist in ${DEBUG_DISTRIBUTIONS}
906 @# For each file that exists in this dist, print the corresponding
907 @# line from the METALOG. This relies on the fact that
908 @# a line containing only the filename will sort immediatly before
909 @# the relevant mtree line.
910 cd ${DESTDIR}/${DISTDIR}; \
911 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
912 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
913 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
919 .for dist in base ${EXTRA_DISTRIBUTIONS}
921 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
922 tar cvf - --exclude usr/lib/debug \
923 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
924 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz
926 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
927 tar cvf - --exclude usr/lib/debug . | \
928 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}.txz
932 .for dist in ${DEBUG_DISTRIBUTIONS}
933 . if defined(NO_ROOT)
934 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
935 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
936 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz
938 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
939 tar cvLf - usr/lib/debug | \
940 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/${dist}-dbg.txz
947 # If you have a build server, you can NFS mount the source and obj directories
948 # and do a 'make reinstall' on the *client* to install new binaries from the
949 # most recent server build.
952 @echo "--------------------------------------------------------------"
953 @echo ">>> Making hierarchy"
954 @echo "--------------------------------------------------------------"
955 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
956 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
958 @echo "--------------------------------------------------------------"
959 @echo ">>> Installing everything"
960 @echo "--------------------------------------------------------------"
961 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
962 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
963 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
967 @echo "--------------------------------------------------------------"
968 @echo ">>> Distributing everything"
969 @echo "--------------------------------------------------------------"
970 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
971 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
972 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
976 distrib-dirs distribution: .MAKE
977 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
978 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
981 # buildkernel and installkernel
983 # Which kernels to build and/or install is specified by setting
984 # KERNCONF. If not defined a GENERIC kernel is built/installed.
985 # Only the existing (depending TARGET) config files are used
986 # for building kernels and only the first of these is designated
987 # as the one being installed.
989 # Note that we have to use TARGET instead of TARGET_ARCH when
990 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
991 # be set to cross-build, we have to make sure TARGET is set
994 .if defined(KERNFAST)
999 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1000 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1001 KERNCONF=${KERNFAST}
1004 .if ${TARGET_ARCH} == "powerpc64"
1005 KERNCONF?= GENERIC64
1009 INSTKERNNAME?= kernel
1011 KERNSRCDIR?= ${.CURDIR}/sys
1012 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1013 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1014 KERNCONFDIR?= ${KRNLCONFDIR}
1018 .for _kernel in ${KERNCONF}
1019 .if exists(${KERNCONFDIR}/${_kernel})
1020 BUILDKERNELS+= ${_kernel}
1021 .if empty(INSTALLKERNEL)
1022 INSTALLKERNEL= ${_kernel}
1027 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
1032 # Builds all kernels defined by BUILDKERNELS.
1035 .if empty(BUILDKERNELS)
1036 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1040 .for _kernel in ${BUILDKERNELS}
1041 @echo "--------------------------------------------------------------"
1042 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1043 @echo "--------------------------------------------------------------"
1044 @echo "===> ${_kernel}"
1045 mkdir -p ${KRNLOBJDIR}
1046 .if !defined(NO_KERNELCONFIG)
1048 @echo "--------------------------------------------------------------"
1049 @echo ">>> stage 1: configuring the kernel"
1050 @echo "--------------------------------------------------------------"
1051 cd ${KRNLCONFDIR}; \
1053 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1054 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1056 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1058 @echo "--------------------------------------------------------------"
1059 @echo ">>> stage 2.1: cleaning up the object tree"
1060 @echo "--------------------------------------------------------------"
1061 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1063 .if !defined(NO_KERNELOBJ)
1065 @echo "--------------------------------------------------------------"
1066 @echo ">>> stage 2.2: rebuilding the object tree"
1067 @echo "--------------------------------------------------------------"
1068 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1071 @echo "--------------------------------------------------------------"
1072 @echo ">>> stage 2.3: build tools"
1073 @echo "--------------------------------------------------------------"
1074 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1075 .if !defined(NO_KERNELDEPEND)
1077 @echo "--------------------------------------------------------------"
1078 @echo ">>> stage 3.1: making dependencies"
1079 @echo "--------------------------------------------------------------"
1080 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1083 @echo "--------------------------------------------------------------"
1084 @echo ">>> stage 3.2: building everything"
1085 @echo "--------------------------------------------------------------"
1086 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1087 @echo "--------------------------------------------------------------"
1088 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1089 @echo "--------------------------------------------------------------"
1093 # installkernel, etc.
1095 # Install the kernel defined by INSTALLKERNEL
1097 installkernel installkernel.debug \
1098 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1099 .if empty(INSTALLKERNEL)
1100 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1103 @echo "--------------------------------------------------------------"
1104 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1105 @echo "--------------------------------------------------------------"
1106 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1107 ${CROSSENV} PATH=${TMPPATH} \
1108 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1110 distributekernel distributekernel.debug:
1111 .if empty(INSTALLKERNEL)
1112 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1115 mkdir -p ${DESTDIR}/${DISTDIR}
1116 .if defined(NO_ROOT)
1117 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1119 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1120 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1121 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1122 DESTDIR=${INSTALL_DDIR}/kernel \
1123 ${.TARGET:S/distributekernel/install/}
1124 .if defined(NO_ROOT)
1125 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1126 ${DESTDIR}/${DISTDIR}/kernel.meta
1128 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1129 .if defined(NO_ROOT)
1130 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1132 cd ${KRNLOBJDIR}/${_kernel}; \
1133 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1134 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1135 KERNEL=${INSTKERNNAME}.${_kernel} \
1136 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1137 ${.TARGET:S/distributekernel/install/}
1138 .if defined(NO_ROOT)
1139 sed -e 's|^./kernel|.|' \
1140 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1141 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1146 .if defined(NO_ROOT)
1147 cd ${DESTDIR}/${DISTDIR}/kernel; \
1148 tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \
1149 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
1150 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1151 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1152 tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1153 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
1156 cd ${DESTDIR}/${DISTDIR}/kernel; \
1158 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
1159 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1160 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1162 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
1169 # Build the API documentation with doxygen
1172 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1173 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1176 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1181 # Update the source tree(s), by running svn/svnup to update to the
1185 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1186 @echo "--------------------------------------------------------------"
1187 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1188 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1189 @echo "--------------------------------------------------------------"
1192 .if defined(SVN_UPDATE)
1193 @echo "--------------------------------------------------------------"
1194 @echo ">>> Updating ${.CURDIR} using Subversion"
1195 @echo "--------------------------------------------------------------"
1196 @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1200 # ------------------------------------------------------------------------
1202 # From here onwards are utility targets used by the 'make world' and
1203 # related targets. If your 'world' breaks, you may like to try to fix
1204 # the problem and manually run the following targets to attempt to
1205 # complete the build. Beware, this is *not* guaranteed to work, you
1206 # need to have a pretty good grip on the current state of the system
1207 # to attempt to manually finish it. If in doubt, 'make world' again.
1211 # legacy: Build compatibility shims for the next three targets
1214 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1215 @echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
1218 .for _tool in tools/build
1219 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1220 cd ${.CURDIR}/${_tool} && \
1221 ${MAKE} DIRPRFX=${_tool}/ obj && \
1222 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1223 ${MAKE} DIRPRFX=${_tool}/ depend && \
1224 ${MAKE} DIRPRFX=${_tool}/ all && \
1225 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1229 # bootstrap-tools: Build tools needed for compatibility
1231 _bt= _bootstrap-tools
1233 .if ${MK_GAMES} != "no"
1234 _strfile= games/fortune/strfile
1237 .if ${MK_CXX} != "no"
1238 _gperf= gnu/usr.bin/gperf
1241 .if ${MK_GROFF} != "no"
1242 _groff= gnu/usr.bin/groff
1245 .if ${MK_VT} != "no"
1246 _vtfontcvt= usr.bin/vtfontcvt
1249 .if ${BOOTSTRAPPING} < 900002
1253 .if ${BOOTSTRAPPING} < 1000002
1257 ${_bt}-usr.bin/m4: ${_bt}-lib/libohash
1260 .if ${BOOTSTRAPPING} < 1000014
1261 _crunch= usr.sbin/crunch
1264 .if ${BOOTSTRAPPING} < 1000026
1265 _nmtree= lib/libnetbsd \
1268 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1271 .if ${BOOTSTRAPPING} < 1000027
1275 .if ${BOOTSTRAPPING} < 1000033
1279 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1283 .if ${BOOTSTRAPPING} < 1001506
1287 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1290 .if ${MK_BSNMP} != "no"
1291 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1294 # We need to build tblgen when we're building clang either as
1295 # the bootstrap compiler, or as the part of the normal build.
1296 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1298 lib/clang/libllvmsupport \
1299 lib/clang/libllvmtablegen \
1300 usr.bin/clang/tblgen \
1301 usr.bin/clang/clang-tblgen
1303 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1304 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1307 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1308 # dtrace tools are required for older bootstrap env and cross-build
1310 .if ${BOOTSTRAPPING} < 1100006 || (${MACHINE} != ${TARGET} || \
1311 ${MACHINE_ARCH} != ${TARGET_ARCH})
1312 _elftoolchain_libs= lib/libelf lib/libdwarf
1313 .if ${MK_CDDL} != "no"
1314 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \
1315 cddl/usr.bin/ctfmerge
1317 ${_bt}-cddl/usr.bin/ctfconvert: ${_bt}-lib/libelf ${_bt}-lib/libdwarf ${_bt}-cddl/lib/libctf
1318 ${_bt}-cddl/usr.bin/ctfmerge: ${_bt}-lib/libelf ${_bt}-lib/libdwarf ${_bt}-cddl/lib/libctf
1322 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1325 .if ${MK_GPL_DTC} != "no"
1326 _dtc= gnu/usr.bin/dtc
1329 .if ${MK_KERBEROS} != "no"
1330 _kerberos5_bootstrap_tools= \
1331 kerberos5/tools/make-roken \
1332 kerberos5/lib/libroken \
1333 kerberos5/lib/libvers \
1334 kerberos5/tools/asn1_compile \
1335 kerberos5/tools/slc \
1338 ${_bt}-kerberos5/tools/slc: ${_bt}-kerberos5/lib/libroken
1339 ${_bt}-kerberos5/tools/asn1_compile: ${_bt}-kerberos5/lib/libroken
1342 bootstrap-tools: .PHONY
1344 # Please document (add comment) why something is in 'bootstrap-tools'.
1345 # Try to bound the building of the bootstrap-tool to just the
1346 # FreeBSD versions that need the tool built at this stage of the build.
1349 ${_kerberos5_bootstrap_tools} \
1350 ${_elftoolchain_libs} \
1359 usr.bin/makewhatis \
1372 ${_bt}-${_tool}: .PHONY .MAKE
1373 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1374 cd ${.CURDIR}/${_tool} && \
1375 ${MAKE} DIRPRFX=${_tool}/ obj && \
1376 ${MAKE} DIRPRFX=${_tool}/ depend && \
1377 ${MAKE} DIRPRFX=${_tool}/ all && \
1378 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1380 bootstrap-tools: ${_bt}-${_tool}
1384 # build-tools: Build special purpose build tools
1386 .if !defined(NO_SHARE)
1387 _share= share/syscons/scrnmaps
1390 .if ${MK_GCC} != "no"
1391 _gcc_tools= gnu/usr.bin/cc/cc_tools
1394 .if ${MK_RESCUE} != "no"
1395 _rescue= rescue/rescue
1403 ${LOCAL_TOOL_DIRS} \
1404 lib/ncurses/ncurses \
1405 lib/ncurses/ncursesw \
1409 usr.bin/mkesdb_static \
1410 usr.bin/mkcsmapper_static \
1412 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1413 cd ${.CURDIR}/${_tool} && \
1414 ${MAKE} DIRPRFX=${_tool}/ obj && \
1415 ${MAKE} DIRPRFX=${_tool}/ build-tools
1419 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1420 cd ${.CURDIR}/${_tool} && \
1421 ${MAKE} DIRPRFX=${_tool}/ obj && \
1422 ${MAKE} DIRPRFX=${_tool}/ depend && \
1423 ${MAKE} DIRPRFX=${_tool}/ all
1427 # kernel-tools: Build kernel-building tools
1430 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1431 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1432 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1435 # cross-tools: Build cross-building tools
1437 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1438 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1439 _btxld= usr.sbin/btxld
1442 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1443 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1444 _crunchide= usr.sbin/crunch/crunchide
1446 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1447 _kgzip= usr.sbin/kgzip
1451 # If we're given an XAS, don't build binutils.
1452 .if ${XAS:M/*} == ""
1453 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1454 _binutils= gnu/usr.bin/binutils
1456 .if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
1457 _elftctools= lib/libelftc \
1462 # These are not required by the build, but can be useful for developers who
1463 # cross-build on a FreeBSD 10 host:
1464 _elftctools+= usr.bin/addr2line
1468 # If an full path to an external cross compiler is given, don't build
1470 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1471 .if ${MK_CLANG_BOOTSTRAP} != "no"
1472 _clang= usr.bin/clang
1473 _clang_libs= lib/clang
1475 .if ${MK_GCC_BOOTSTRAP} != "no"
1487 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1492 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1493 cd ${.CURDIR}/${_tool} && \
1494 ${MAKE} DIRPRFX=${_tool}/ obj && \
1495 ${MAKE} DIRPRFX=${_tool}/ depend && \
1496 ${MAKE} DIRPRFX=${_tool}/ all && \
1497 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1500 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1501 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1502 VERSION="${VERSION}"
1503 NXBMAKE= ${NXBENV} ${MAKE} \
1504 TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
1505 CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
1506 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1507 MK_GDB=no MK_TESTS=no \
1509 MK_HTML=no NO_LINT=yes MK_MAN=no \
1510 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1511 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1512 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1515 native-xtools: .MAKE
1516 mkdir -p ${OBJTREE}/nxb-bin/bin
1517 mkdir -p ${OBJTREE}/nxb-bin/sbin
1518 mkdir -p ${OBJTREE}/nxb-bin/usr
1519 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1520 -p ${OBJTREE}/nxb-bin/usr >/dev/null
1521 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1522 -p ${OBJTREE}/nxb-bin/usr/include >/dev/null
1582 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1583 cd ${.CURDIR}/${_tool} && \
1584 ${NXBMAKE} DIRPRFX=${_tool}/ obj && \
1585 ${NXBMAKE} DIRPRFX=${_tool}/ depend && \
1586 ${NXBMAKE} DIRPRFX=${_tool}/ all && \
1587 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${OBJTREE}/nxb-bin install
1591 # hierarchy - ensure that all the needed directories are present
1593 hierarchy hier: .MAKE
1594 cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1597 # libraries - build all libraries, and install them under ${DESTDIR}.
1599 # The list of libraries with dependents (${_prebuild_libs}) and their
1600 # interdependencies (__L) are built automatically by the
1601 # ${.CURDIR}/tools/make_libdeps.sh script.
1605 ${MAKE} -f Makefile.inc1 _prereq_libs && \
1606 ${MAKE} -f Makefile.inc1 _startup_libs && \
1607 ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1608 ${MAKE} -f Makefile.inc1 _generic_libs
1611 # static libgcc.a prerequisite for shared libc
1613 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1615 # These dependencies are not automatically generated:
1617 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1618 # all shared libraries for ELF.
1620 _startup_libs= gnu/lib/csu
1621 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1622 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1623 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1624 _startup_libs+= lib/csu/${MACHINE_ARCH}
1626 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1628 _startup_libs+= gnu/lib/libgcc
1629 _startup_libs+= lib/libcompiler_rt
1630 _startup_libs+= lib/libc
1631 _startup_libs+= lib/libc_nonshared
1632 .if ${MK_LIBCPLUSPLUS} != "no"
1633 _startup_libs+= lib/libcxxrt
1636 gnu/lib/libgcc__L: lib/libc__L
1637 gnu/lib/libgcc__L: lib/libc_nonshared__L
1638 .if ${MK_LIBCPLUSPLUS} != "no"
1639 lib/libcxxrt__L: gnu/lib/libgcc__L
1642 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1643 ${_kerberos5_lib_libhdb} \
1644 ${_kerberos5_lib_libheimbase} \
1645 ${_kerberos5_lib_libheimntlm} \
1646 ${_kerberos5_lib_libheimsqlite} \
1647 ${_kerberos5_lib_libheimipcc} \
1648 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1649 ${_kerberos5_lib_libroken} \
1650 ${_kerberos5_lib_libwind} \
1651 lib/libbz2 ${_libcom_err} lib/libcrypt \
1652 lib/libelf lib/libexpat \
1655 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1656 ${_lib_libcapsicum} \
1657 lib/ncurses/ncurses lib/ncurses/ncursesw \
1658 lib/libopie lib/libpam ${_lib_libthr} \
1659 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1661 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1662 ${_cddl_lib_libuutil} \
1663 ${_cddl_lib_libavl} \
1664 ${_cddl_lib_libzfs_core} \
1665 ${_cddl_lib_libctf} \
1666 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1667 ${_secure_lib_libcrypto} ${_lib_libldns} \
1668 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1670 .if ${MK_GNUCXX} != "no"
1671 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1672 gnu/lib/libstdc++__L: lib/msun__L
1673 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1676 lib/libgeom__L: lib/libexpat__L
1678 .if ${MK_LIBTHR} != "no"
1679 _lib_libthr= lib/libthr
1682 .if ${MK_RADIUS_SUPPORT} != "no"
1683 _lib_libradius= lib/libradius
1686 .if ${MK_OFED} != "no"
1687 _ofed_lib= contrib/ofed/usr.lib/
1690 .if ${MK_CASPER} != "no"
1691 _lib_libcapsicum=lib/libcapsicum
1694 lib/libcapsicum__L: lib/libnv__L
1695 lib/libpjdlog__L: lib/libutil__L
1696 lib/liblzma__L: lib/libthr__L
1698 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1699 .for _DIR in ${LOCAL_LIB_DIRS}
1700 .if exists(${.CURDIR}/${_DIR}/Makefile)
1701 _generic_libs+= ${_DIR}
1705 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1707 .if ${MK_CDDL} != "no"
1708 _cddl_lib_libumem= cddl/lib/libumem
1709 _cddl_lib_libnvpair= cddl/lib/libnvpair
1710 _cddl_lib_libavl= cddl/lib/libavl
1711 _cddl_lib_libuutil= cddl/lib/libuutil
1712 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1713 _cddl_lib_libctf= cddl/lib/libctf
1715 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1716 cddl/lib/libzfs__L: lib/libgeom__L
1717 cddl/lib/libctf__L: lib/libz__L
1720 .if ${MK_CRYPT} != "no"
1721 .if ${MK_OPENSSL} != "no"
1722 _secure_lib_libcrypto= secure/lib/libcrypto
1723 _secure_lib_libssl= secure/lib/libssl
1724 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1725 .if ${MK_LDNS} != "no"
1726 _lib_libldns= lib/libldns
1727 lib/libldns__L: secure/lib/libcrypto__L
1729 .if ${MK_OPENSSH} != "no"
1730 _secure_lib_libssh= secure/lib/libssh
1731 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1732 .if ${MK_LDNS} != "no"
1733 secure/lib/libssh__L: lib/libldns__L
1735 .if ${MK_KERBEROS_SUPPORT} != "no"
1736 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1737 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1738 lib/libmd__L kerberos5/lib/libroken__L
1742 _secure_lib= secure/lib
1745 .if ${MK_KERBEROS} != "no"
1746 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1747 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1748 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1749 kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
1750 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1751 kerberos5/lib/libroken__L lib/libcom_err__L
1752 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1753 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1754 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1755 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1756 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1757 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1758 kerberos5/lib/libroken__L: lib/libcrypt__L
1759 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1760 kerberos5/lib/libheimbase__L: lib/libthr__L
1761 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1762 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1765 .if ${MK_GSSAPI} != "no"
1766 _lib_libgssapi= lib/libgssapi
1769 .if ${MK_KERBEROS} != "no"
1770 _kerberos5_lib= kerberos5/lib
1771 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1772 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1773 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1774 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1775 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1776 _kerberos5_lib_libroken= kerberos5/lib/libroken
1777 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1778 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1779 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1780 _kerberos5_lib_libwind= kerberos5/lib/libwind
1781 _libcom_err= lib/libcom_err
1784 .if ${MK_NIS} != "no"
1785 _lib_libypclnt= lib/libypclnt
1788 .if ${MK_OPENSSL} == "no"
1789 lib/libradius__L: lib/libmd__L
1792 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
1794 .for _lib in ${_prereq_libs}
1795 ${_lib}__PL: .PHONY .MAKE
1796 .if exists(${.CURDIR}/${_lib})
1797 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1798 cd ${.CURDIR}/${_lib} && \
1799 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1800 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1801 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1802 DIRPRFX=${_lib}/ all && \
1803 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1804 DIRPRFX=${_lib}/ install
1808 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1809 ${_lib}__L: .PHONY .MAKE
1810 .if exists(${.CURDIR}/${_lib})
1811 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1812 cd ${.CURDIR}/${_lib} && \
1813 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj && \
1814 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend && \
1815 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all && \
1816 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1820 # libpam is special: we need to build static PAM modules before
1821 # static PAM library, and dynamic PAM library before dynamic PAM
1823 lib/libpam__L: .PHONY .MAKE
1824 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1825 cd ${.CURDIR}/lib/libpam && \
1826 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj && \
1827 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend && \
1828 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1829 -D_NO_LIBPAM_SO_YET all && \
1830 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
1831 -D_NO_LIBPAM_SO_YET install
1833 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1834 _startup_libs: ${_startup_libs:S/$/__L/}
1835 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1836 _generic_libs: ${_generic_libs:S/$/__L/}
1838 .for __target in all clean cleandepend cleandir depend includes obj
1839 .for entry in ${SUBDIR}
1840 ${entry}.${__target}__D: .PHONY .MAKE
1841 ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1842 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1843 edir=${entry}.${MACHINE_ARCH}; \
1844 cd ${.CURDIR}/$${edir}; \
1846 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1848 cd ${.CURDIR}/$${edir}; \
1850 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1852 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1855 .include <bsd.subdir.mk>
1857 .if make(check-old) || make(check-old-dirs) || \
1858 make(check-old-files) || make(check-old-libs) || \
1859 make(delete-old) || make(delete-old-dirs) || \
1860 make(delete-old-files) || make(delete-old-libs)
1863 # check for / delete old files section
1866 .include "ObsoleteFiles.inc"
1868 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1869 else you can not start such an application. Consult UPDATING for more \
1870 information regarding how to cope with the removal/revision bump of a \
1873 .if !defined(BATCH_DELETE_OLD_FILES)
1880 @echo ">>> Removing old files (only deletes safe to delete libs)"
1881 # Ask for every old file if the user really wants to remove it.
1882 # It's annoying, but better safe than sorry.
1883 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1884 # argument list will get too long. Using .for/.endfor make "loops" will make
1885 # the Makefile parser segfault.
1888 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1889 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1890 while read file; do \
1891 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1892 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1893 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1896 # Remove catpages without corresponding manpages.
1898 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1899 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1900 while read catpage; do \
1902 if [ ! -e "$${manpage}" ]; then \
1903 rm ${RM_I} $${catpage} <&3; \
1906 @echo ">>> Old files removed"
1909 @echo ">>> Checking for old files"
1911 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1912 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1913 while read file; do \
1914 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1915 echo "${DESTDIR}/$${file}"; \
1918 # Check for catpages without corresponding manpages.
1919 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1920 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1921 while read catpage; do \
1923 if [ ! -e "$${manpage}" ]; then \
1929 @echo ">>> Removing old libraries"
1930 @echo "${OLD_LIBS_MESSAGE}" | fmt
1933 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1934 -V OLD_LIBS | xargs -n1 | \
1935 while read file; do \
1936 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1937 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1938 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1940 for ext in debug symbols; do \
1941 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1942 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1943 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1948 @echo ">>> Old libraries removed"
1951 @echo ">>> Checking for old libraries"
1953 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1954 -V OLD_LIBS | xargs -n1 | \
1955 while read file; do \
1956 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1957 echo "${DESTDIR}/$${file}"; \
1959 for ext in debug symbols; do \
1960 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1961 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1967 @echo ">>> Removing old directories"
1969 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1970 -V OLD_DIRS | xargs -n1 | sort -r | \
1971 while read dir; do \
1972 if [ -d "${DESTDIR}/$${dir}" ]; then \
1973 rmdir -v "${DESTDIR}/$${dir}" || true; \
1974 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1975 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1978 @echo ">>> Old directories removed"
1981 @echo ">>> Checking for old directories"
1983 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1984 -V OLD_DIRS | xargs -n1 | \
1985 while read dir; do \
1986 if [ -d "${DESTDIR}/$${dir}" ]; then \
1987 echo "${DESTDIR}/$${dir}"; \
1988 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1989 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1993 delete-old: delete-old-files delete-old-dirs
1994 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1996 check-old: check-old-files check-old-libs check-old-dirs
1997 @echo "To remove old files and directories run '${MAKE} delete-old'."
1998 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2003 # showconfig - show build configuration.
2006 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2007 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2009 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2010 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2012 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2013 .if exists(${KERNCONFDIR}/${KERNCONF})
2014 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2015 '${KERNCONFDIR}/${KERNCONF}' ; echo
2021 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2022 DTBOUTPUTPATH= ${.CURDIR}
2026 # Build 'standalone' Device Tree Blob
2029 @PATH=${TMPPATH} MACHINE=${TARGET} \
2030 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2031 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2035 .if defined(TARGET) && defined(TARGET_ARCH)
2037 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2038 XDEV_CPUTYPE?=${CPUTYPE}
2040 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2043 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2044 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2045 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2046 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2047 CPUTYPE=${XDEV_CPUTYPE}
2049 XDDIR=${TARGET_ARCH}-freebsd
2052 .error XDTP variable should be an absolute path
2055 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2056 INSTALL="sh ${.CURDIR}/tools/install.sh"
2058 _SHLIBDIRPREFIX=${XDDESTDIR} \
2059 TOOLS_PREFIX=${XDTP}
2060 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2061 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2062 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2063 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2064 CPP="${CPP} ${CD2CFLAGS}" \
2065 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2067 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2068 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2069 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2070 XDDESTDIR=${DESTDIR}/${XDTP}
2072 OSREL!= uname -r | sed -e 's/[-(].*//'
2075 .ORDER: xdev-build xdev-install xdev-links
2076 xdev: xdev-build xdev-install
2078 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2079 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2082 mkdir -p ${CDTMP}/usr
2083 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2084 -p ${CDTMP}/usr >/dev/null
2086 _xb-bootstrap-tools:
2090 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2091 cd ${.CURDIR}/${_tool} && \
2092 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2093 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2094 ${CDMAKE} DIRPRFX=${_tool}/ all && \
2095 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2099 ${_+_}@cd ${.CURDIR}; \
2100 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2110 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2111 cd ${.CURDIR}/${_tool} && \
2112 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
2113 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
2114 ${CDMAKE} DIRPRFX=${_tool}/ all
2118 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2119 mkdir -p ${XDDESTDIR}
2120 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2121 -p ${XDDESTDIR} >/dev/null
2122 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2123 -p ${XDDESTDIR}/usr >/dev/null
2124 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2125 -p ${XDDESTDIR}/usr/include >/dev/null
2126 .if ${MK_TESTS} != "no"
2127 mkdir -p ${XDDESTDIR}${TESTSBASE}
2128 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2129 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2132 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2133 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2136 @echo "_xi-cross-tools"
2144 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2145 cd ${.CURDIR}/${_tool}; \
2146 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2150 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
2151 DESTDIR=${XDDESTDIR}
2154 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2155 DESTDIR=${XDDESTDIR}
2158 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2159 mkdir -p ../../../../usr/bin; \
2161 ln -sf ../../${XDTP}/usr/bin/$$i \
2162 ../../../../usr/bin/${XDDIR}-$$i; \
2163 ln -sf ../../${XDTP}/usr/bin/$$i \
2164 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2167 xdev xdev-build xdev-install xdev-links:
2168 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"