4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DNO_SHARE do not go into share subdir
8 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
9 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
13 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
14 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
15 # -DNO_CTF do not run the DTrace CTF conversion tools on built objects
16 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
17 # TARGET="machine" to crossbuild world for a different machine type
18 # TARGET_ARCH= may be required when a TARGET supports multiple endians
21 # The intended user-driven targets are:
22 # buildworld - rebuild *everything*, including glue to help do upgrades
23 # installworld- install everything built by "buildworld"
24 # doxygen - build API documentation of the kernel
25 # update - convenient way to update your source tree (eg: cvsup/cvs)
27 # Standard targets (not defined here) are documented in the makefiles in
28 # /usr/share/mk. These include:
29 # obj depend all install clean cleandepend cleanobj
31 # You are supposed to define both of these when calling Makefile.inc1
32 # directly. However, some old scripts don't. Cope for the moment, but
33 # issue a new warning for a transition period.
34 .if defined(TARGET) && !defined(TARGET_ARCH)
35 .warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}."
38 .if !defined(TARGET) || !defined(TARGET_ARCH)
39 .error "Both TARGET and TARGET_ARCH must be defined."
43 .include <bsd.arch.inc.mk>
45 # We must do share/info early so that installation of info `dir'
46 # entries works correctly. Do it first since it is less likely to
47 # grow dependencies on include and lib than vice versa.
49 # We must do lib/ and libexec/ before bin/, because if installworld
50 # installs a new /bin/sh, the 'make' command will *immediately*
51 # use that new version. And the new (dynamically-linked) /bin/sh
52 # will expect to find appropriate libraries in /lib and /libexec.
54 SUBDIR= share/info lib libexec
56 .if ${MK_GAMES} != "no"
59 .if ${MK_CDDL} != "no"
65 .if ${MK_KERBEROS} != "no"
68 .if ${MK_RESCUE} != "no"
72 .if ${MK_CRYPT} != "no"
75 .if !defined(NO_SHARE)
78 SUBDIR+=sys usr.bin usr.sbin
79 .if ${MK_OFED} != "no"
83 # We must do etc/ last for install/distribute to work.
87 # These are last, since it is nice to at least get the base system
88 # rebuilt before you do them.
89 .for _DIR in ${LOCAL_DIRS}
90 .if exists(${.CURDIR}/${_DIR}/Makefile)
95 .if defined(SUBDIR_OVERRIDE)
96 SUBDIR= ${SUBDIR_OVERRIDE}
102 .if defined(NO_CLEANDIR)
103 CLEANDIR= clean cleandepend
109 CVSFLAGS?= -A -P -d -I!
115 SUPFLAGS+= -h ${SUPHOST}
118 MAKEOBJDIRPREFIX?= /usr/obj
119 .if !defined(OSRELDATE)
120 .if exists(/usr/include/osreldate.h)
121 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
122 /usr/include/osreldate.h
128 .if !defined(VERSION)
130 VERSION+= ${OSRELDATE}
133 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 sparc64/sun4v
134 .if ${TARGET} == ${TARGET_ARCH}
137 _t= ${TARGET_ARCH}/${TARGET}
140 .if empty(KNOWN_ARCHES:M${_t})
141 .error Unknown target ${TARGET_ARCH}:${TARGET}.
145 .if ${TARGET} == ${MACHINE}
146 TARGET_CPUTYPE?=${CPUTYPE}
151 .if !empty(TARGET_CPUTYPE)
152 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
154 _TARGET_CPUTYPE=dummy
156 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
157 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
158 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
159 .error CPUTYPE global should be set with ?=.
162 BUILD_ARCH!= uname -p
163 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
164 .error To cross-build, set TARGET_ARCH.
167 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
168 OBJTREE= ${MAKEOBJDIRPREFIX}
170 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
172 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
173 # /usr/games added for fortune which depend on strfile
174 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
175 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
176 STRICTTMPPATH= ${BPATH}:${XPATH}
177 TMPPATH= ${STRICTTMPPATH}:${PATH}
180 # Avoid running mktemp(1) unless actually needed.
181 # It may not be functional, e.g., due to new ABI
182 # when in the middle of installing over this system.
184 .if make(distributeworld) || make(installworld)
185 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
189 # Building a world goes through the following stages
191 # 1. legacy stage [BMAKE]
192 # This stage is responsible for creating compatibility
193 # shims that are needed by the bootstrap-tools,
194 # build-tools and cross-tools stages.
195 # 1. bootstrap-tools stage [BMAKE]
196 # This stage is responsible for creating programs that
197 # are needed for backward compatibility reasons. They
198 # are not built as cross-tools.
199 # 2. build-tools stage [TMAKE]
200 # This stage is responsible for creating the object
201 # tree and building any tools that are needed during
203 # 3. cross-tools stage [XMAKE]
204 # This stage is responsible for creating any tools that
205 # are needed for cross-builds. A cross-compiler is one
207 # 4. world stage [WMAKE]
208 # This stage actually builds the world.
209 # 5. install stage (optional) [IMAKE]
210 # This stage installs a previously built world.
215 # Common environment for world related stages
216 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
217 MACHINE_ARCH=${TARGET_ARCH} \
219 CPUTYPE=${TARGET_CPUTYPE}
220 .if ${OSRELDATE} < 700044
221 CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib
223 .if ${MK_GROFF} != "no"
224 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
225 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
226 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
229 # bootstrap-tools stage
230 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
231 PATH=${BPATH}:${PATH} \
232 WORLDTMP=${WORLDTMP} \
233 VERSION="${VERSION}" \
234 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
235 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
236 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
238 BOOTSTRAPPING=${OSRELDATE} \
240 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
241 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
242 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
245 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
246 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
247 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
250 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
254 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
255 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
259 WMAKEENV= ${CROSSENV} \
260 _SHLIBDIRPREFIX=${WORLDTMP} \
261 VERSION="${VERSION}" \
262 INSTALL="sh ${.CURDIR}/tools/install.sh" \
264 .if ${MK_CDDL} == "no"
267 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
269 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
271 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
273 .if ${TARGET_ARCH} == "amd64"
274 .if empty(TARGET_CPUTYPE)
275 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
277 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
279 LIB32CPUFLAGS+= -mfancy-math-387
280 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
281 MACHINE_CPU="i686 mmx sse sse2" \
282 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
285 .elif ${TARGET_ARCH} == "powerpc64"
286 .if empty(TARGET_CPUTYPE)
287 LIB32CPUFLAGS= -mcpu=powerpc
289 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
291 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc \
292 LD="${LD} -m elf32ppc"
296 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
297 -isystem ${LIB32TMP}/usr/include/ \
298 -L${LIB32TMP}/usr/lib32 \
299 -B${LIB32TMP}/usr/lib32
301 # Yes, the flags are redundant.
302 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
303 _SHLIBDIRPREFIX=${LIB32TMP} \
304 VERSION="${VERSION}" \
305 INSTALL="sh ${.CURDIR}/tools/install.sh" \
307 CC="${CC} ${LIB32FLAGS}" \
308 CXX="${CXX} ${LIB32FLAGS}" \
312 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
313 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
314 -DWITHOUT_HTML -DNO_CTF -DNO_LINT DESTDIR=${LIB32TMP}
315 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
319 IMAKEENV= ${CROSSENV}
320 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
321 .if empty(.MAKEFLAGS:M-n)
322 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
323 LD_LIBRARY_PATH=${INSTALLTMP} \
324 PATH_LOCALE=${INSTALLTMP}/locale
325 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
327 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
331 KMAKEENV= ${WMAKEENV}
332 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
337 # Attempt to rebuild the entire system, with reasonable chance of
338 # success, regardless of how old your existing system is.
341 .if ${.CURDIR:C/[^,]//g} != ""
342 # The m4 build of sendmail files doesn't like it if ',' is used
343 # anywhere in the path of it's files.
345 @echo "*** Error: path to source tree contains a comma ','"
350 @echo "--------------------------------------------------------------"
351 @echo ">>> Rebuilding the temporary build tree"
352 @echo "--------------------------------------------------------------"
353 .if !defined(NO_CLEAN)
355 .if defined(LIB32TMP)
359 rm -rf ${WORLDTMP}/legacy/usr/include
360 # XXX - These three can depend on any header file.
361 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
362 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
363 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
367 mkdir -p ${WORLDTMP}/${_dir}
369 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
370 -p ${WORLDTMP}/legacy/usr >/dev/null
371 .if ${MK_GROFF} != "no"
372 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
373 -p ${WORLDTMP}/legacy/usr >/dev/null
375 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
376 -p ${WORLDTMP}/usr >/dev/null
377 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
378 -p ${WORLDTMP}/usr/include >/dev/null
379 ln -sf ${.CURDIR}/sys ${WORLDTMP}
380 .if ${MK_BIND_LIBS} != "no"
381 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
382 -p ${WORLDTMP}/usr/include >/dev/null
386 @echo "--------------------------------------------------------------"
387 @echo ">>> stage 1.1: legacy release compatibility shims"
388 @echo "--------------------------------------------------------------"
389 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
392 @echo "--------------------------------------------------------------"
393 @echo ">>> stage 1.2: bootstrap tools"
394 @echo "--------------------------------------------------------------"
395 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
397 .if !defined(NO_CLEAN)
399 @echo "--------------------------------------------------------------"
400 @echo ">>> stage 2.1: cleaning up the object tree"
401 @echo "--------------------------------------------------------------"
402 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
403 .if defined(LIB32TMP)
404 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
409 @echo "--------------------------------------------------------------"
410 @echo ">>> stage 2.2: rebuilding the object tree"
411 @echo "--------------------------------------------------------------"
412 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
415 @echo "--------------------------------------------------------------"
416 @echo ">>> stage 2.3: build tools"
417 @echo "--------------------------------------------------------------"
418 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
421 @echo "--------------------------------------------------------------"
422 @echo ">>> stage 3: cross tools"
423 @echo "--------------------------------------------------------------"
424 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
427 @echo "--------------------------------------------------------------"
428 @echo ">>> stage 4.1: building includes"
429 @echo "--------------------------------------------------------------"
430 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
433 @echo "--------------------------------------------------------------"
434 @echo ">>> stage 4.2: building libraries"
435 @echo "--------------------------------------------------------------"
436 ${_+_}cd ${.CURDIR}; \
437 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
438 -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
441 @echo "--------------------------------------------------------------"
442 @echo ">>> stage 4.3: make dependencies"
443 @echo "--------------------------------------------------------------"
444 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
447 @echo "--------------------------------------------------------------"
448 @echo ">>> stage 4.4: building everything"
449 @echo "--------------------------------------------------------------"
450 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
451 .if defined(LIB32TMP)
454 @echo "--------------------------------------------------------------"
455 @echo ">>> stage 5.1: building 32 bit shim libraries"
456 @echo "--------------------------------------------------------------"
457 mkdir -p ${LIB32TMP}/usr/include
458 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
459 -p ${LIB32TMP}/usr >/dev/null
460 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
461 -p ${LIB32TMP}/usr/include >/dev/null
463 ln -sf ${.CURDIR}/sys ${WORLDTMP}
464 .if ${MK_KERBEROS} != "no"
465 .for _t in obj depend all
466 cd ${.CURDIR}/kerberos5/tools; \
467 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
468 DIRPRFX=kerberos5/tools/ ${_t}
471 .for _t in obj includes
472 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
473 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
474 .if ${MK_CDDL} != "no"
475 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
477 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
478 .if ${MK_CRYPT} != "no"
479 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
481 .if ${MK_KERBEROS} != "no"
482 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
485 .for _dir in usr.bin/lex/lib
486 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
488 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
489 cd ${.CURDIR}/${_dir}; \
490 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
491 DIRPRFX=${_dir}/ build-tools
494 ${LIB32WMAKE} -f Makefile.inc1 libraries
495 .for _t in obj depend all
496 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
497 DIRPRFX=libexec/rtld-elf/ ${_t}
498 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
499 DIRPRFX=usr.bin/ldd ${_t}
502 distribute32 install32:
503 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
504 .if ${MK_CDDL} != "no"
505 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
507 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
508 .if ${MK_CRYPT} != "no"
509 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
511 .if ${MK_KERBEROS} != "no"
512 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
514 cd ${.CURDIR}/libexec/rtld-elf; \
515 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
516 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
520 .if !defined(SUBDIR_OVERRIDE)
521 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
523 WMAKE_TGTS+= _cleanobj _obj _build-tools
524 .if !defined(SUBDIR_OVERRIDE)
525 WMAKE_TGTS+= _cross-tools
527 WMAKE_TGTS+= _includes _libraries _depend everything
528 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
532 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
533 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
536 @echo "--------------------------------------------------------------"
537 @echo ">>> World build started on `LC_ALL=C date`"
538 @echo "--------------------------------------------------------------"
542 @echo "--------------------------------------------------------------"
543 @echo ">>> World build completed on `LC_ALL=C date`"
544 @echo "--------------------------------------------------------------"
547 # We need to have this as a target because the indirection between Makefile
548 # and Makefile.inc1 causes the correct PATH to be used, rather than a
549 # modification of the current environment's PATH. In addition, we need
550 # to quote multiword values.
556 @echo Entering world for ${TARGET_ARCH}:${TARGET}
557 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
559 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
560 toolchain: ${TOOLCHAIN_TGTS}
561 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
566 # Checks to be sure system is ready for installworld/installkernel.
571 # Require DESTDIR to be set if installing for a different architecture.
573 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
574 .if !make(distributeworld)
575 installcheck: installcheck_DESTDIR
576 installcheck_DESTDIR:
577 .if !defined(DESTDIR) || empty(DESTDIR)
578 @echo "ERROR: Please set DESTDIR!"; \
585 # Check for missing UIDs/GIDs.
589 .if ${MK_SENDMAIL} != "no"
595 CHECK_GIDS+= proxy authpf
597 installcheck: installcheck_UGID
599 .for uid in ${CHECK_UIDS}
600 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
601 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
605 .for gid in ${CHECK_GIDS}
606 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
607 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
613 # Required install tools to be saved in a scratch dir for safety.
615 .if ${MK_INFO} != "no"
616 _install-info= install-info
618 .if ${MK_ZONEINFO} != "no"
619 _zoneinfo= zic tzsetup
622 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
623 date echo egrep find grep ${_install-info} \
624 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
625 test true uname wc ${_zoneinfo}
630 # Distributes everything compiled by a `buildworld'.
634 # Installs everything compiled by a 'buildworld'.
637 # Non-base distributions produced by the base system
638 EXTRA_DISTRIBUTIONS= doc games
639 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
640 EXTRA_DISTRIBUTIONS+= lib32
643 distributeworld installworld: installcheck
644 mkdir -p ${INSTALLTMP}
645 progs=$$(for prog in ${ITOOLS}; do \
646 if progpath=`which $$prog`; then \
649 echo "Required tool $$prog not found in PATH." >&2; \
653 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
654 while read line; do \
656 if [ "$$2 $$3" != "not found" ]; then \
659 echo "Required library $$1 not found." >&2; \
663 cp $$libs $$progs ${INSTALLTMP}
664 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
665 .if make(distributeworld)
666 .for dist in ${EXTRA_DISTRIBUTIONS}
667 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
668 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
669 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
670 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
671 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
672 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
673 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
675 -mkdir ${DESTDIR}/${DISTDIR}/base
676 ${_+_}cd ${.CURDIR}; ${IMAKE} distrib-dirs \
677 DESTDIR=${DESTDIR}/${DISTDIR}/base
679 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
680 ${IMAKEENV} rm -rf ${INSTALLTMP}
681 .if make(distributeworld)
682 .for dist in ${EXTRA_DISTRIBUTIONS}
683 find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete
688 .for dist in base ${EXTRA_DISTRIBUTIONS}
689 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
690 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz .
696 # If you have a build server, you can NFS mount the source and obj directories
697 # and do a 'make reinstall' on the *client* to install new binaries from the
698 # most recent server build.
701 @echo "--------------------------------------------------------------"
702 @echo ">>> Making hierarchy"
703 @echo "--------------------------------------------------------------"
704 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
706 @echo "--------------------------------------------------------------"
707 @echo ">>> Installing everything"
708 @echo "--------------------------------------------------------------"
709 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
710 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
711 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
715 @echo "--------------------------------------------------------------"
716 @echo ">>> Distributing everything"
717 @echo "--------------------------------------------------------------"
718 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
719 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
720 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
724 distrib-dirs distribution:
725 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
728 # buildkernel and installkernel
730 # Which kernels to build and/or install is specified by setting
731 # KERNCONF. If not defined a GENERIC kernel is built/installed.
732 # Only the existing (depending TARGET) config files are used
733 # for building kernels and only the first of these is designated
734 # as the one being installed.
736 # Note that we have to use TARGET instead of TARGET_ARCH when
737 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
738 # be set to cross-build, we have to make sure TARGET is set
741 .if defined(KERNFAST)
746 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
747 .if !defined(KERNCONF) && ${KERNFAST} != "1"
751 .if !defined(KERNCONF) && defined(KERNEL)
755 .if ${TARGET_ARCH} == "powerpc64"
761 INSTKERNNAME?= kernel
763 KERNSRCDIR?= ${.CURDIR}/sys
764 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
765 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
766 KERNCONFDIR?= ${KRNLCONFDIR}
770 .for _kernel in ${KERNCONF}
771 .if exists(${KERNCONFDIR}/${_kernel})
772 BUILDKERNELS+= ${_kernel}
773 .if empty(INSTALLKERNEL)
774 INSTALLKERNEL= ${_kernel}
782 # Builds all kernels defined by BUILDKERNELS.
785 .if empty(BUILDKERNELS)
786 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
789 .if defined(KERNWARN)
790 @echo "--------------------------------------------------------------"
791 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
792 @echo "--------------------------------------------------------------"
796 .for _kernel in ${BUILDKERNELS}
797 @echo "--------------------------------------------------------------"
798 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
799 @echo "--------------------------------------------------------------"
800 @echo "===> ${_kernel}"
801 mkdir -p ${KRNLOBJDIR}
802 .if !defined(NO_KERNELCONFIG)
804 @echo "--------------------------------------------------------------"
805 @echo ">>> stage 1: configuring the kernel"
806 @echo "--------------------------------------------------------------"
809 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
810 ${KERNCONFDIR}/${_kernel}
812 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
814 @echo "--------------------------------------------------------------"
815 @echo ">>> stage 2.1: cleaning up the object tree"
816 @echo "--------------------------------------------------------------"
817 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
819 .if !defined(NO_KERNELOBJ)
821 @echo "--------------------------------------------------------------"
822 @echo ">>> stage 2.2: rebuilding the object tree"
823 @echo "--------------------------------------------------------------"
824 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
827 @echo "--------------------------------------------------------------"
828 @echo ">>> stage 2.3: build tools"
829 @echo "--------------------------------------------------------------"
830 cd ${KRNLOBJDIR}/${_kernel}; \
831 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
832 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS \
833 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
834 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
835 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
836 .for target in obj depend all
837 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
838 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
839 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
842 .if !defined(NO_KERNELDEPEND)
844 @echo "--------------------------------------------------------------"
845 @echo ">>> stage 3.1: making dependencies"
846 @echo "--------------------------------------------------------------"
847 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
850 @echo "--------------------------------------------------------------"
851 @echo ">>> stage 3.2: building everything"
852 @echo "--------------------------------------------------------------"
853 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
854 @echo "--------------------------------------------------------------"
855 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
856 @echo "--------------------------------------------------------------"
860 # installkernel, etc.
862 # Install the kernel defined by INSTALLKERNEL
864 installkernel installkernel.debug \
865 reinstallkernel reinstallkernel.debug: installcheck
866 .if empty(INSTALLKERNEL)
867 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
870 @echo "--------------------------------------------------------------"
871 @echo ">>> Installing kernel ${KERNCONF}"
872 @echo "--------------------------------------------------------------"
873 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
874 ${CROSSENV} PATH=${TMPPATH} \
875 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
877 distributekernel distributekernel.debug:
878 .if empty(INSTALLKERNEL)
879 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
882 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
883 ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
884 DESTDIR=${DESTDIR}/${DISTDIR}/kernel \
885 ${.TARGET:S/distributekernel/install/}
888 ${_+_}cd ${DESTDIR}/${DISTDIR}/kernel; \
889 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
894 # Build the API documentation with doxygen
897 @if [ ! -x `/usr/bin/which doxygen` ]; then \
898 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
901 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
906 # Update the source tree, by running cvsup and/or running cvs to update to the
910 .if defined(SUP_UPDATE)
911 @echo "--------------------------------------------------------------"
912 @echo ">>> Running ${SUP}"
913 @echo "--------------------------------------------------------------"
915 @${SUP} ${SUPFLAGS} ${SUPFILE}
917 .if defined(SUPFILE1)
918 @${SUP} ${SUPFLAGS} ${SUPFILE1}
920 .if defined(SUPFILE2)
921 @${SUP} ${SUPFLAGS} ${SUPFILE2}
923 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
924 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
926 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
927 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
930 .if defined(CVS_UPDATE)
932 if [ -d CVS ] ; then \
933 echo "--------------------------------------------------------------" ; \
934 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
935 echo "--------------------------------------------------------------" ; \
936 echo ${CVS} -R -q update ${CVSFLAGS} ; \
937 ${CVS} -R -q update ${CVSFLAGS} ; \
940 .if defined(SVN_UPDATE)
942 if [ -d .svn ] ; then \
943 echo "--------------------------------------------------------------" ; \
944 echo ">>> Updating ${.CURDIR} using Subversion" ; \
945 echo "--------------------------------------------------------------" ; \
946 echo ${SVN} update ${SVNFLAGS} ; \
947 ${SVN} update ${SVNFLAGS} ; \
952 # ------------------------------------------------------------------------
954 # From here onwards are utility targets used by the 'make world' and
955 # related targets. If your 'world' breaks, you may like to try to fix
956 # the problem and manually run the following targets to attempt to
957 # complete the build. Beware, this is *not* guaranteed to work, you
958 # need to have a pretty good grip on the current state of the system
959 # to attempt to manually finish it. If in doubt, 'make world' again.
963 # legacy: Build compatibility shims for the next three targets
966 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
967 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
970 .for _tool in tools/build
971 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
972 cd ${.CURDIR}/${_tool}; \
973 ${MAKE} DIRPRFX=${_tool}/ obj; \
974 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
975 ${MAKE} DIRPRFX=${_tool}/ depend; \
976 ${MAKE} DIRPRFX=${_tool}/ all; \
977 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
981 # bootstrap-tools: Build tools needed for compatibility
983 .if ${MK_GAMES} != "no"
984 _strfile= games/fortune/strfile
987 .if ${MK_CXX} != "no"
988 _gperf= gnu/usr.bin/gperf
991 .if ${MK_GROFF} != "no"
992 _groff= gnu/usr.bin/groff
995 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
999 .if ${BOOTSTRAPPING} < 800013
1000 _mklocale= usr.bin/mklocale
1003 .if ${BOOTSTRAPPING} < 900002
1007 .if ${BOOTSTRAPPING} < 900006
1012 .if ${BOOTSTRAPPING} < 700018
1013 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1016 .if ${MK_RESCUE} != "no" && \
1017 ${BOOTSTRAPPING} < 700026
1018 _crunchgen= usr.sbin/crunch/crunchgen
1021 .if ${MK_CLANG} != "no"
1023 lib/clang/libllvmsupport \
1024 usr.bin/clang/tblgen
1027 .if ${MK_CDDL} != "no"
1028 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1029 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1032 .if ${MK_FDT} != "no"
1033 _dtc= gnu/usr.bin/dtc
1046 usr.bin/makewhatis \
1056 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1057 cd ${.CURDIR}/${_tool}; \
1058 ${MAKE} DIRPRFX=${_tool}/ obj; \
1059 ${MAKE} DIRPRFX=${_tool}/ depend; \
1060 ${MAKE} DIRPRFX=${_tool}/ all; \
1061 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1065 # build-tools: Build special purpose build tools
1067 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1068 _aicasm= sys/modules/aic7xxx/aicasm
1071 .if !defined(NO_SHARE)
1072 _share= share/syscons/scrnmaps
1075 .if ${MK_KERBEROS} != "no"
1076 _kerberos5_tools= kerberos5/tools
1079 .if ${MK_RESCUE} != "no"
1080 _rescue= rescue/rescue
1088 lib/ncurses/ncurses \
1089 lib/ncurses/ncursesw \
1094 usr.sbin/sysinstall \
1095 usr.bin/mkesdb_static \
1096 usr.bin/mkcsmapper_static
1097 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1098 cd ${.CURDIR}/${_tool}; \
1099 ${MAKE} DIRPRFX=${_tool}/ obj; \
1100 ${MAKE} DIRPRFX=${_tool}/ build-tools
1103 gnu/usr.bin/cc/cc_tools \
1105 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1106 cd ${.CURDIR}/${_tool}; \
1107 ${MAKE} DIRPRFX=${_tool}/ obj; \
1108 ${MAKE} DIRPRFX=${_tool}/ depend; \
1109 ${MAKE} DIRPRFX=${_tool}/ all
1113 # cross-tools: Build cross-building tools
1115 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1116 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1117 _btxld= usr.sbin/btxld
1120 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1121 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1122 _crunchide= usr.sbin/crunch/crunchide
1124 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1125 _kgzip= usr.sbin/kgzip
1129 .if ${MK_CLANG} != "no"
1130 .if ${CC:T:Mclang} == "clang"
1131 _clang= usr.bin/clang
1132 _clang_libs= lib/clang
1140 gnu/usr.bin/binutils \
1142 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1146 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1147 cd ${.CURDIR}/${_tool}; \
1148 ${MAKE} DIRPRFX=${_tool}/ obj; \
1149 ${MAKE} DIRPRFX=${_tool}/ depend; \
1150 ${MAKE} DIRPRFX=${_tool}/ all; \
1151 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1155 # hierarchy - ensure that all the needed directories are present
1158 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
1161 # libraries - build all libraries, and install them under ${DESTDIR}.
1163 # The list of libraries with dependents (${_prebuild_libs}) and their
1164 # interdependencies (__L) are built automatically by the
1165 # ${.CURDIR}/tools/make_libdeps.sh script.
1169 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1170 ${MAKE} -f Makefile.inc1 _startup_libs; \
1171 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1172 ${MAKE} -f Makefile.inc1 _generic_libs;
1175 # static libgcc.a prerequisite for shared libc
1177 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1179 # These dependencies are not automatically generated:
1181 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1182 # all shared libraries for ELF.
1184 _startup_libs= gnu/lib/csu
1185 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1186 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1187 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1188 _startup_libs+= lib/csu/${MACHINE_ARCH}
1190 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1192 _startup_libs+= gnu/lib/libgcc
1193 _startup_libs+= lib/libcompiler_rt
1194 _startup_libs+= lib/libc
1196 gnu/lib/libgcc__L: lib/libc__L
1198 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1199 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1200 ${_kerberos5_lib_libroken} \
1201 lib/libbz2 lib/libcom_err lib/libcrypt \
1202 lib/libexpat lib/libfetch \
1203 ${_lib_libgssapi} ${_lib_libipx} \
1204 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1205 lib/ncurses/ncurses lib/ncurses/ncursesw \
1206 lib/libopie lib/libpam ${_lib_libthr} \
1207 lib/libradius lib/libsbuf lib/libtacplus \
1208 ${_cddl_lib_libumem} \
1209 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1210 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1211 ${_secure_lib_libssl}
1213 .if ${MK_LIBTHR} != "no"
1214 _lib_libthr= lib/libthr
1217 .if ${MK_OFED} != "no"
1218 _ofed_lib= contrib/ofed/usr.lib/
1221 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1223 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1225 .if ${MK_CDDL} != "no"
1226 _cddl_lib_libumem= cddl/lib/libumem
1230 .if ${MK_CRYPT} != "no"
1231 .if ${MK_OPENSSL} != "no"
1232 _secure_lib_libcrypto= secure/lib/libcrypto
1233 _secure_lib_libssl= secure/lib/libssl
1234 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1235 lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L
1236 .if ${MK_OPENSSH} != "no"
1237 _secure_lib_libssh= secure/lib/libssh
1238 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1239 .if ${MK_KERBEROS_SUPPORT} != "no"
1240 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1241 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1242 lib/libmd__L kerberos5/lib/libroken__L
1246 _secure_lib= secure/lib
1249 .if ${MK_GSSAPI} != "no"
1250 _lib_libgssapi= lib/libgssapi
1253 .if ${MK_IPX} != "no"
1254 _lib_libipx= lib/libipx
1257 .if ${MK_KERBEROS} != "no"
1258 _kerberos5_lib= kerberos5/lib
1259 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1260 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1261 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1262 _kerberos5_lib_libroken= kerberos5/lib/libroken
1263 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1266 .if ${MK_NIS} != "no"
1267 _lib_libypclnt= lib/libypclnt
1270 .if ${MK_OPENSSL} == "no"
1271 lib/libfetch__L lib/libradius__L: lib/libmd__L
1274 .for _lib in ${_prereq_libs}
1276 .if exists(${.CURDIR}/${_lib})
1277 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1278 cd ${.CURDIR}/${_lib}; \
1279 ${MAKE} DIRPRFX=${_lib}/ obj; \
1280 ${MAKE} DIRPRFX=${_lib}/ depend; \
1281 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1282 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1286 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1288 .if exists(${.CURDIR}/${_lib})
1289 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1290 cd ${.CURDIR}/${_lib}; \
1291 ${MAKE} DIRPRFX=${_lib}/ obj; \
1292 ${MAKE} DIRPRFX=${_lib}/ depend; \
1293 ${MAKE} DIRPRFX=${_lib}/ all; \
1294 ${MAKE} DIRPRFX=${_lib}/ install
1298 # libpam is special: we need to build static PAM modules before
1299 # static PAM library, and dynamic PAM library before dynamic PAM
1301 lib/libpam__L: .PHONY
1302 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1303 cd ${.CURDIR}/lib/libpam; \
1304 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1305 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1306 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1307 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1309 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1310 _startup_libs: ${_startup_libs:S/$/__L/}
1311 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1312 _generic_libs: ${_generic_libs:S/$/__L/}
1314 .for __target in all clean cleandepend cleandir depend includes obj
1315 .for entry in ${SUBDIR}
1316 ${entry}.${__target}__D: .PHONY
1317 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1318 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1319 edir=${entry}.${MACHINE_ARCH}; \
1320 cd ${.CURDIR}/$${edir}; \
1322 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1324 cd ${.CURDIR}/$${edir}; \
1326 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1328 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1331 .include <bsd.subdir.mk>
1333 .if make(check-old) || make(check-old-dirs) || \
1334 make(check-old-files) || make(check-old-libs) || \
1335 make(delete-old) || make(delete-old-dirs) || \
1336 make(delete-old-files) || make(delete-old-libs)
1339 # check for / delete old files section
1342 .include "ObsoleteFiles.inc"
1344 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1345 else you can not start such an application. Consult UPDATING for more \
1346 information regarding how to cope with the removal/revision bump of a \
1349 .if !defined(BATCH_DELETE_OLD_FILES)
1356 @echo ">>> Removing old files (only deletes safe to delete libs)"
1357 # Ask for every old file if the user really wants to remove it.
1358 # It's annoying, but better safe than sorry.
1359 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1360 # argument list will get too long. Using .for/.endfor make "loops" will make
1361 # the Makefile parser segfault.
1363 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1364 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1365 while read file; do \
1366 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1367 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1368 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1371 # Remove catpages without corresponding manpages.
1373 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1374 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1375 while read catpage; do \
1377 if [ ! -e "$${manpage}" ]; then \
1378 rm ${RM_I} $${catpage} <&3; \
1381 @echo ">>> Old files removed"
1384 @echo ">>> Checking for old files"
1385 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1386 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1387 while read file; do \
1388 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1389 echo "${DESTDIR}/$${file}"; \
1392 # Check for catpages without corresponding manpages.
1393 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1394 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1395 while read catpage; do \
1397 if [ ! -e "$${manpage}" ]; then \
1403 @echo ">>> Removing old libraries"
1404 @echo "${OLD_LIBS_MESSAGE}" | fmt
1406 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1407 -V OLD_LIBS | xargs -n1 | \
1408 while read file; do \
1409 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1410 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1411 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1414 @echo ">>> Old libraries removed"
1417 @echo ">>> Checking for old libraries"
1418 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1419 -V OLD_LIBS | xargs -n1 | \
1420 while read file; do \
1421 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1422 echo "${DESTDIR}/$${file}"; \
1427 @echo ">>> Removing old directories"
1428 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1429 -V OLD_DIRS | xargs -n1 | \
1430 while read dir; do \
1431 if [ -d "${DESTDIR}/$${dir}" ]; then \
1432 rmdir -v "${DESTDIR}/$${dir}" || true; \
1433 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1434 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1437 @echo ">>> Old directories removed"
1440 @echo ">>> Checking for old directories"
1441 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1442 -V OLD_DIRS | xargs -n1 | \
1443 while read dir; do \
1444 if [ -d "${DESTDIR}/$${dir}" ]; then \
1445 echo "${DESTDIR}/$${dir}"; \
1446 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1447 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1451 delete-old: delete-old-files delete-old-dirs
1452 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1454 check-old: check-old-files check-old-libs check-old-dirs
1455 @echo "To remove old files and directories run '${MAKE} delete-old'."
1456 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1461 # showconfig - show build configuration.
1464 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1466 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1467 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1469 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1470 .if exists(${KERNCONFDIR}/${KERNCONF})
1471 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1472 ${KERNCONFDIR}/${KERNCONF}
1478 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1479 DTBOUTPUTPATH= ${.CURDIR}
1483 # Build 'standalone' Device Tree Blob
1486 @if [ "${FDT_DTS_FILE}" = "" ]; then \
1487 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1490 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1491 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1495 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \
1496 echo "WARNING: DTB will be placed in the current working \
1501 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1502 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1506 .if defined(XDEV) && defined(XDEV_ARCH)
1508 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1509 XDEV_CPUTYPE?=${CPUTYPE}
1511 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1514 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1515 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1516 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1517 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1518 CPUTYPE=${XDEV_CPUTYPE}
1520 XDDIR=${XDEV_ARCH}-freebsd
1522 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR}
1524 _SHLIBDIRPREFIX=${XDTP} \
1525 TOOLS_PREFIX=${XDTP}
1527 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1529 CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1530 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1531 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1532 XDDESTDIR=${DESTDIR}${XDTP}
1534 OSREL!= uname -r | sed -e 's/[-(].*//'
1537 .ORDER: xdev-build xdev-install
1538 xdev: xdev-build xdev-install
1540 .ORDER: _xb-build-tools _xb-cross-tools
1541 xdev-build: _xb-build-tools _xb-cross-tools
1544 ${_+_}@cd ${.CURDIR}; \
1545 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1549 gnu/usr.bin/binutils \
1551 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1552 cd ${.CURDIR}/${_tool}; \
1553 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1554 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1555 ${CDMAKE} DIRPRFX=${_tool}/ all
1559 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1560 mkdir -p ${XDDESTDIR}
1561 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1562 -p ${XDDESTDIR} >/dev/null
1563 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1564 -p ${XDDESTDIR}/usr >/dev/null
1565 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1566 -p ${XDDESTDIR}/usr/include >/dev/null
1568 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1569 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1572 @echo "_xi-cross-tools"
1574 gnu/usr.bin/binutils \
1576 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1577 cd ${.CURDIR}/${_tool}; \
1578 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1582 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1583 DESTDIR=${XDDESTDIR}
1586 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1587 DESTDIR=${XDDESTDIR}
1590 ${_+_}cd ${XDDESTDIR}/usr/bin; \
1592 ln -sf ../../${XDTP}/usr/bin/$$i \
1593 ../../../../usr/bin/${XDDIR}-$$i; \
1594 ln -sf ../../${XDTP}/usr/bin/$$i \
1595 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \