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 # -DNO_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_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # METALOG="path to metadata log" to write permission and ownership
26 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
27 # TARGET="machine" to crossbuild world for a different machine type
28 # TARGET_ARCH= may be required when a TARGET supports multiple endians
29 # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
30 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
31 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
34 # The intended user-driven targets are:
35 # buildworld - rebuild *everything*, including glue to help do upgrades
36 # installworld- install everything built by "buildworld"
37 # doxygen - build API documentation of the kernel
38 # update - convenient way to update your source tree (eg: svn/svnup)
40 # Standard targets (not defined here) are documented in the makefiles in
41 # /usr/share/mk. These include:
42 # obj depend all install clean cleandepend cleanobj
44 .if !defined(TARGET) || !defined(TARGET_ARCH)
45 .error "Both TARGET and TARGET_ARCH must be defined."
49 .include <bsd.arch.inc.mk>
50 .include <bsd.compiler.mk>
52 # We must do share/info early so that installation of info `dir'
53 # entries works correctly. Do it first since it is less likely to
54 # grow dependencies on include and lib than vice versa.
56 # We must do lib/ and libexec/ before bin/, because if installworld
57 # installs a new /bin/sh, the 'make' command will *immediately*
58 # use that new version. And the new (dynamically-linked) /bin/sh
59 # will expect to find appropriate libraries in /lib and /libexec.
61 .if defined(SUBDIR_OVERRIDE)
62 SUBDIR= ${SUBDIR_OVERRIDE}
64 SUBDIR= share/info lib libexec
66 .if ${MK_GAMES} != "no"
69 .if ${MK_CDDL} != "no"
73 .if ${MK_KERBEROS} != "no"
76 .if ${MK_RESCUE} != "no"
80 .if ${MK_CRYPT} != "no"
83 .if !defined(NO_SHARE)
86 SUBDIR+=sys usr.bin usr.sbin
87 .if ${MK_OFED} != "no"
91 # We must do etc/ last for install/distribute to work.
95 # These are last, since it is nice to at least get the base system
96 # rebuilt before you do them.
97 .for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS}
98 .if exists(${.CURDIR}/${_DIR}/Makefile)
107 .if defined(NO_CLEANDIR)
108 CLEANDIR= clean cleandepend
115 BUILDENV_SHELL?=/bin/sh
117 SVN?= /usr/local/bin/svn
120 MAKEOBJDIRPREFIX?= /usr/obj
121 .if !defined(OSRELDATE)
122 .if exists(/usr/include/osreldate.h)
123 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
124 /usr/include/osreldate.h
130 .if !defined(VERSION)
131 REVISION!= make -C ${.CURDIR}/release -V REVISION
132 BRANCH!= make -C ${.CURDIR}/release -V BRANCH
133 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
134 ${.CURDIR}/sys/sys/param.h
135 VERSION= FreeBSD ${REVISION}-${BRANCH} ${TARGET_ARCH} ${SRCRELDATE}
138 KNOWN_ARCHES?= amd64 arm armeb/arm armv6/arm i386 i386/pc98 ia64 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
139 .if ${TARGET} == ${TARGET_ARCH}
142 _t= ${TARGET_ARCH}/${TARGET}
145 .if empty(KNOWN_ARCHES:M${_t})
146 .error Unknown target ${TARGET_ARCH}:${TARGET}.
150 .if ${TARGET} == ${MACHINE}
151 TARGET_CPUTYPE?=${CPUTYPE}
156 .if !empty(TARGET_CPUTYPE)
157 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
159 _TARGET_CPUTYPE=dummy
161 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
162 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
163 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
164 .error CPUTYPE global should be set with ?=.
167 BUILD_ARCH!= uname -p
168 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
169 .error To cross-build, set TARGET_ARCH.
172 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
173 OBJTREE= ${MAKEOBJDIRPREFIX}
175 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
177 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
178 # /usr/games added for fortune which depend on strfile
179 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
180 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
181 STRICTTMPPATH= ${BPATH}:${XPATH}
182 TMPPATH= ${STRICTTMPPATH}:${PATH}
185 # Avoid running mktemp(1) unless actually needed.
186 # It may not be functional, e.g., due to new ABI
187 # when in the middle of installing over this system.
189 .if make(distributeworld) || make(installworld)
190 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
194 # Building a world goes through the following stages
196 # 1. legacy stage [BMAKE]
197 # This stage is responsible for creating compatibility
198 # shims that are needed by the bootstrap-tools,
199 # build-tools and cross-tools stages.
200 # 1. bootstrap-tools stage [BMAKE]
201 # This stage is responsible for creating programs that
202 # are needed for backward compatibility reasons. They
203 # are not built as cross-tools.
204 # 2. build-tools stage [TMAKE]
205 # This stage is responsible for creating the object
206 # tree and building any tools that are needed during
208 # 3. cross-tools stage [XMAKE]
209 # This stage is responsible for creating any tools that
210 # are needed for cross-builds. A cross-compiler is one
212 # 4. world stage [WMAKE]
213 # This stage actually builds the world.
214 # 5. install stage (optional) [IMAKE]
215 # This stage installs a previously built world.
220 # Common environment for world related stages
221 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
222 MACHINE_ARCH=${TARGET_ARCH} \
224 CPUTYPE=${TARGET_CPUTYPE}
225 .if ${MK_GROFF} != "no"
226 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
227 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
228 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
231 # bootstrap-tools stage
232 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
233 PATH=${BPATH}:${PATH} \
234 WORLDTMP=${WORLDTMP} \
235 VERSION="${VERSION}" \
236 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
237 COMPILER_TYPE=${COMPILER_TYPE}
238 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
239 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
241 BOOTSTRAPPING=${OSRELDATE} \
243 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
244 -DNO_PIC -DNO_PROFILE -DNO_SHARED \
245 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
248 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
249 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
250 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
252 BOOTSTRAPPING=${OSRELDATE} \
255 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
258 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
259 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
263 WMAKEENV= ${CROSSENV} \
264 _SHLIBDIRPREFIX=${WORLDTMP} \
266 VERSION="${VERSION}" \
267 INSTALL="sh ${.CURDIR}/tools/install.sh" \
271 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
273 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
276 .if ${MK_CDDL} == "no"
280 .if defined(CROSS_TOOLCHAIN_PREFIX)
281 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
282 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
284 XCOMPILERS= CC CXX CPP
285 .for COMPILER in ${XCOMPILERS}
286 .if defined(CROSS_COMPILER_PREFIX)
287 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
289 X${COMPILER}?= ${${COMPILER}}
292 XBINUTILS= AS AR LD NM OBJDUMP RANLIB STRINGS
293 .for BINUTIL in ${XBINUTILS}
294 .if defined(CROSS_BINUTILS_PREFIX)
295 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
297 X${BINUTIL}?= ${${BINUTIL}}
300 WMAKEENV+= CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS}" \
301 CPP="${XCPP} ${XFLAGS}" \
302 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
303 OBJDUMP=${XOBJDUMP} RANLIB=${XRANLIB} STRINGS=${XSTRINGS}
305 .if ${XCC:T:Mgcc} == "gcc"
306 WMAKE_COMPILER_TYPE= gcc
307 .elif ${XCC:T:Mclang} == "clang"
308 WMAKE_COMPILER_TYPE= clang
309 .elif ${MK_CLANG_IS_CC} == "no"
310 WMAKE_COMPILER_TYPE= gcc
312 WMAKE_COMPILER_TYPE= clang
314 IMAKE_COMPILER_TYPE= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
317 XFLAGS= --sysroot=${WORLDTMP}
318 .if defined(CROSS_BINUTILS_PREFIX)
319 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
320 # directory, but the compiler will look in the right place for it's
321 # tools so we don't need to tell it where to look.
322 .if exists(${CROSS_BINUTILS_PREFIX})
323 XFLAGS+= -B${CROSS_BINUTILS_PREFIX}
326 XFLAGS+= -B${WORLDTMP}/usr/bin
328 .if ${TARGET_ARCH} != ${MACHINE_ARCH} && ${WMAKE_COMPILER_TYPE} == "clang"
329 .if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \
330 ${MK_ARM_EABI} != "no"
335 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd10.0
336 XFLAGS+= -target ${TARGET_TRIPLE}
340 WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
341 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
343 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
345 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
347 .if ${TARGET_ARCH} == "amd64"
348 .if empty(TARGET_CPUTYPE)
349 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
351 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
353 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
354 MACHINE_CPU="i686 mmx sse sse2"
357 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
359 .elif ${TARGET_ARCH} == "powerpc64"
360 .if empty(TARGET_CPUTYPE)
361 LIB32CPUFLAGS= -mcpu=powerpc
363 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
365 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
367 LD="${LD} -m elf32ppc_fbsd"
371 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
372 -isystem ${LIB32TMP}/usr/include/ \
373 -L${LIB32TMP}/usr/lib32 \
374 -B${LIB32TMP}/usr/lib32
376 LIB32FLAGS+= --sysroot=${WORLDTMP}
379 # Yes, the flags are redundant.
380 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
381 _SHLIBDIRPREFIX=${LIB32TMP} \
382 _LDSCRIPTROOT=${LIB32TMP} \
383 VERSION="${VERSION}" \
384 INSTALL="sh ${.CURDIR}/tools/install.sh" \
387 SHLIBDIR=/usr/lib32 \
388 LIBPRIVATEDIR=/usr/lib32/private \
389 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
391 CC="${XCC} ${LIB32FLAGS}" \
392 CXX="${XCXX} ${LIB32FLAGS}" \
393 DESTDIR=${LIB32TMP} \
400 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
401 -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
402 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
406 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
407 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
408 ${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_COMPILER_TYPE}
409 .if empty(.MAKEFLAGS:M-n)
410 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
411 LD_LIBRARY_PATH=${INSTALLTMP} \
412 PATH_LOCALE=${INSTALLTMP}/locale
413 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
415 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
417 .if defined(DB_FROM_SRC)
418 INSTALLFLAGS+= -N ${.CURDIR}/etc
419 MTREEFLAGS+= -N ${.CURDIR}/etc
421 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
422 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
424 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
425 IMAKE+= -DNO_ROOT METALOG=${METALOG}
426 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
429 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
430 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
431 IMAKE_MTREE= MTREE_CMD="nmtree ${MTREEFLAGS}"
435 KMAKEENV= ${WMAKEENV}
436 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
441 # Attempt to rebuild the entire system, with reasonable chance of
442 # success, regardless of how old your existing system is.
445 .if ${.CURDIR:C/[^,]//g} != ""
446 # The m4 build of sendmail files doesn't like it if ',' is used
447 # anywhere in the path of it's files.
449 @echo "*** Error: path to source tree contains a comma ','"
454 @echo "--------------------------------------------------------------"
455 @echo ">>> Rebuilding the temporary build tree"
456 @echo "--------------------------------------------------------------"
457 .if !defined(NO_CLEAN)
459 .if defined(LIB32TMP)
463 rm -rf ${WORLDTMP}/legacy/usr/include
464 # XXX - These three can depend on any header file.
465 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
466 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
467 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
470 lib usr legacy/bin legacy/usr
471 mkdir -p ${WORLDTMP}/${_dir}
473 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
474 -p ${WORLDTMP}/legacy/usr >/dev/null
475 .if ${MK_GROFF} != "no"
476 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
477 -p ${WORLDTMP}/legacy/usr >/dev/null
479 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
480 -p ${WORLDTMP}/usr >/dev/null
481 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
482 -p ${WORLDTMP}/usr/include >/dev/null
483 ln -sf ${.CURDIR}/sys ${WORLDTMP}
484 .if ${MK_DEBUG_FILES} != "no"
485 # We could instead disable debug files for these build stages
486 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
487 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
488 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
489 -p ${WORLDTMP}/usr/lib >/dev/null
491 .for _mtree in ${LOCAL_MTREE}
492 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
496 @echo "--------------------------------------------------------------"
497 @echo ">>> stage 1.1: legacy release compatibility shims"
498 @echo "--------------------------------------------------------------"
499 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
502 @echo "--------------------------------------------------------------"
503 @echo ">>> stage 1.2: bootstrap tools"
504 @echo "--------------------------------------------------------------"
505 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
507 .if !defined(NO_CLEAN)
509 @echo "--------------------------------------------------------------"
510 @echo ">>> stage 2.1: cleaning up the object tree"
511 @echo "--------------------------------------------------------------"
512 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
513 .if defined(LIB32TMP)
514 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
519 @echo "--------------------------------------------------------------"
520 @echo ">>> stage 2.2: rebuilding the object tree"
521 @echo "--------------------------------------------------------------"
522 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
525 @echo "--------------------------------------------------------------"
526 @echo ">>> stage 2.3: build tools"
527 @echo "--------------------------------------------------------------"
528 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
531 @echo "--------------------------------------------------------------"
532 @echo ">>> stage 3: cross tools"
533 @echo "--------------------------------------------------------------"
534 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
537 @echo "--------------------------------------------------------------"
538 @echo ">>> stage 4.1: building includes"
539 @echo "--------------------------------------------------------------"
540 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
543 @echo "--------------------------------------------------------------"
544 @echo ">>> stage 4.2: building libraries"
545 @echo "--------------------------------------------------------------"
546 ${_+_}cd ${.CURDIR}; \
547 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
548 -DWITHOUT_MAN -DNO_PROFILE libraries
551 @echo "--------------------------------------------------------------"
552 @echo ">>> stage 4.3: make dependencies"
553 @echo "--------------------------------------------------------------"
554 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
557 @echo "--------------------------------------------------------------"
558 @echo ">>> stage 4.4: building everything"
559 @echo "--------------------------------------------------------------"
560 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
561 .if defined(LIB32TMP)
564 @echo "--------------------------------------------------------------"
565 @echo ">>> stage 5.1: building 32 bit shim libraries"
566 @echo "--------------------------------------------------------------"
567 mkdir -p ${LIB32TMP}/usr/include
568 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
569 -p ${LIB32TMP}/usr >/dev/null
570 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
571 -p ${LIB32TMP}/usr/include >/dev/null
572 .if ${MK_DEBUG_FILES} != "no"
573 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
574 -p ${LIB32TMP}/usr/lib >/dev/null
577 ln -sf ${.CURDIR}/sys ${WORLDTMP}
578 .for _t in obj includes
579 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
580 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
581 .if ${MK_CDDL} != "no"
582 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
584 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
585 .if ${MK_CRYPT} != "no"
586 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
588 .if ${MK_KERBEROS} != "no"
589 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
592 .for _dir in usr.bin/lex/lib
593 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
595 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
596 cd ${.CURDIR}/${_dir}; \
597 WORLDTMP=${WORLDTMP} \
598 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
599 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
600 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
601 -DEARLY_BUILD build-tools
604 ${LIB32WMAKE} -f Makefile.inc1 libraries
605 .for _t in obj depend all
606 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
607 DIRPRFX=libexec/rtld-elf/ ${_t}
608 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
609 DIRPRFX=usr.bin/ldd ${_t}
612 distribute32 install32:
613 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
614 .if ${MK_CDDL} != "no"
615 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
617 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
618 .if ${MK_CRYPT} != "no"
619 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
621 .if ${MK_KERBEROS} != "no"
622 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
624 cd ${.CURDIR}/libexec/rtld-elf; \
625 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
626 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
630 .if !defined(SUBDIR_OVERRIDE)
631 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
633 WMAKE_TGTS+= _cleanobj _obj _build-tools
634 .if !defined(SUBDIR_OVERRIDE)
635 WMAKE_TGTS+= _cross-tools
637 WMAKE_TGTS+= _includes _libraries _depend everything
638 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
642 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
643 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
646 @echo "--------------------------------------------------------------"
647 @echo ">>> World build started on `LC_ALL=C date`"
648 @echo "--------------------------------------------------------------"
652 @echo "--------------------------------------------------------------"
653 @echo ">>> World build completed on `LC_ALL=C date`"
654 @echo "--------------------------------------------------------------"
657 # We need to have this as a target because the indirection between Makefile
658 # and Makefile.inc1 causes the correct PATH to be used, rather than a
659 # modification of the current environment's PATH. In addition, we need
660 # to quote multiword values.
666 @echo Entering world for ${TARGET_ARCH}:${TARGET}
667 @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
669 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
670 toolchain: ${TOOLCHAIN_TGTS}
671 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
676 # Checks to be sure system is ready for installworld/installkernel.
678 installcheck: _installcheck_world _installcheck_kernel
680 _installcheck_kernel:
683 # Require DESTDIR to be set if installing for a different architecture or
684 # using the user/group database in the source tree.
686 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
688 .if !make(distributeworld)
689 _installcheck_world: __installcheck_DESTDIR
690 _installcheck_kernel: __installcheck_DESTDIR
691 __installcheck_DESTDIR:
692 .if !defined(DESTDIR) || empty(DESTDIR)
693 @echo "ERROR: Please set DESTDIR!"; \
699 .if !defined(DB_FROM_SRC)
701 # Check for missing UIDs/GIDs.
703 CHECK_UIDS= auditdistd
705 .if ${MK_SENDMAIL} != "no"
711 CHECK_GIDS+= proxy authpf
713 .if ${MK_UNBOUND} != "no"
717 _installcheck_world: __installcheck_UGID
719 .for uid in ${CHECK_UIDS}
720 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
721 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
725 .for gid in ${CHECK_GIDS}
726 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
727 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
734 # Required install tools to be saved in a scratch dir for safety.
736 .if ${MK_INFO} != "no"
737 _install-info= install-info
739 .if ${MK_ZONEINFO} != "no"
740 _zoneinfo= zic tzsetup
743 .if exists(/usr/sbin/nmtree)
744 _nmtree_itools= nmtree
747 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
748 date echo egrep find grep id install ${_install-info} \
749 ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
750 rm sed sh sysctl test true uname wc ${_zoneinfo}
755 # Distributes everything compiled by a `buildworld'.
759 # Installs everything compiled by a 'buildworld'.
762 # Non-base distributions produced by the base system
763 EXTRA_DISTRIBUTIONS= doc
764 .if ${MK_GAMES} != "no"
765 EXTRA_DISTRIBUTIONS+= games
767 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
768 EXTRA_DISTRIBUTIONS+= lib32
771 MTREE_MAGIC?= mtree 2.0
773 distributeworld installworld: _installcheck_world
774 mkdir -p ${INSTALLTMP}
775 progs=$$(for prog in ${ITOOLS}; do \
776 if progpath=`which $$prog`; then \
779 echo "Required tool $$prog not found in PATH." >&2; \
783 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
784 while read line; do \
786 if [ "$$2 $$3" != "not found" ]; then \
789 echo "Required library $$1 not found." >&2; \
793 cp $$libs $$progs ${INSTALLTMP}
794 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
796 echo "#${MTREE_MAGIC}" > ${METALOG}
798 .if make(distributeworld)
799 .for dist in ${EXTRA_DISTRIBUTIONS}
800 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
801 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
802 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
803 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
804 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
805 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
806 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
807 .if ${MK_DEBUG_FILES} != "no"
808 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
809 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
812 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
813 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
814 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
815 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
816 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
817 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
820 -mkdir ${DESTDIR}/${DISTDIR}/base
821 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
822 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
823 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
824 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
826 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
827 ${IMAKEENV} rm -rf ${INSTALLTMP}
828 .if make(distributeworld)
829 .for dist in ${EXTRA_DISTRIBUTIONS}
830 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
833 .for dist in base ${EXTRA_DISTRIBUTIONS}
834 @# For each file that exists in this dist, print the corresponding
835 @# line from the METALOG. This relies on the fact that
836 @# a line containing only the filename will sort immediatly before
837 @# the relevant mtree line.
838 cd ${DESTDIR}/${DISTDIR}; \
839 find ./${dist} | sort -u ${METALOG} - | \
840 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
841 ${DESTDIR}/${DISTDIR}/${dist}.meta
843 .if ${MK_DEBUG_FILES} != "no"
844 . for dist in base ${EXTRA_DISTRIBUTIONS}
845 @# For each file that exists in this dist, print the corresponding
846 @# line from the METALOG. This relies on the fact that
847 @# a line containing only the filename will sort immediatly before
848 @# the relevant mtree line.
849 cd ${DESTDIR}/${DISTDIR}; \
850 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
851 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
852 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
859 .for dist in base ${EXTRA_DISTRIBUTIONS}
861 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
862 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
863 --exclude usr/lib/debug \
864 @${DESTDIR}/${DISTDIR}/${dist}.meta
866 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
867 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
868 --exclude usr/lib/debug .
872 .if ${MK_DEBUG_FILES} != "no"
873 . for dist in base ${EXTRA_DISTRIBUTIONS}
874 . if defined(NO_ROOT)
875 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
876 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
877 @${DESTDIR}/${DISTDIR}/${dist}.debug.meta
879 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
880 tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
889 # If you have a build server, you can NFS mount the source and obj directories
890 # and do a 'make reinstall' on the *client* to install new binaries from the
891 # most recent server build.
894 @echo "--------------------------------------------------------------"
895 @echo ">>> Making hierarchy"
896 @echo "--------------------------------------------------------------"
897 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
898 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
900 @echo "--------------------------------------------------------------"
901 @echo ">>> Installing everything"
902 @echo "--------------------------------------------------------------"
903 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
904 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
905 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
909 @echo "--------------------------------------------------------------"
910 @echo ">>> Distributing everything"
911 @echo "--------------------------------------------------------------"
912 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
913 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
914 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
918 distrib-dirs distribution:
919 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
920 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
923 # buildkernel and installkernel
925 # Which kernels to build and/or install is specified by setting
926 # KERNCONF. If not defined a GENERIC kernel is built/installed.
927 # Only the existing (depending TARGET) config files are used
928 # for building kernels and only the first of these is designated
929 # as the one being installed.
931 # Note that we have to use TARGET instead of TARGET_ARCH when
932 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
933 # be set to cross-build, we have to make sure TARGET is set
936 .if defined(KERNFAST)
941 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
942 .if !defined(KERNCONF) && ${KERNFAST} != "1"
946 .if ${TARGET_ARCH} == "powerpc64"
951 INSTKERNNAME?= kernel
953 KERNSRCDIR?= ${.CURDIR}/sys
954 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
955 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
956 KERNCONFDIR?= ${KRNLCONFDIR}
960 .for _kernel in ${KERNCONF}
961 .if exists(${KERNCONFDIR}/${_kernel})
962 BUILDKERNELS+= ${_kernel}
963 .if empty(INSTALLKERNEL)
964 INSTALLKERNEL= ${_kernel}
972 # Builds all kernels defined by BUILDKERNELS.
975 .if empty(BUILDKERNELS)
976 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
980 .for _kernel in ${BUILDKERNELS}
981 @echo "--------------------------------------------------------------"
982 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
983 @echo "--------------------------------------------------------------"
984 @echo "===> ${_kernel}"
985 mkdir -p ${KRNLOBJDIR}
986 .if !defined(NO_KERNELCONFIG)
988 @echo "--------------------------------------------------------------"
989 @echo ">>> stage 1: configuring the kernel"
990 @echo "--------------------------------------------------------------"
993 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
994 ${KERNCONFDIR}/${_kernel}
996 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
998 @echo "--------------------------------------------------------------"
999 @echo ">>> stage 2.1: cleaning up the object tree"
1000 @echo "--------------------------------------------------------------"
1001 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1003 .if !defined(NO_KERNELOBJ)
1005 @echo "--------------------------------------------------------------"
1006 @echo ">>> stage 2.2: rebuilding the object tree"
1007 @echo "--------------------------------------------------------------"
1008 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1011 @echo "--------------------------------------------------------------"
1012 @echo ">>> stage 2.3: build tools"
1013 @echo "--------------------------------------------------------------"
1014 cd ${KRNLOBJDIR}/${_kernel}; \
1015 PATH=${BPATH}:${PATH} \
1016 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
1017 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
1018 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
1019 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
1020 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
1021 .for target in obj depend all
1022 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
1023 PATH=${BPATH}:${PATH} \
1024 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
1025 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
1028 .if !defined(NO_KERNELDEPEND)
1030 @echo "--------------------------------------------------------------"
1031 @echo ">>> stage 3.1: making dependencies"
1032 @echo "--------------------------------------------------------------"
1033 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1036 @echo "--------------------------------------------------------------"
1037 @echo ">>> stage 3.2: building everything"
1038 @echo "--------------------------------------------------------------"
1039 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1040 @echo "--------------------------------------------------------------"
1041 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1042 @echo "--------------------------------------------------------------"
1046 # installkernel, etc.
1048 # Install the kernel defined by INSTALLKERNEL
1050 installkernel installkernel.debug \
1051 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1052 .if empty(INSTALLKERNEL)
1053 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1056 @echo "--------------------------------------------------------------"
1057 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1058 @echo "--------------------------------------------------------------"
1059 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1060 ${CROSSENV} PATH=${TMPPATH} \
1061 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1063 distributekernel distributekernel.debug:
1064 .if empty(INSTALLKERNEL)
1065 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1068 mkdir -p ${DESTDIR}/${DISTDIR}
1069 .if defined(NO_ROOT)
1070 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1072 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1073 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1074 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1075 DESTDIR=${INSTALL_DDIR}/kernel \
1076 ${.TARGET:S/distributekernel/install/}
1077 .if defined(NO_ROOT)
1078 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1079 ${DESTDIR}/${DISTDIR}/kernel.meta
1081 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1082 .if defined(NO_ROOT)
1083 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1085 cd ${KRNLOBJDIR}/${_kernel}; \
1086 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1087 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1088 KERNEL=${INSTKERNNAME}.${_kernel} \
1089 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1090 ${.TARGET:S/distributekernel/install/}
1091 .if defined(NO_ROOT)
1092 sed -e 's|^./kernel|.|' \
1093 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1094 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1099 .if defined(NO_ROOT)
1100 cd ${DESTDIR}/${DISTDIR}/kernel; \
1101 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
1102 @${DESTDIR}/${DISTDIR}/kernel.meta
1103 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1104 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1105 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
1106 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1109 cd ${DESTDIR}/${DISTDIR}/kernel; \
1110 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1111 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1112 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1113 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1120 # Build the API documentation with doxygen
1123 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1124 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1127 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1132 # Update the source tree(s), by running svn/svnup to update to the
1136 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1137 @echo "--------------------------------------------------------------"
1138 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1139 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1140 @echo "--------------------------------------------------------------"
1143 .if defined(SVN_UPDATE)
1144 @echo "--------------------------------------------------------------"
1145 @echo ">>> Updating ${.CURDIR} using Subversion"
1146 @echo "--------------------------------------------------------------"
1147 @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1151 # ------------------------------------------------------------------------
1153 # From here onwards are utility targets used by the 'make world' and
1154 # related targets. If your 'world' breaks, you may like to try to fix
1155 # the problem and manually run the following targets to attempt to
1156 # complete the build. Beware, this is *not* guaranteed to work, you
1157 # need to have a pretty good grip on the current state of the system
1158 # to attempt to manually finish it. If in doubt, 'make world' again.
1162 # legacy: Build compatibility shims for the next three targets
1165 .if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0
1166 @echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \
1169 .for _tool in tools/build
1170 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1171 cd ${.CURDIR}/${_tool} && \
1172 ${MAKE} DIRPRFX=${_tool}/ obj && \
1173 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
1174 ${MAKE} DIRPRFX=${_tool}/ depend && \
1175 ${MAKE} DIRPRFX=${_tool}/ all && \
1176 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1180 # bootstrap-tools: Build tools needed for compatibility
1182 .if ${MK_GAMES} != "no"
1183 _strfile= games/fortune/strfile
1186 .if ${MK_CXX} != "no"
1187 _gperf= gnu/usr.bin/gperf
1190 .if ${MK_GROFF} != "no"
1191 _groff= gnu/usr.bin/groff
1194 .if ${BOOTSTRAPPING} < 800022
1198 .if ${BOOTSTRAPPING} < 800013
1199 _mklocale= usr.bin/mklocale
1202 .if ${BOOTSTRAPPING} < 900002
1206 .if ${BOOTSTRAPPING} < 900006
1210 .if ${BOOTSTRAPPING} < 1000002
1214 .if ${BOOTSTRAPPING} < 1000013
1219 .if ${BOOTSTRAPPING} < 1000014
1220 _crunch= usr.sbin/crunch
1223 .if ${BOOTSTRAPPING} < 1000026
1224 _nmtree= lib/libnetbsd \
1228 .if ${BOOTSTRAPPING} < 1000027
1232 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1236 .if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree)
1237 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1240 .if ${MK_CLANG} != "no"
1242 lib/clang/libllvmsupport \
1243 lib/clang/libllvmtablegen \
1244 usr.bin/clang/tblgen \
1245 usr.bin/clang/clang-tblgen
1248 # dtrace tools are required for older bootstrap env and cross-build
1249 .if ${MK_CDDL} != "no" && \
1250 ((${BOOTSTRAPPING} < 1000034 && \
1251 !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
1252 || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1253 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1254 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1257 # Default to building the BSDL DTC, but build the GPL one if users explicitly
1260 .if ${MK_GPL_DTC} != "no"
1261 _dtc= gnu/usr.bin/dtc
1264 .if ${MK_KERBEROS} != "no"
1265 _kerberos5_bootstrap_tools= \
1266 kerberos5/tools/make-roken \
1267 kerberos5/lib/libroken \
1268 kerberos5/lib/libvers \
1269 kerberos5/tools/asn1_compile \
1270 kerberos5/tools/slc \
1274 # Please document (add comment) why something is in 'bootstrap-tools'.
1275 # Try to bound the building of the bootstrap-tool to just the
1276 # FreeBSD versions that need the tool built at this stage of the build.
1277 bootstrap-tools: .MAKE
1280 ${_kerberos5_bootstrap_tools} \
1290 usr.bin/makewhatis \
1303 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1304 cd ${.CURDIR}/${_tool} && \
1305 ${MAKE} DIRPRFX=${_tool}/ obj && \
1306 ${MAKE} DIRPRFX=${_tool}/ depend && \
1307 ${MAKE} DIRPRFX=${_tool}/ all && \
1308 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1312 # build-tools: Build special purpose build tools
1314 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1315 _aicasm= sys/modules/aic7xxx/aicasm
1318 .if !defined(NO_SHARE)
1319 _share= share/syscons/scrnmaps
1322 .if ${MK_GCC} != "no"
1323 _gcc_tools= gnu/usr.bin/cc/cc_tools
1326 .if ${MK_RESCUE} != "no"
1327 _rescue= rescue/rescue
1335 ${LOCAL_TOOL_DIRS} \
1336 lib/ncurses/ncurses \
1337 lib/ncurses/ncursesw \
1342 usr.bin/mkesdb_static \
1343 usr.bin/mkcsmapper_static \
1345 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1346 cd ${.CURDIR}/${_tool} && \
1347 ${MAKE} DIRPRFX=${_tool}/ obj && \
1348 ${MAKE} DIRPRFX=${_tool}/ build-tools
1352 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1353 cd ${.CURDIR}/${_tool} && \
1354 ${MAKE} DIRPRFX=${_tool}/ obj && \
1355 ${MAKE} DIRPRFX=${_tool}/ depend && \
1356 ${MAKE} DIRPRFX=${_tool}/ all
1360 # cross-tools: Build cross-building tools
1362 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1363 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1364 _btxld= usr.sbin/btxld
1367 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1368 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1369 _crunchide= usr.sbin/crunch/crunchide
1371 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1372 _kgzip= usr.sbin/kgzip
1376 .if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
1377 _binutils= gnu/usr.bin/binutils
1380 # If an full path to an external cross compiler is given, don't build
1382 .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1383 .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1384 _clang= usr.bin/clang
1385 _clang_libs= lib/clang
1388 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1399 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1403 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1404 cd ${.CURDIR}/${_tool} && \
1405 ${MAKE} DIRPRFX=${_tool}/ obj && \
1406 ${MAKE} DIRPRFX=${_tool}/ depend && \
1407 ${MAKE} DIRPRFX=${_tool}/ all && \
1408 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1412 # hierarchy - ensure that all the needed directories are present
1415 cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1418 # libraries - build all libraries, and install them under ${DESTDIR}.
1420 # The list of libraries with dependents (${_prebuild_libs}) and their
1421 # interdependencies (__L) are built automatically by the
1422 # ${.CURDIR}/tools/make_libdeps.sh script.
1426 ${MAKE} -f Makefile.inc1 _prereq_libs && \
1427 ${MAKE} -f Makefile.inc1 _startup_libs && \
1428 ${MAKE} -f Makefile.inc1 _prebuild_libs && \
1429 ${MAKE} -f Makefile.inc1 _generic_libs
1432 # static libgcc.a prerequisite for shared libc
1434 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1436 # These dependencies are not automatically generated:
1438 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1439 # all shared libraries for ELF.
1441 _startup_libs= gnu/lib/csu
1442 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1443 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1444 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1445 _startup_libs+= lib/csu/${MACHINE_ARCH}
1447 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1449 _startup_libs+= gnu/lib/libgcc
1450 _startup_libs+= lib/libcompiler_rt
1451 _startup_libs+= lib/libc
1452 .if ${MK_LIBCPLUSPLUS} != "no"
1453 _startup_libs+= lib/libcxxrt
1456 gnu/lib/libgcc__L: lib/libc__L
1457 .if ${MK_LIBCPLUSPLUS} != "no"
1458 lib/libcxxrt__L: gnu/lib/libgcc__L
1461 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1462 ${_kerberos5_lib_libhdb} \
1463 ${_kerberos5_lib_libheimbase} \
1464 ${_kerberos5_lib_libheimntlm} \
1465 ${_kerberos5_lib_libheimsqlite} \
1466 ${_kerberos5_lib_libheimipcc} \
1467 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1468 ${_kerberos5_lib_libroken} \
1469 ${_kerberos5_lib_libwind} \
1470 ${_lib_atf_libatf_c} \
1471 lib/libbz2 ${_libcom_err} lib/libcrypt \
1472 lib/libelf lib/libexpat \
1473 ${_lib_libgssapi} ${_lib_libipx} \
1474 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1475 lib/ncurses/ncurses lib/ncurses/ncursesw \
1476 lib/libopie lib/libpam ${_lib_libthr} \
1477 lib/libradius lib/libsbuf lib/libtacplus \
1478 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1479 ${_cddl_lib_libzfs_core} \
1480 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1481 ${_secure_lib_libcrypto} ${_lib_libldns} \
1482 ${_secure_lib_libssh} ${_secure_lib_libssl}
1484 .if ${MK_ATF} != "no"
1485 _lib_atf_libatf_c= lib/atf/libatf-c
1488 .if ${MK_LIBTHR} != "no"
1489 _lib_libthr= lib/libthr
1492 .if ${MK_OFED} != "no"
1493 _ofed_lib= contrib/ofed/usr.lib/
1496 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1497 .for _DIR in ${LOCAL_LIB_DIRS}
1498 .if exists(${.CURDIR}/${_DIR}/Makefile)
1499 _generic_libs+= ${_DIR}
1503 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1505 .if ${MK_CDDL} != "no"
1506 _cddl_lib_libumem= cddl/lib/libumem
1507 _cddl_lib_libnvpair= cddl/lib/libnvpair
1508 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1510 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1513 .if ${MK_CRYPT} != "no"
1514 .if ${MK_OPENSSL} != "no"
1515 _secure_lib_libcrypto= secure/lib/libcrypto
1516 _secure_lib_libssl= secure/lib/libssl
1517 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1518 .if ${MK_LDNS} != "no"
1519 _lib_libldns= lib/libldns
1520 lib/libldns__L: secure/lib/libcrypto__L
1522 .if ${MK_OPENSSH} != "no"
1523 _secure_lib_libssh= secure/lib/libssh
1524 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1525 .if ${MK_LDNS} != "no"
1526 secure/lib/libssh__L: lib/libldns__L
1528 .if ${MK_KERBEROS_SUPPORT} != "no"
1529 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1530 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1531 lib/libmd__L kerberos5/lib/libroken__L
1535 _secure_lib= secure/lib
1538 .if ${MK_KERBEROS} != "no"
1539 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1540 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1541 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1542 kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
1543 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1544 kerberos5/lib/libroken__L lib/libcom_err__L
1545 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1546 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1547 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1548 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1549 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1550 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1551 kerberos5/lib/libroken__L: lib/libcrypt__L
1552 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1553 kerberos5/lib/libheimbase__L: lib/libthr__L
1554 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1555 kerberos5/lib/libheimsqlite__L: lib/libthr__L
1558 .if ${MK_GSSAPI} != "no"
1559 _lib_libgssapi= lib/libgssapi
1562 .if ${MK_IPX} != "no"
1563 _lib_libipx= lib/libipx
1566 .if ${MK_KERBEROS} != "no"
1567 _kerberos5_lib= kerberos5/lib
1568 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1569 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1570 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1571 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1572 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1573 _kerberos5_lib_libroken= kerberos5/lib/libroken
1574 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1575 _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
1576 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1577 _kerberos5_lib_libwind= kerberos5/lib/libwind
1578 _libcom_err= lib/libcom_err
1581 .if ${MK_NIS} != "no"
1582 _lib_libypclnt= lib/libypclnt
1585 .if ${MK_OPENSSL} == "no"
1586 lib/libradius__L: lib/libmd__L
1589 .for _lib in ${_prereq_libs}
1590 ${_lib}__PL: .PHONY .MAKE
1591 .if exists(${.CURDIR}/${_lib})
1592 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1593 cd ${.CURDIR}/${_lib} && \
1594 ${MAKE} DIRPRFX=${_lib}/ obj && \
1595 ${MAKE} DIRPRFX=${_lib}/ depend && \
1596 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all && \
1597 ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1601 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1602 ${_lib}__L: .PHONY .MAKE
1603 .if exists(${.CURDIR}/${_lib})
1604 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1605 cd ${.CURDIR}/${_lib} && \
1606 ${MAKE} DIRPRFX=${_lib}/ obj && \
1607 ${MAKE} DIRPRFX=${_lib}/ depend && \
1608 ${MAKE} DIRPRFX=${_lib}/ all && \
1609 ${MAKE} DIRPRFX=${_lib}/ install
1613 # libpam is special: we need to build static PAM modules before
1614 # static PAM library, and dynamic PAM library before dynamic PAM
1616 lib/libpam__L: .PHONY .MAKE
1617 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1618 cd ${.CURDIR}/lib/libpam && \
1619 ${MAKE} DIRPRFX=lib/libpam/ obj && \
1620 ${MAKE} DIRPRFX=lib/libpam/ depend && \
1621 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all && \
1622 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1624 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1625 _startup_libs: ${_startup_libs:S/$/__L/}
1626 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1627 _generic_libs: ${_generic_libs:S/$/__L/}
1629 .for __target in all clean cleandepend cleandir depend includes obj
1630 .for entry in ${SUBDIR}
1631 ${entry}.${__target}__D: .PHONY .MAKE
1632 ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1633 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1634 edir=${entry}.${MACHINE_ARCH}; \
1635 cd ${.CURDIR}/$${edir}; \
1637 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1639 cd ${.CURDIR}/$${edir}; \
1641 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1643 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1646 .include <bsd.subdir.mk>
1648 .if make(check-old) || make(check-old-dirs) || \
1649 make(check-old-files) || make(check-old-libs) || \
1650 make(delete-old) || make(delete-old-dirs) || \
1651 make(delete-old-files) || make(delete-old-libs)
1654 # check for / delete old files section
1657 .include "ObsoleteFiles.inc"
1659 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1660 else you can not start such an application. Consult UPDATING for more \
1661 information regarding how to cope with the removal/revision bump of a \
1664 .if !defined(BATCH_DELETE_OLD_FILES)
1671 @echo ">>> Removing old files (only deletes safe to delete libs)"
1672 # Ask for every old file if the user really wants to remove it.
1673 # It's annoying, but better safe than sorry.
1674 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1675 # argument list will get too long. Using .for/.endfor make "loops" will make
1676 # the Makefile parser segfault.
1678 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1679 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1680 while read file; do \
1681 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1682 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1683 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1686 # Remove catpages without corresponding manpages.
1688 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1689 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1690 while read catpage; do \
1692 if [ ! -e "$${manpage}" ]; then \
1693 rm ${RM_I} $${catpage} <&3; \
1696 @echo ">>> Old files removed"
1699 @echo ">>> Checking for old files"
1700 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1701 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1702 while read file; do \
1703 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1704 echo "${DESTDIR}/$${file}"; \
1707 # Check for catpages without corresponding manpages.
1708 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1709 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1710 while read catpage; do \
1712 if [ ! -e "$${manpage}" ]; then \
1718 @echo ">>> Removing old libraries"
1719 @echo "${OLD_LIBS_MESSAGE}" | fmt
1721 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1722 -V OLD_LIBS | xargs -n1 | \
1723 while read file; do \
1724 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1725 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1726 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1729 @echo ">>> Old libraries removed"
1732 @echo ">>> Checking for old libraries"
1733 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1734 -V OLD_LIBS | xargs -n1 | \
1735 while read file; do \
1736 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1737 echo "${DESTDIR}/$${file}"; \
1742 @echo ">>> Removing old directories"
1743 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1744 -V OLD_DIRS | xargs -n1 | sort -r | \
1745 while read dir; do \
1746 if [ -d "${DESTDIR}/$${dir}" ]; then \
1747 rmdir -v "${DESTDIR}/$${dir}" || true; \
1748 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1749 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1752 @echo ">>> Old directories removed"
1755 @echo ">>> Checking for old directories"
1756 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1757 -V OLD_DIRS | xargs -n1 | \
1758 while read dir; do \
1759 if [ -d "${DESTDIR}/$${dir}" ]; then \
1760 echo "${DESTDIR}/$${dir}"; \
1761 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1762 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1766 delete-old: delete-old-files delete-old-dirs
1767 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1769 check-old: check-old-files check-old-libs check-old-dirs
1770 @echo "To remove old files and directories run '${MAKE} delete-old'."
1771 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1776 # showconfig - show build configuration.
1779 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort
1781 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1782 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1784 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1785 .if exists(${KERNCONFDIR}/${KERNCONF})
1786 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1787 ${KERNCONFDIR}/${KERNCONF} ; echo
1793 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1794 DTBOUTPUTPATH= ${.CURDIR}
1798 # Build 'standalone' Device Tree Blob
1801 @if [ "${FDT_DTS_FILE}" = "" ]; then \
1802 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1805 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1806 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1810 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \
1811 echo "WARNING: DTB will be placed in the current working \
1816 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1817 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1821 .if defined(XDEV) && defined(XDEV_ARCH)
1823 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1824 XDEV_CPUTYPE?=${CPUTYPE}
1826 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1829 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1830 -DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \
1831 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1832 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1833 CPUTYPE=${XDEV_CPUTYPE}
1835 XDDIR=${XDEV_ARCH}-freebsd
1837 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1838 INSTALL="sh ${.CURDIR}/tools/install.sh"
1840 _SHLIBDIRPREFIX=${XDDESTDIR} \
1841 TOOLS_PREFIX=${XDDESTDIR}
1842 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
1843 -B${XDDESTDIR}/usr/lib
1844 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" \
1845 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1847 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
1848 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1849 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1850 XDDESTDIR=${DESTDIR}${XDTP}
1852 OSREL!= uname -r | sed -e 's/[-(].*//'
1855 .ORDER: xdev-build xdev-install
1856 xdev: xdev-build xdev-install
1858 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1859 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
1862 mkdir -p ${CDTMP}/usr
1863 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1864 -p ${CDTMP}/usr >/dev/null
1866 _xb-bootstrap-tools:
1869 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1870 cd ${.CURDIR}/${_tool} && \
1871 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1872 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1873 ${CDMAKE} DIRPRFX=${_tool}/ all && \
1874 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
1878 ${_+_}@cd ${.CURDIR}; \
1879 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1883 gnu/usr.bin/binutils \
1888 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1889 cd ${.CURDIR}/${_tool} && \
1890 ${CDMAKE} DIRPRFX=${_tool}/ obj && \
1891 ${CDMAKE} DIRPRFX=${_tool}/ depend && \
1892 ${CDMAKE} DIRPRFX=${_tool}/ all
1896 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1897 mkdir -p ${XDDESTDIR}
1898 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1899 -p ${XDDESTDIR} >/dev/null
1900 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1901 -p ${XDDESTDIR}/usr >/dev/null
1902 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1903 -p ${XDDESTDIR}/usr/include >/dev/null
1905 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1906 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1909 @echo "_xi-cross-tools"
1911 gnu/usr.bin/binutils \
1915 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1916 cd ${.CURDIR}/${_tool}; \
1917 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1921 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1922 DESTDIR=${XDDESTDIR}
1925 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1926 DESTDIR=${XDDESTDIR}
1929 ${_+_}cd ${XDDESTDIR}/usr/bin; \
1931 ln -sf ../../${XDTP}/usr/bin/$$i \
1932 ../../../../usr/bin/${XDDIR}-$$i; \
1933 ln -sf ../../${XDTP}/usr/bin/$$i \
1934 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1937 xdev xdev-build xdev-install:
1938 @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
1941 buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE