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_MTREE="list of mtree files" to process to allow local directories
21 # to be created before files are installed
22 # METALOG="path to metadata log" to write permission and ownership
23 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
24 # TARGET="machine" to crossbuild world for a different machine type
25 # TARGET_ARCH= may be required when a TARGET supports multiple endians
26 # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
27 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
28 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
31 # The intended user-driven targets are:
32 # buildworld - rebuild *everything*, including glue to help do upgrades
33 # installworld- install everything built by "buildworld"
34 # doxygen - build API documentation of the kernel
35 # update - convenient way to update your source tree (eg: cvsup/cvs)
37 # Standard targets (not defined here) are documented in the makefiles in
38 # /usr/share/mk. These include:
39 # obj depend all install clean cleandepend cleanobj
41 # You are supposed to define both of these when calling Makefile.inc1
42 # directly. However, some old scripts don't. Cope for the moment, but
43 # issue a new warning for a transition period.
44 .if defined(TARGET) && !defined(TARGET_ARCH)
45 .warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}."
48 .if !defined(TARGET) || !defined(TARGET_ARCH)
49 .error "Both TARGET and TARGET_ARCH must be defined."
53 .include <bsd.arch.inc.mk>
54 .include <bsd.compiler.mk>
56 # We must do share/info early so that installation of info `dir'
57 # entries works correctly. Do it first since it is less likely to
58 # grow dependencies on include and lib than vice versa.
60 # We must do lib/ and libexec/ before bin/, because if installworld
61 # installs a new /bin/sh, the 'make' command will *immediately*
62 # use that new version. And the new (dynamically-linked) /bin/sh
63 # will expect to find appropriate libraries in /lib and /libexec.
65 SUBDIR= share/info lib libexec
67 .if ${MK_GAMES} != "no"
70 .if ${MK_CDDL} != "no"
74 .if ${MK_KERBEROS} != "no"
77 .if ${MK_RESCUE} != "no"
81 .if ${MK_CRYPT} != "no"
84 .if !defined(NO_SHARE)
87 SUBDIR+=sys usr.bin usr.sbin
88 .if ${MK_OFED} != "no"
92 # We must do etc/ last for install/distribute to work.
96 # These are last, since it is nice to at least get the base system
97 # rebuilt before you do them.
98 .for _DIR in ${LOCAL_DIRS}
99 .if exists(${.CURDIR}/${_DIR}/Makefile)
104 .if defined(SUBDIR_OVERRIDE)
105 SUBDIR= ${SUBDIR_OVERRIDE}
111 .if defined(NO_CLEANDIR)
112 CLEANDIR= clean cleandepend
117 BUILDENV_SHELL?=/bin/sh
119 SVN?= /usr/local/bin/svn
122 MAKEOBJDIRPREFIX?= /usr/obj
123 .if !defined(OSRELDATE)
124 .if exists(/usr/include/osreldate.h)
125 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
126 /usr/include/osreldate.h
132 .if !defined(VERSION)
134 VERSION+= ${OSRELDATE}
137 KNOWN_ARCHES?= amd64 arm armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/mips mips64el/mips mips64eb/mips mipsn32el/mips mipsn32eb/mips powerpc powerpc64/powerpc sparc64
138 .if ${TARGET} == ${TARGET_ARCH}
141 _t= ${TARGET_ARCH}/${TARGET}
144 .if empty(KNOWN_ARCHES:M${_t})
145 .error Unknown target ${TARGET_ARCH}:${TARGET}.
149 .if ${TARGET} == ${MACHINE}
150 TARGET_CPUTYPE?=${CPUTYPE}
155 .if !empty(TARGET_CPUTYPE)
156 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
158 _TARGET_CPUTYPE=dummy
160 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
161 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
162 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
163 .error CPUTYPE global should be set with ?=.
166 BUILD_ARCH!= uname -p
167 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
168 .error To cross-build, set TARGET_ARCH.
171 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
172 OBJTREE= ${MAKEOBJDIRPREFIX}
174 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
176 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
177 # /usr/games added for fortune which depend on strfile
178 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
179 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
180 STRICTTMPPATH= ${BPATH}:${XPATH}
181 TMPPATH= ${STRICTTMPPATH}:${PATH}
184 # Avoid running mktemp(1) unless actually needed.
185 # It may not be functional, e.g., due to new ABI
186 # when in the middle of installing over this system.
188 .if make(distributeworld) || make(installworld)
189 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
193 # Building a world goes through the following stages
195 # 1. legacy stage [BMAKE]
196 # This stage is responsible for creating compatibility
197 # shims that are needed by the bootstrap-tools,
198 # build-tools and cross-tools stages.
199 # 1. bootstrap-tools stage [BMAKE]
200 # This stage is responsible for creating programs that
201 # are needed for backward compatibility reasons. They
202 # are not built as cross-tools.
203 # 2. build-tools stage [TMAKE]
204 # This stage is responsible for creating the object
205 # tree and building any tools that are needed during
207 # 3. cross-tools stage [XMAKE]
208 # This stage is responsible for creating any tools that
209 # are needed for cross-builds. A cross-compiler is one
211 # 4. world stage [WMAKE]
212 # This stage actually builds the world.
213 # 5. install stage (optional) [IMAKE]
214 # This stage installs a previously built world.
219 # Common environment for world related stages
220 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
221 MACHINE_ARCH=${TARGET_ARCH} \
223 CPUTYPE=${TARGET_CPUTYPE}
224 .if ${OSRELDATE} < 700044
225 CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib
227 .if ${MK_GROFF} != "no"
228 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
229 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
230 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
233 # bootstrap-tools stage
234 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
235 PATH=${BPATH}:${PATH} \
236 WORLDTMP=${WORLDTMP} \
237 VERSION="${VERSION}" \
238 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
239 COMPILER_TYPE=${COMPILER_TYPE}
240 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
241 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
243 BOOTSTRAPPING=${OSRELDATE} \
245 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
246 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
247 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
250 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
251 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
252 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
254 BOOTSTRAPPING=${OSRELDATE} \
257 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
260 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
261 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
265 WMAKEENV= ${CROSSENV} \
266 _SHLIBDIRPREFIX=${WORLDTMP} \
268 VERSION="${VERSION}" \
269 INSTALL="sh ${.CURDIR}/tools/install.sh" \
273 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
275 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
278 .if ${MK_CDDL} == "no"
281 .if ${CC:T:Mgcc} == "gcc"
282 WMAKE_COMPILER_TYPE= gcc
283 .elif ${CC:T:Mclang} == "clang"
284 WMAKE_COMPILER_TYPE= clang
285 .elif ${MK_CLANG_IS_CC} == "no"
286 WMAKE_COMPILER_TYPE= gcc
288 WMAKE_COMPILER_TYPE= clang
290 WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
291 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
293 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
295 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
297 .if ${TARGET_ARCH} == "amd64"
298 .if empty(TARGET_CPUTYPE)
299 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
301 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
303 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
304 MACHINE_CPU="i686 mmx sse sse2"
307 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
309 .elif ${TARGET_ARCH} == "powerpc64"
310 .if empty(TARGET_CPUTYPE)
311 LIB32CPUFLAGS= -mcpu=powerpc
313 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
315 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
317 LD="${LD} -m elf32ppc"
321 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
322 -isystem ${LIB32TMP}/usr/include/ \
323 -L${LIB32TMP}/usr/lib32 \
324 -B${LIB32TMP}/usr/lib32
326 # Yes, the flags are redundant.
327 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
328 _SHLIBDIRPREFIX=${LIB32TMP} \
329 _LDSCRIPTROOT=${LIB32TMP} \
330 VERSION="${VERSION}" \
331 INSTALL="sh ${.CURDIR}/tools/install.sh" \
334 SHLIBDIR=/usr/lib32 \
335 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
337 CC="${CC} ${LIB32FLAGS}" \
338 CXX="${CXX} ${LIB32FLAGS}" \
339 DESTDIR=${LIB32TMP} \
346 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
347 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
348 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
352 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
353 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
354 ${IMAKE_INSTALL} ${IMAKE_MTREE}
355 .if empty(.MAKEFLAGS:M-n)
356 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
357 LD_LIBRARY_PATH=${INSTALLTMP} \
358 PATH_LOCALE=${INSTALLTMP}/locale
359 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
361 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
363 .if defined(DB_FROM_SRC)
364 INSTALLFLAGS+= -N ${.CURDIR}/etc
365 MTREEFLAGS+= -N ${.CURDIR}/etc
368 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
369 IMAKE+= -DNO_ROOT METALOG=${METALOG}
370 INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
371 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR:S://:/:g:C:/$::}
374 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
375 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
376 IMAKE_MTREE= MTREE_CMD="nmtree ${MTREEFLAGS}"
380 KMAKEENV= ${WMAKEENV}
381 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
386 # Attempt to rebuild the entire system, with reasonable chance of
387 # success, regardless of how old your existing system is.
390 .if ${.CURDIR:C/[^,]//g} != ""
391 # The m4 build of sendmail files doesn't like it if ',' is used
392 # anywhere in the path of it's files.
394 @echo "*** Error: path to source tree contains a comma ','"
399 @echo "--------------------------------------------------------------"
400 @echo ">>> Rebuilding the temporary build tree"
401 @echo "--------------------------------------------------------------"
402 .if !defined(NO_CLEAN)
404 .if defined(LIB32TMP)
408 rm -rf ${WORLDTMP}/legacy/usr/include
409 # XXX - These three can depend on any header file.
410 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
411 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
412 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
415 lib usr legacy/bin legacy/usr
416 mkdir -p ${WORLDTMP}/${_dir}
418 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
419 -p ${WORLDTMP}/legacy/usr >/dev/null
420 .if ${MK_GROFF} != "no"
421 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
422 -p ${WORLDTMP}/legacy/usr >/dev/null
424 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
425 -p ${WORLDTMP}/usr >/dev/null
426 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
427 -p ${WORLDTMP}/usr/include >/dev/null
428 ln -sf ${.CURDIR}/sys ${WORLDTMP}
429 .if ${MK_DEBUG_FILES} != "no"
430 # We could instead disable debug files for these build stages
431 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
432 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
433 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
434 -p ${WORLDTMP}/usr/lib >/dev/null
436 .if ${MK_BIND_LIBS} != "no"
437 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
438 -p ${WORLDTMP}/usr/include >/dev/null
440 .for _mtree in ${LOCAL_MTREE}
441 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
445 @echo "--------------------------------------------------------------"
446 @echo ">>> stage 1.1: legacy release compatibility shims"
447 @echo "--------------------------------------------------------------"
448 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
451 @echo "--------------------------------------------------------------"
452 @echo ">>> stage 1.2: bootstrap tools"
453 @echo "--------------------------------------------------------------"
454 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
456 .if !defined(NO_CLEAN)
458 @echo "--------------------------------------------------------------"
459 @echo ">>> stage 2.1: cleaning up the object tree"
460 @echo "--------------------------------------------------------------"
461 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
462 .if defined(LIB32TMP)
463 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
468 @echo "--------------------------------------------------------------"
469 @echo ">>> stage 2.2: rebuilding the object tree"
470 @echo "--------------------------------------------------------------"
471 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
474 @echo "--------------------------------------------------------------"
475 @echo ">>> stage 2.3: build tools"
476 @echo "--------------------------------------------------------------"
477 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
480 @echo "--------------------------------------------------------------"
481 @echo ">>> stage 3: cross tools"
482 @echo "--------------------------------------------------------------"
483 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
486 @echo "--------------------------------------------------------------"
487 @echo ">>> stage 4.1: building includes"
488 @echo "--------------------------------------------------------------"
489 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
492 @echo "--------------------------------------------------------------"
493 @echo ">>> stage 4.2: building libraries"
494 @echo "--------------------------------------------------------------"
495 ${_+_}cd ${.CURDIR}; \
496 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
497 -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
500 @echo "--------------------------------------------------------------"
501 @echo ">>> stage 4.3: make dependencies"
502 @echo "--------------------------------------------------------------"
503 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
506 @echo "--------------------------------------------------------------"
507 @echo ">>> stage 4.4: building everything"
508 @echo "--------------------------------------------------------------"
509 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
510 .if defined(LIB32TMP)
513 @echo "--------------------------------------------------------------"
514 @echo ">>> stage 5.1: building 32 bit shim libraries"
515 @echo "--------------------------------------------------------------"
516 mkdir -p ${LIB32TMP}/usr/include
517 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
518 -p ${LIB32TMP}/usr >/dev/null
519 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
520 -p ${LIB32TMP}/usr/include >/dev/null
521 .if ${MK_DEBUG_FILES} != "no"
522 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
523 -p ${LIB32TMP}/usr/lib >/dev/null
526 ln -sf ${.CURDIR}/sys ${WORLDTMP}
527 .if ${MK_KERBEROS} != "no"
528 .for _t in obj depend all
529 cd ${.CURDIR}/kerberos5/tools; \
530 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
531 DIRPRFX=kerberos5/tools/ ${_t}
534 .for _t in obj includes
535 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
536 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
537 .if ${MK_CDDL} != "no"
538 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
540 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
541 .if ${MK_CRYPT} != "no"
542 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
544 .if ${MK_KERBEROS} != "no"
545 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
548 .for _dir in usr.bin/lex/lib
549 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
551 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
552 cd ${.CURDIR}/${_dir}; \
553 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
554 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
555 -DEARLY_BUILD build-tools
558 ${LIB32WMAKE} -f Makefile.inc1 libraries
559 .for _t in obj depend all
560 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
561 DIRPRFX=libexec/rtld-elf/ ${_t}
562 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
563 DIRPRFX=usr.bin/ldd ${_t}
566 distribute32 install32:
567 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
568 .if ${MK_CDDL} != "no"
569 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
571 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
572 .if ${MK_CRYPT} != "no"
573 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
575 .if ${MK_KERBEROS} != "no"
576 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
578 cd ${.CURDIR}/libexec/rtld-elf; \
579 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
580 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
584 .if !defined(SUBDIR_OVERRIDE)
585 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
587 WMAKE_TGTS+= _cleanobj _obj _build-tools
588 .if !defined(SUBDIR_OVERRIDE)
589 WMAKE_TGTS+= _cross-tools
591 WMAKE_TGTS+= _includes _libraries _depend everything
592 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
596 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
597 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
600 @echo "--------------------------------------------------------------"
601 @echo ">>> World build started on `LC_ALL=C date`"
602 @echo "--------------------------------------------------------------"
606 @echo "--------------------------------------------------------------"
607 @echo ">>> World build completed on `LC_ALL=C date`"
608 @echo "--------------------------------------------------------------"
611 # We need to have this as a target because the indirection between Makefile
612 # and Makefile.inc1 causes the correct PATH to be used, rather than a
613 # modification of the current environment's PATH. In addition, we need
614 # to quote multiword values.
620 @echo Entering world for ${TARGET_ARCH}:${TARGET}
621 @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
623 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
624 toolchain: ${TOOLCHAIN_TGTS}
625 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
630 # Checks to be sure system is ready for installworld/installkernel.
636 # Require DESTDIR to be set if installing for a different architecture or
637 # using the user/group database in the source tree.
639 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
641 .if !make(distributeworld)
642 installcheck: installcheck_DESTDIR
643 installcheck_DESTDIR:
644 .if !defined(DESTDIR) || empty(DESTDIR)
645 @echo "ERROR: Please set DESTDIR!"; \
651 .if !defined(DB_FROM_SRC)
653 # Check for missing UIDs/GIDs.
655 CHECK_UIDS= auditdistd
657 .if ${MK_SENDMAIL} != "no"
663 CHECK_GIDS+= proxy authpf
666 .for uid in ${CHECK_UIDS}
667 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
668 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
672 .for gid in ${CHECK_GIDS}
673 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
674 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
681 # Required install tools to be saved in a scratch dir for safety.
683 .if ${MK_INFO} != "no"
684 _install-info= install-info
686 .if ${MK_ZONEINFO} != "no"
687 _zoneinfo= zic tzsetup
690 .if exists(/usr/sbin/nmtree)
691 _nmtree_itools= nmtree
694 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
695 date echo egrep find grep id install ${_install-info} \
696 ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
697 rm sed sh sysctl test true uname wc ${_zoneinfo}
702 # Distributes everything compiled by a `buildworld'.
706 # Installs everything compiled by a 'buildworld'.
709 # Non-base distributions produced by the base system
710 EXTRA_DISTRIBUTIONS= doc
711 .if ${MK_GAMES} != "no"
712 EXTRA_DISTRIBUTIONS+= games
714 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
715 EXTRA_DISTRIBUTIONS+= lib32
718 MTREE_MAGIC?= mtree 2.0
720 distributeworld installworld: installcheck installcheck_UGID
721 mkdir -p ${INSTALLTMP}
722 progs=$$(for prog in ${ITOOLS}; do \
723 if progpath=`which $$prog`; then \
726 echo "Required tool $$prog not found in PATH." >&2; \
730 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
731 while read line; do \
733 if [ "$$2 $$3" != "not found" ]; then \
736 echo "Required library $$1 not found." >&2; \
740 cp $$libs $$progs ${INSTALLTMP}
741 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
743 echo "#${MTREE_MAGIC}" > ${METALOG}
745 .if make(distributeworld)
746 .for dist in ${EXTRA_DISTRIBUTIONS}
747 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
748 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
749 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
750 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
751 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
752 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
753 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
754 .if ${MK_DEBUG_FILES} != "no"
755 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
756 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
759 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
760 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
761 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
762 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
763 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
764 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
767 -mkdir ${DESTDIR}/${DISTDIR}/base
768 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
769 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
770 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
771 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
773 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
774 ${IMAKEENV} rm -rf ${INSTALLTMP}
775 .if make(distributeworld)
776 .for dist in ${EXTRA_DISTRIBUTIONS}
777 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
780 .for dist in base ${EXTRA_DISTRIBUTIONS}
781 @# For each file that exists in this dist, print the corresponding
782 @# line from the METALOG. This relies on the fact that
783 @# a line containing only the filename will sort immediatly before
784 @# the relevant mtree line.
785 cd ${DESTDIR}/${DISTDIR}; \
786 find ./${dist} | sort -u ${METALOG} - | \
787 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
788 ${DESTDIR}/${DISTDIR}/${dist}.meta
794 .for dist in base ${EXTRA_DISTRIBUTIONS}
796 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
797 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
798 @${DESTDIR}/${DISTDIR}/${dist}.meta
800 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
801 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz .
808 # If you have a build server, you can NFS mount the source and obj directories
809 # and do a 'make reinstall' on the *client* to install new binaries from the
810 # most recent server build.
813 @echo "--------------------------------------------------------------"
814 @echo ">>> Making hierarchy"
815 @echo "--------------------------------------------------------------"
816 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
817 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
819 @echo "--------------------------------------------------------------"
820 @echo ">>> Installing everything"
821 @echo "--------------------------------------------------------------"
822 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
823 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
824 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
828 @echo "--------------------------------------------------------------"
829 @echo ">>> Distributing everything"
830 @echo "--------------------------------------------------------------"
831 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
832 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
833 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
837 distrib-dirs distribution:
838 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
839 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
842 # buildkernel and installkernel
844 # Which kernels to build and/or install is specified by setting
845 # KERNCONF. If not defined a GENERIC kernel is built/installed.
846 # Only the existing (depending TARGET) config files are used
847 # for building kernels and only the first of these is designated
848 # as the one being installed.
850 # Note that we have to use TARGET instead of TARGET_ARCH when
851 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
852 # be set to cross-build, we have to make sure TARGET is set
855 .if defined(KERNFAST)
860 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
861 .if !defined(KERNCONF) && ${KERNFAST} != "1"
865 .if !defined(KERNCONF) && defined(KERNEL)
869 .if ${TARGET_ARCH} == "powerpc64"
875 INSTKERNNAME?= kernel
877 KERNSRCDIR?= ${.CURDIR}/sys
878 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
879 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
880 KERNCONFDIR?= ${KRNLCONFDIR}
884 .for _kernel in ${KERNCONF}
885 .if exists(${KERNCONFDIR}/${_kernel})
886 BUILDKERNELS+= ${_kernel}
887 .if empty(INSTALLKERNEL)
888 INSTALLKERNEL= ${_kernel}
896 # Builds all kernels defined by BUILDKERNELS.
899 .if empty(BUILDKERNELS)
900 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
903 .if defined(KERNWARN)
904 @echo "--------------------------------------------------------------"
905 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
906 @echo "--------------------------------------------------------------"
910 .for _kernel in ${BUILDKERNELS}
911 @echo "--------------------------------------------------------------"
912 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
913 @echo "--------------------------------------------------------------"
914 @echo "===> ${_kernel}"
915 mkdir -p ${KRNLOBJDIR}
916 .if !defined(NO_KERNELCONFIG)
918 @echo "--------------------------------------------------------------"
919 @echo ">>> stage 1: configuring the kernel"
920 @echo "--------------------------------------------------------------"
923 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
924 ${KERNCONFDIR}/${_kernel}
926 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
928 @echo "--------------------------------------------------------------"
929 @echo ">>> stage 2.1: cleaning up the object tree"
930 @echo "--------------------------------------------------------------"
931 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
933 .if !defined(NO_KERNELOBJ)
935 @echo "--------------------------------------------------------------"
936 @echo ">>> stage 2.2: rebuilding the object tree"
937 @echo "--------------------------------------------------------------"
938 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
941 @echo "--------------------------------------------------------------"
942 @echo ">>> stage 2.3: build tools"
943 @echo "--------------------------------------------------------------"
944 cd ${KRNLOBJDIR}/${_kernel}; \
945 PATH=${BPATH}:${PATH} \
946 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
947 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
948 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
949 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
950 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
951 .for target in obj depend all
952 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
953 PATH=${BPATH}:${PATH} \
954 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
955 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
958 .if !defined(NO_KERNELDEPEND)
960 @echo "--------------------------------------------------------------"
961 @echo ">>> stage 3.1: making dependencies"
962 @echo "--------------------------------------------------------------"
963 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
966 @echo "--------------------------------------------------------------"
967 @echo ">>> stage 3.2: building everything"
968 @echo "--------------------------------------------------------------"
969 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
970 @echo "--------------------------------------------------------------"
971 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
972 @echo "--------------------------------------------------------------"
976 # installkernel, etc.
978 # Install the kernel defined by INSTALLKERNEL
980 installkernel installkernel.debug \
981 reinstallkernel reinstallkernel.debug: installcheck
982 .if empty(INSTALLKERNEL)
983 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
986 @echo "--------------------------------------------------------------"
987 @echo ">>> Installing kernel ${INSTALLKERNEL}"
988 @echo "--------------------------------------------------------------"
989 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
990 ${CROSSENV} PATH=${TMPPATH} \
991 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
993 distributekernel distributekernel.debug:
994 .if empty(INSTALLKERNEL)
995 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
998 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
999 ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1000 DESTDIR=${DESTDIR}/${DISTDIR}/kernel \
1001 ${.TARGET:S/distributekernel/install/}
1002 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1003 cd ${KRNLOBJDIR}/${_kernel}; \
1004 ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1005 KERNEL=${INSTKERNNAME}.${_kernel} \
1006 DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
1007 ${.TARGET:S/distributekernel/install/}
1011 cd ${DESTDIR}/${DISTDIR}/kernel; \
1012 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
1013 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1014 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1015 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1021 # Build the API documentation with doxygen
1024 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1025 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1028 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1033 # Update the source tree(s), by running cvsup/cvs/svn to update to the
1037 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1038 @echo "--------------------------------------------------------------"
1039 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1040 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1041 @echo "--------------------------------------------------------------"
1044 .if defined(SVN_UPDATE)
1045 @echo "--------------------------------------------------------------"
1046 @echo ">>> Updating ${.CURDIR} using Subversion"
1047 @echo "--------------------------------------------------------------"
1048 @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
1052 # ------------------------------------------------------------------------
1054 # From here onwards are utility targets used by the 'make world' and
1055 # related targets. If your 'world' breaks, you may like to try to fix
1056 # the problem and manually run the following targets to attempt to
1057 # complete the build. Beware, this is *not* guaranteed to work, you
1058 # need to have a pretty good grip on the current state of the system
1059 # to attempt to manually finish it. If in doubt, 'make world' again.
1063 # legacy: Build compatibility shims for the next three targets
1066 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
1067 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
1070 .for _tool in tools/build
1071 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1072 cd ${.CURDIR}/${_tool}; \
1073 ${MAKE} DIRPRFX=${_tool}/ obj; \
1074 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1075 ${MAKE} DIRPRFX=${_tool}/ depend; \
1076 ${MAKE} DIRPRFX=${_tool}/ all; \
1077 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1081 # bootstrap-tools: Build tools needed for compatibility
1083 .if ${MK_GAMES} != "no"
1084 _strfile= games/fortune/strfile
1087 .if ${MK_CXX} != "no"
1088 _gperf= gnu/usr.bin/gperf
1091 .if ${MK_GROFF} != "no"
1092 _groff= gnu/usr.bin/groff
1095 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
1099 .if ${BOOTSTRAPPING} < 800013
1100 _mklocale= usr.bin/mklocale
1103 .if ${BOOTSTRAPPING} < 900002
1107 .if ${BOOTSTRAPPING} < 900006
1111 .if ${BOOTSTRAPPING} < 900006 || ${BOOTSTRAPPING} >= 1000013
1116 .if ${BOOTSTRAPPING} < 1000026
1117 _nmtree= lib/libnetbsd \
1121 .if ${BOOTSTRAPPING} < 1000027
1125 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1129 .if ${MK_BSNMP} != "no" && \
1130 (${BOOTSTRAPPING} < 700018 || !exists(/usr/sbin/gensnmptree))
1131 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1134 .if ${MK_RESCUE} != "no" && \
1135 ${BOOTSTRAPPING} < 700026
1136 _crunchgen= usr.sbin/crunch/crunchgen
1139 .if ${MK_CLANG} != "no"
1141 lib/clang/libllvmsupport \
1142 lib/clang/libllvmtablegen \
1143 usr.bin/clang/tblgen \
1144 usr.bin/clang/clang-tblgen
1147 .if ${MK_CDDL} != "no" && \
1148 ((${BOOTSTRAPPING} < 1000034 && \
1149 !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
1150 || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1151 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1152 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1155 .if ${MK_FDT} != "no"
1156 _dtc= gnu/usr.bin/dtc
1159 # Please document (add comment) why something is in 'bootstrap-tools'.
1160 # Try to bound the building of the bootstrap-tool to just the
1161 # FreeBSD versions that need the tool built at this stage of the build.
1174 usr.bin/makewhatis \
1186 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1187 cd ${.CURDIR}/${_tool}; \
1188 ${MAKE} DIRPRFX=${_tool}/ obj; \
1189 ${MAKE} DIRPRFX=${_tool}/ depend; \
1190 ${MAKE} DIRPRFX=${_tool}/ all; \
1191 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1195 # build-tools: Build special purpose build tools
1197 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1198 _aicasm= sys/modules/aic7xxx/aicasm
1201 .if !defined(NO_SHARE)
1202 _share= share/syscons/scrnmaps
1205 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1206 _gcc_tools= gnu/usr.bin/cc/cc_tools
1209 .if ${MK_KERBEROS} != "no"
1210 _kerberos5_tools= kerberos5/tools
1213 .if ${MK_RESCUE} != "no"
1214 _rescue= rescue/rescue
1222 lib/ncurses/ncurses \
1223 lib/ncurses/ncursesw \
1228 usr.sbin/sysinstall \
1229 usr.bin/mkesdb_static \
1230 usr.bin/mkcsmapper_static
1231 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1232 cd ${.CURDIR}/${_tool}; \
1233 ${MAKE} DIRPRFX=${_tool}/ obj; \
1234 ${MAKE} DIRPRFX=${_tool}/ build-tools
1239 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1240 cd ${.CURDIR}/${_tool}; \
1241 ${MAKE} DIRPRFX=${_tool}/ obj; \
1242 ${MAKE} DIRPRFX=${_tool}/ depend; \
1243 ${MAKE} DIRPRFX=${_tool}/ all
1247 # cross-tools: Build cross-building tools
1249 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1250 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1251 _btxld= usr.sbin/btxld
1254 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1255 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1256 _crunchide= usr.sbin/crunch/crunchide
1258 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1259 _kgzip= usr.sbin/kgzip
1263 .if ${MK_BINUTILS} != "no"
1264 _binutils= gnu/usr.bin/binutils
1267 .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1268 _clang= usr.bin/clang
1269 _clang_libs= lib/clang
1272 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1282 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1286 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1287 cd ${.CURDIR}/${_tool}; \
1288 ${MAKE} DIRPRFX=${_tool}/ obj; \
1289 ${MAKE} DIRPRFX=${_tool}/ depend; \
1290 ${MAKE} DIRPRFX=${_tool}/ all; \
1291 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1295 # hierarchy - ensure that all the needed directories are present
1298 cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
1301 # libraries - build all libraries, and install them under ${DESTDIR}.
1303 # The list of libraries with dependents (${_prebuild_libs}) and their
1304 # interdependencies (__L) are built automatically by the
1305 # ${.CURDIR}/tools/make_libdeps.sh script.
1309 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1310 ${MAKE} -f Makefile.inc1 _startup_libs; \
1311 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1312 ${MAKE} -f Makefile.inc1 _generic_libs;
1315 # static libgcc.a prerequisite for shared libc
1317 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1319 # These dependencies are not automatically generated:
1321 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1322 # all shared libraries for ELF.
1324 _startup_libs= gnu/lib/csu
1325 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1326 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1327 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1328 _startup_libs+= lib/csu/${MACHINE_ARCH}
1330 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1332 _startup_libs+= gnu/lib/libgcc
1333 _startup_libs+= lib/libcompiler_rt
1334 _startup_libs+= lib/libc
1335 .if ${MK_LIBCPLUSPLUS} != "no"
1336 _startup_libs+= lib/libcxxrt
1339 gnu/lib/libgcc__L: lib/libc__L
1340 .if ${MK_LIBCPLUSPLUS} != "no"
1341 lib/libcxxrt__L: gnu/lib/libgcc__L
1344 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libhdb} \
1345 ${_kerberos5_lib_libheimntlm} \
1346 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1347 ${_kerberos5_lib_libroken} \
1348 lib/libbz2 lib/libcom_err lib/libcrypt \
1349 lib/libelf lib/libexpat \
1350 ${_lib_libgssapi} ${_lib_libipx} \
1351 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1352 lib/ncurses/ncurses lib/ncurses/ncursesw \
1353 lib/libopie lib/libpam ${_lib_libthr} \
1354 lib/libradius lib/libsbuf lib/libtacplus \
1355 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1356 ${_cddl_lib_libzfs_core} \
1357 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1358 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1359 ${_secure_lib_libssl}
1361 .if ${MK_LIBTHR} != "no"
1362 _lib_libthr= lib/libthr
1365 .if ${MK_OFED} != "no"
1366 _ofed_lib= contrib/ofed/usr.lib/
1369 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1371 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1373 .if ${MK_CDDL} != "no"
1374 _cddl_lib_libumem= cddl/lib/libumem
1375 _cddl_lib_libnvpair= cddl/lib/libnvpair
1376 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1378 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1381 .if ${MK_CRYPT} != "no"
1382 .if ${MK_OPENSSL} != "no"
1383 _secure_lib_libcrypto= secure/lib/libcrypto
1384 _secure_lib_libssl= secure/lib/libssl
1385 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1386 .if ${MK_OPENSSH} != "no"
1387 _secure_lib_libssh= secure/lib/libssh
1388 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1389 .if ${MK_KERBEROS_SUPPORT} != "no"
1390 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1391 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1392 lib/libmd__L kerberos5/lib/libroken__L
1396 _secure_lib= secure/lib
1399 .if ${MK_KERBEROS} != "no"
1400 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1401 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1402 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L
1403 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L
1404 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1405 secure/lib/libcrypto__L kerberos5/lib/libroken__L
1406 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1407 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1408 kerberos5/lib/libroken__L
1409 kerberos5/lib/libroken__L: lib/libcrypt__L
1412 .if ${MK_GSSAPI} != "no"
1413 _lib_libgssapi= lib/libgssapi
1416 .if ${MK_IPX} != "no"
1417 _lib_libipx= lib/libipx
1420 .if ${MK_KERBEROS} != "no"
1421 _kerberos5_lib= kerberos5/lib
1422 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1423 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1424 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1425 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1426 _kerberos5_lib_libroken= kerberos5/lib/libroken
1427 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1430 .if ${MK_NIS} != "no"
1431 _lib_libypclnt= lib/libypclnt
1434 .if ${MK_OPENSSL} == "no"
1435 lib/libradius__L: lib/libmd__L
1438 .for _lib in ${_prereq_libs}
1440 .if exists(${.CURDIR}/${_lib})
1441 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1442 cd ${.CURDIR}/${_lib}; \
1443 ${MAKE} DIRPRFX=${_lib}/ obj; \
1444 ${MAKE} DIRPRFX=${_lib}/ depend; \
1445 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1446 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1450 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1452 .if exists(${.CURDIR}/${_lib})
1453 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1454 cd ${.CURDIR}/${_lib}; \
1455 ${MAKE} DIRPRFX=${_lib}/ obj; \
1456 ${MAKE} DIRPRFX=${_lib}/ depend; \
1457 ${MAKE} DIRPRFX=${_lib}/ all; \
1458 ${MAKE} DIRPRFX=${_lib}/ install
1462 # libpam is special: we need to build static PAM modules before
1463 # static PAM library, and dynamic PAM library before dynamic PAM
1465 lib/libpam__L: .PHONY
1466 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1467 cd ${.CURDIR}/lib/libpam; \
1468 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1469 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1470 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1471 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1473 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1474 _startup_libs: ${_startup_libs:S/$/__L/}
1475 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1476 _generic_libs: ${_generic_libs:S/$/__L/}
1478 .for __target in all clean cleandepend cleandir depend includes obj
1479 .for entry in ${SUBDIR}
1480 ${entry}.${__target}__D: .PHONY
1481 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1482 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1483 edir=${entry}.${MACHINE_ARCH}; \
1484 cd ${.CURDIR}/$${edir}; \
1486 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1488 cd ${.CURDIR}/$${edir}; \
1490 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1492 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1495 .include <bsd.subdir.mk>
1497 .if make(check-old) || make(check-old-dirs) || \
1498 make(check-old-files) || make(check-old-libs) || \
1499 make(delete-old) || make(delete-old-dirs) || \
1500 make(delete-old-files) || make(delete-old-libs)
1503 # check for / delete old files section
1506 .include "ObsoleteFiles.inc"
1508 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1509 else you can not start such an application. Consult UPDATING for more \
1510 information regarding how to cope with the removal/revision bump of a \
1513 .if !defined(BATCH_DELETE_OLD_FILES)
1520 @echo ">>> Removing old files (only deletes safe to delete libs)"
1521 # Ask for every old file if the user really wants to remove it.
1522 # It's annoying, but better safe than sorry.
1523 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1524 # argument list will get too long. Using .for/.endfor make "loops" will make
1525 # the Makefile parser segfault.
1527 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1528 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1529 while read file; do \
1530 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1531 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1532 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1535 # Remove catpages without corresponding manpages.
1537 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1538 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1539 while read catpage; do \
1541 if [ ! -e "$${manpage}" ]; then \
1542 rm ${RM_I} $${catpage} <&3; \
1545 @echo ">>> Old files removed"
1548 @echo ">>> Checking for old files"
1549 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1550 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1551 while read file; do \
1552 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1553 echo "${DESTDIR}/$${file}"; \
1556 # Check for catpages without corresponding manpages.
1557 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1558 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1559 while read catpage; do \
1561 if [ ! -e "$${manpage}" ]; then \
1567 @echo ">>> Removing old libraries"
1568 @echo "${OLD_LIBS_MESSAGE}" | fmt
1570 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1571 -V OLD_LIBS | xargs -n1 | \
1572 while read file; do \
1573 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1574 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1575 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1577 for ext in debug symbols; do \
1578 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1579 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1580 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1585 @echo ">>> Old libraries removed"
1588 @echo ">>> Checking for old libraries"
1589 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1590 -V OLD_LIBS | xargs -n1 | \
1591 while read file; do \
1592 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1593 echo "${DESTDIR}/$${file}"; \
1595 for ext in debug symbols; do \
1596 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1597 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
1603 @echo ">>> Removing old directories"
1604 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1605 -V OLD_DIRS | xargs -n1 | \
1606 while read dir; do \
1607 if [ -d "${DESTDIR}/$${dir}" ]; then \
1608 rmdir -v "${DESTDIR}/$${dir}" || true; \
1609 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1610 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1613 @echo ">>> Old directories removed"
1616 @echo ">>> Checking for old directories"
1617 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1618 -V OLD_DIRS | xargs -n1 | \
1619 while read dir; do \
1620 if [ -d "${DESTDIR}/$${dir}" ]; then \
1621 echo "${DESTDIR}/$${dir}"; \
1622 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1623 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1627 delete-old: delete-old-files delete-old-dirs
1628 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1630 check-old: check-old-files check-old-libs check-old-dirs
1631 @echo "To remove old files and directories run '${MAKE} delete-old'."
1632 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1637 # showconfig - show build configuration.
1640 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1642 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1643 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1645 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1646 .if exists(${KERNCONFDIR}/${KERNCONF})
1647 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1648 ${KERNCONFDIR}/${KERNCONF} ; echo
1654 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1655 DTBOUTPUTPATH= ${.CURDIR}
1659 # Build 'standalone' Device Tree Blob
1662 @if [ "${FDT_DTS_FILE}" = "" ]; then \
1663 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1666 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1667 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1671 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \
1672 echo "WARNING: DTB will be placed in the current working \
1677 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1678 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1682 .if defined(XDEV) && defined(XDEV_ARCH)
1684 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1685 XDEV_CPUTYPE?=${CPUTYPE}
1687 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1690 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1691 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1692 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1693 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1694 CPUTYPE=${XDEV_CPUTYPE}
1696 XDDIR=${XDEV_ARCH}-freebsd
1698 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1699 INSTALL="sh ${.CURDIR}/tools/install.sh"
1701 _SHLIBDIRPREFIX=${XDTP} \
1702 TOOLS_PREFIX=${XDTP}
1704 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1706 CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1707 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1708 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1709 XDDESTDIR=${DESTDIR}${XDTP}
1711 OSREL!= uname -r | sed -e 's/[-(].*//'
1714 .ORDER: xdev-build xdev-install
1715 xdev: xdev-build xdev-install
1717 .ORDER: _xb-build-tools _xb-cross-tools
1718 xdev-build: _xb-build-tools _xb-cross-tools
1721 ${_+_}@cd ${.CURDIR}; \
1722 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1726 gnu/usr.bin/binutils \
1729 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1730 cd ${.CURDIR}/${_tool}; \
1731 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1732 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1733 ${CDMAKE} DIRPRFX=${_tool}/ all
1737 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1738 mkdir -p ${XDDESTDIR}
1739 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1740 -p ${XDDESTDIR} >/dev/null
1741 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1742 -p ${XDDESTDIR}/usr >/dev/null
1743 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1744 -p ${XDDESTDIR}/usr/include >/dev/null
1746 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1747 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1750 @echo "_xi-cross-tools"
1752 gnu/usr.bin/binutils \
1755 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1756 cd ${.CURDIR}/${_tool}; \
1757 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1761 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1762 DESTDIR=${XDDESTDIR}
1765 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1766 DESTDIR=${XDDESTDIR}
1769 ${_+_}cd ${XDDESTDIR}/usr/bin; \
1771 ln -sf ../../${XDTP}/usr/bin/$$i \
1772 ../../../../usr/bin/${XDDIR}-$$i; \
1773 ln -sf ../../${XDTP}/usr/bin/$$i \
1774 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \