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
32 .include <bsd.arch.inc.mk>
34 # We must do share/info early so that installation of info `dir'
35 # entries works correctly. Do it first since it is less likely to
36 # grow dependencies on include and lib than vice versa.
38 # We must do lib/ and libexec/ before bin/, because if installworld
39 # installs a new /bin/sh, the 'make' command will *immediately*
40 # use that new version. And the new (dynamically-linked) /bin/sh
41 # will expect to find appropriate libraries in /lib and /libexec.
43 SUBDIR= share/info lib libexec
45 .if ${MK_GAMES} != "no"
48 .if ${MK_CDDL} != "no"
54 .if ${MK_KERBEROS} != "no"
57 .if ${MK_RESCUE} != "no"
61 .if ${MK_CRYPT} != "no"
64 .if !defined(NO_SHARE)
67 SUBDIR+=sys usr.bin usr.sbin
69 # We must do etc/ last for install/distribute to work.
73 # These are last, since it is nice to at least get the base system
74 # rebuilt before you do them.
75 .for _DIR in ${LOCAL_DIRS}
76 .if exists(${.CURDIR}/${_DIR}/Makefile)
81 .if defined(SUBDIR_OVERRIDE)
82 SUBDIR= ${SUBDIR_OVERRIDE}
88 .if defined(NO_CLEANDIR)
89 CLEANDIR= clean cleandepend
95 CVSFLAGS?= -A -P -d -I!
101 SUPFLAGS+= -h ${SUPHOST}
104 MAKEOBJDIRPREFIX?= /usr/obj
105 .if !defined(OSRELDATE)
106 .if exists(/usr/include/osreldate.h)
107 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
108 /usr/include/osreldate.h
114 .if !defined(VERSION)
116 VERSION+= ${OSRELDATE}
119 # Guess machine architecture from machine type, and vice versa.
120 .if !defined(TARGET_ARCH) && defined(TARGET)
121 TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/:S/mips/mipsel/}
122 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
123 ${TARGET_ARCH} != ${MACHINE_ARCH}
124 TARGET= ${TARGET_ARCH:C/mipse[lb]/mips/:C/armeb/arm}
126 # Legacy names, for a transition period mips:mips -> mipsel:mips
127 .if defined(TARGET) && defined(TARGET_ARCH) && \
128 ${TARGET_ARCH} == "mips" && ${TARGET} == "mips"
129 .warning "TARGET_ARCH of mips is deprecated in favor of mipsel or mipseb"
130 .if defined(TARGET_BIG_ENDIAN)
136 # arm with TARGET_BIG_ENDIAN -> armeb
137 .if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
138 .warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated. use armeb"
141 # Otherwise, default to current machine type and architecture.
143 TARGET_ARCH?= ${MACHINE_ARCH}
145 KNOWN_ARCHES?= amd64 arm armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/mips powerpc powerpc64/powerpc sparc64 sparc64/sun4v
146 .if ${TARGET} == ${TARGET_ARCH}
149 _t= ${TARGET_ARCH}/${TARGET}
152 .if empty(KNOWN_ARCHES:M${_t})
153 .error Unknown target ${TARGET_ARCH}:${TARGET}.
157 .if ${TARGET} == ${MACHINE}
158 TARGET_CPUTYPE?=${CPUTYPE}
163 .if !empty(TARGET_CPUTYPE)
164 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
166 _TARGET_CPUTYPE=dummy
168 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
169 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
170 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
171 .error CPUTYPE global should be set with ?=.
174 BUILD_ARCH!= uname -p
175 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
176 .error To cross-build, set TARGET_ARCH.
179 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
180 OBJTREE= ${MAKEOBJDIRPREFIX}
182 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
184 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
185 # /usr/games added for fortune which depend on strfile
186 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
187 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
188 STRICTTMPPATH= ${BPATH}:${XPATH}
189 TMPPATH= ${STRICTTMPPATH}:${PATH}
192 # Avoid running mktemp(1) unless actually needed.
193 # It may not be functional, e.g., due to new ABI
194 # when in the middle of installing over this system.
196 .if make(distributeworld) || make(installworld)
197 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
201 # Building a world goes through the following stages
203 # 1. legacy stage [BMAKE]
204 # This stage is responsible for creating compatibility
205 # shims that are needed by the bootstrap-tools,
206 # build-tools and cross-tools stages.
207 # 1. bootstrap-tools stage [BMAKE]
208 # This stage is responsible for creating programs that
209 # are needed for backward compatibility reasons. They
210 # are not built as cross-tools.
211 # 2. build-tools stage [TMAKE]
212 # This stage is responsible for creating the object
213 # tree and building any tools that are needed during
215 # 3. cross-tools stage [XMAKE]
216 # This stage is responsible for creating any tools that
217 # are needed for cross-builds. A cross-compiler is one
219 # 4. world stage [WMAKE]
220 # This stage actually builds the world.
221 # 5. install stage (optional) [IMAKE]
222 # This stage installs a previously built world.
227 # Common environment for world related stages
228 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
229 MACHINE_ARCH=${TARGET_ARCH} \
231 CPUTYPE=${TARGET_CPUTYPE} \
232 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
233 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
234 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
235 .if ${OSRELDATE} < 700044
236 CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib
239 # bootstrap-tools stage
240 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
241 PATH=${BPATH}:${PATH} \
242 WORLDTMP=${WORLDTMP} \
243 VERSION="${VERSION}" \
244 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
245 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
246 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
248 BOOTSTRAPPING=${OSRELDATE} \
250 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
251 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
252 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
255 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
256 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
257 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
260 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
264 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
265 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
269 WMAKEENV= ${CROSSENV} \
270 _SHLIBDIRPREFIX=${WORLDTMP} \
271 VERSION="${VERSION}" \
272 INSTALL="sh ${.CURDIR}/tools/install.sh" \
274 .if ${MK_CDDL} == "no"
277 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
279 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
281 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
283 .if ${TARGET_ARCH} == "amd64"
284 .if empty(TARGET_CPUTYPE)
285 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
287 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
289 LIB32CPUFLAGS+= -mfancy-math-387
290 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
291 MACHINE_CPU="i686 mmx sse sse2" \
292 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
295 .elif ${TARGET_ARCH} == "powerpc64"
296 .if empty(TARGET_CPUTYPE)
297 LIB32CPUFLAGS= -mcpu=powerpc
299 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
301 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc \
302 LD="${LD} -m elf32ppc"
306 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
307 -isystem ${LIB32TMP}/usr/include/ \
308 -L${LIB32TMP}/usr/lib32 \
309 -B${LIB32TMP}/usr/lib32
311 # Yes, the flags are redundant.
312 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
313 _SHLIBDIRPREFIX=${LIB32TMP} \
314 VERSION="${VERSION}" \
315 INSTALL="sh ${.CURDIR}/tools/install.sh" \
317 CC="${CC} ${LIB32FLAGS}" \
318 CXX="${CXX} ${LIB32FLAGS}" \
319 OBJC="${OBJC} ${LIB32FLAGS}" \
323 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
324 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
325 -DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
326 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
330 IMAKEENV= ${CROSSENV}
331 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
332 .if empty(.MAKEFLAGS:M-n)
333 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
334 LD_LIBRARY_PATH=${INSTALLTMP} \
335 PATH_LOCALE=${INSTALLTMP}/locale
336 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
338 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
342 KMAKEENV= ${WMAKEENV}
343 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
348 # Attempt to rebuild the entire system, with reasonable chance of
349 # success, regardless of how old your existing system is.
352 .if ${.CURDIR:C/[^,]//g} != ""
353 # The m4 build of sendmail files doesn't like it if ',' is used
354 # anywhere in the path of it's files.
356 @echo "*** Error: path to source tree contains a comma ','"
361 @echo "--------------------------------------------------------------"
362 @echo ">>> Rebuilding the temporary build tree"
363 @echo "--------------------------------------------------------------"
364 .if !defined(NO_CLEAN)
366 .if defined(LIB32TMP)
370 rm -rf ${WORLDTMP}/legacy/usr/include
371 # XXX - These three can depend on any header file.
372 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
373 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
374 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
378 mkdir -p ${WORLDTMP}/${_dir}
380 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
381 -p ${WORLDTMP}/legacy/usr >/dev/null
382 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
383 -p ${WORLDTMP}/usr >/dev/null
384 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
385 -p ${WORLDTMP}/usr/include >/dev/null
386 ln -sf ${.CURDIR}/sys ${WORLDTMP}
387 .if ${MK_BIND_LIBS} != "no"
388 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
389 -p ${WORLDTMP}/usr/include >/dev/null
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 1.1: legacy release compatibility shims"
395 @echo "--------------------------------------------------------------"
396 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
399 @echo "--------------------------------------------------------------"
400 @echo ">>> stage 1.2: bootstrap tools"
401 @echo "--------------------------------------------------------------"
402 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
404 .if !defined(NO_CLEAN)
406 @echo "--------------------------------------------------------------"
407 @echo ">>> stage 2.1: cleaning up the object tree"
408 @echo "--------------------------------------------------------------"
409 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
410 .if defined(LIB32TMP)
411 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
416 @echo "--------------------------------------------------------------"
417 @echo ">>> stage 2.2: rebuilding the object tree"
418 @echo "--------------------------------------------------------------"
419 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
422 @echo "--------------------------------------------------------------"
423 @echo ">>> stage 2.3: build tools"
424 @echo "--------------------------------------------------------------"
425 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
428 @echo "--------------------------------------------------------------"
429 @echo ">>> stage 3: cross tools"
430 @echo "--------------------------------------------------------------"
431 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
434 @echo "--------------------------------------------------------------"
435 @echo ">>> stage 4.1: building includes"
436 @echo "--------------------------------------------------------------"
437 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
440 @echo "--------------------------------------------------------------"
441 @echo ">>> stage 4.2: building libraries"
442 @echo "--------------------------------------------------------------"
443 ${_+_}cd ${.CURDIR}; \
444 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
445 -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
448 @echo "--------------------------------------------------------------"
449 @echo ">>> stage 4.3: make dependencies"
450 @echo "--------------------------------------------------------------"
451 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
454 @echo "--------------------------------------------------------------"
455 @echo ">>> stage 4.4: building everything"
456 @echo "--------------------------------------------------------------"
457 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
458 .if defined(LIB32TMP)
461 @echo "--------------------------------------------------------------"
462 @echo ">>> stage 5.1: building 32 bit shim libraries"
463 @echo "--------------------------------------------------------------"
464 mkdir -p ${LIB32TMP}/usr/lib32
465 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
466 -p ${LIB32TMP}/usr >/dev/null
467 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
468 -p ${LIB32TMP}/usr/include >/dev/null
470 ln -sf ${.CURDIR}/sys ${WORLDTMP}
471 .if ${MK_KERBEROS} != "no"
472 .for _t in obj depend all
473 cd ${.CURDIR}/kerberos5/tools; \
474 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
478 .for _t in obj includes
479 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
480 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
481 .if ${MK_CDDL} != "no"
482 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
484 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
485 .if ${MK_CRYPT} != "no"
486 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
488 .if ${MK_KERBEROS} != "no"
489 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
492 .for _dir in usr.bin/lex/lib
493 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
495 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
496 cd ${.CURDIR}/${_dir}; \
497 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
501 ${LIB32WMAKE} -f Makefile.inc1 libraries
502 .for _t in obj depend all
503 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
504 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
507 distribute32 install32:
508 .if make(distribute32)
509 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
510 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace # XXX add to mtree
512 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
513 mkdir -p ${DESTDIR}/usr/lib32/dtrace # XXX add to mtree
515 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
516 .if ${MK_CDDL} != "no"
517 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
519 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
520 .if ${MK_CRYPT} != "no"
521 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
523 .if ${MK_KERBEROS} != "no"
524 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
526 cd ${.CURDIR}/libexec/rtld-elf; \
527 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
528 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
532 .if !defined(SUBDIR_OVERRIDE)
533 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
535 WMAKE_TGTS+= _cleanobj _obj _build-tools
536 .if !defined(SUBDIR_OVERRIDE)
537 WMAKE_TGTS+= _cross-tools
539 WMAKE_TGTS+= _includes _libraries _depend everything
540 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
544 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
545 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
548 @echo "--------------------------------------------------------------"
549 @echo ">>> World build started on `LC_ALL=C date`"
550 @echo "--------------------------------------------------------------"
554 @echo "--------------------------------------------------------------"
555 @echo ">>> World build completed on `LC_ALL=C date`"
556 @echo "--------------------------------------------------------------"
559 # We need to have this as a target because the indirection between Makefile
560 # and Makefile.inc1 causes the correct PATH to be used, rather than a
561 # modification of the current environment's PATH. In addition, we need
562 # to quote multiword values.
568 @echo Entering world for ${TARGET_ARCH}:${TARGET}
569 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
571 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
572 toolchain: ${TOOLCHAIN_TGTS}
573 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
578 # Checks to be sure system is ready for installworld/installkernel.
583 # Require DESTDIR to be set if installing for a different architecture.
585 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
586 .if !make(distributeworld)
587 installcheck: installcheck_DESTDIR
588 installcheck_DESTDIR:
589 .if !defined(DESTDIR) || empty(DESTDIR)
590 @echo "ERROR: Please set DESTDIR!"; \
597 # Check for missing UIDs/GIDs.
601 .if ${MK_SENDMAIL} != "no"
607 CHECK_GIDS+= proxy authpf
609 installcheck: installcheck_UGID
611 .for uid in ${CHECK_UIDS}
612 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
613 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
617 .for gid in ${CHECK_GIDS}
618 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
619 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
625 # Required install tools to be saved in a scratch dir for safety.
627 .if ${MK_INFO} != "no"
628 _install-info= install-info
630 .if ${MK_ZONEINFO} != "no"
631 _zoneinfo= zic tzsetup
634 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
635 date echo egrep find grep ${_install-info} \
636 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
637 test true uname wc ${_zoneinfo}
642 # Distributes everything compiled by a `buildworld'.
646 # Installs everything compiled by a 'buildworld'.
648 distributeworld installworld: installcheck
649 mkdir -p ${INSTALLTMP}
650 progs=$$(for prog in ${ITOOLS}; do \
651 if progpath=`which $$prog`; then \
654 echo "Required tool $$prog not found in PATH." >&2; \
658 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
659 while read line; do \
661 if [ "$$2 $$3" != "not found" ]; then \
664 echo "Required library $$1 not found." >&2; \
668 cp $$libs $$progs ${INSTALLTMP}
669 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
670 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
671 ${IMAKEENV} rm -rf ${INSTALLTMP}
676 # If you have a build server, you can NFS mount the source and obj directories
677 # and do a 'make reinstall' on the *client* to install new binaries from the
678 # most recent server build.
681 @echo "--------------------------------------------------------------"
682 @echo ">>> Making hierarchy"
683 @echo "--------------------------------------------------------------"
684 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
686 @echo "--------------------------------------------------------------"
687 @echo ">>> Installing everything"
688 @echo "--------------------------------------------------------------"
689 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
690 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
691 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
695 @echo "--------------------------------------------------------------"
696 @echo ">>> Distributing everything"
697 @echo "--------------------------------------------------------------"
698 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
699 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
700 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
704 distrib-dirs distribution:
705 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
708 # buildkernel and installkernel
710 # Which kernels to build and/or install is specified by setting
711 # KERNCONF. If not defined a GENERIC kernel is built/installed.
712 # Only the existing (depending TARGET) config files are used
713 # for building kernels and only the first of these is designated
714 # as the one being installed.
716 # Note that we have to use TARGET instead of TARGET_ARCH when
717 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
718 # be set to cross-build, we have to make sure TARGET is set
721 .if defined(KERNFAST)
726 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
727 .if !defined(KERNCONF) && ${KERNFAST} != "1"
731 .if !defined(KERNCONF) && defined(KERNEL)
735 .if ${TARGET_ARCH} == "powerpc64"
741 INSTKERNNAME?= kernel
743 KERNSRCDIR?= ${.CURDIR}/sys
744 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
745 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
746 KERNCONFDIR?= ${KRNLCONFDIR}
750 .for _kernel in ${KERNCONF}
751 .if exists(${KERNCONFDIR}/${_kernel})
752 BUILDKERNELS+= ${_kernel}
753 .if empty(INSTALLKERNEL)
754 INSTALLKERNEL= ${_kernel}
762 # Builds all kernels defined by BUILDKERNELS.
765 .if empty(BUILDKERNELS)
766 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
769 .if defined(KERNWARN)
770 @echo "--------------------------------------------------------------"
771 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
772 @echo "--------------------------------------------------------------"
776 .for _kernel in ${BUILDKERNELS}
777 @echo "--------------------------------------------------------------"
778 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
779 @echo "--------------------------------------------------------------"
780 @echo "===> ${_kernel}"
781 mkdir -p ${KRNLOBJDIR}
782 .if !defined(NO_KERNELCONFIG)
784 @echo "--------------------------------------------------------------"
785 @echo ">>> stage 1: configuring the kernel"
786 @echo "--------------------------------------------------------------"
789 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
790 ${KERNCONFDIR}/${_kernel}
792 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
794 @echo "--------------------------------------------------------------"
795 @echo ">>> stage 2.1: cleaning up the object tree"
796 @echo "--------------------------------------------------------------"
797 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
799 .if !defined(NO_KERNELOBJ)
801 @echo "--------------------------------------------------------------"
802 @echo ">>> stage 2.2: rebuilding the object tree"
803 @echo "--------------------------------------------------------------"
804 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
807 @echo "--------------------------------------------------------------"
808 @echo ">>> stage 2.3: build tools"
809 @echo "--------------------------------------------------------------"
810 cd ${KRNLOBJDIR}/${_kernel}; \
811 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
812 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS \
813 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
814 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
815 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
816 .for target in obj depend all
817 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
818 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
819 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
822 .if !defined(NO_KERNELDEPEND)
824 @echo "--------------------------------------------------------------"
825 @echo ">>> stage 3.1: making dependencies"
826 @echo "--------------------------------------------------------------"
827 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
830 @echo "--------------------------------------------------------------"
831 @echo ">>> stage 3.2: building everything"
832 @echo "--------------------------------------------------------------"
833 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
834 @echo "--------------------------------------------------------------"
835 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
836 @echo "--------------------------------------------------------------"
840 # installkernel, etc.
842 # Install the kernel defined by INSTALLKERNEL
844 installkernel installkernel.debug \
845 reinstallkernel reinstallkernel.debug: installcheck
846 .if empty(INSTALLKERNEL)
847 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
850 @echo "--------------------------------------------------------------"
851 @echo ">>> Installing kernel"
852 @echo "--------------------------------------------------------------"
853 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
854 ${CROSSENV} PATH=${TMPPATH} \
855 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
860 # Build the API documentation with doxygen
863 @if [ ! -x `/usr/bin/which doxygen` ]; then \
864 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
867 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
872 # Update the source tree, by running cvsup and/or running cvs to update to the
876 .if defined(SUP_UPDATE)
877 @echo "--------------------------------------------------------------"
878 @echo ">>> Running ${SUP}"
879 @echo "--------------------------------------------------------------"
881 @${SUP} ${SUPFLAGS} ${SUPFILE}
883 .if defined(SUPFILE1)
884 @${SUP} ${SUPFLAGS} ${SUPFILE1}
886 .if defined(SUPFILE2)
887 @${SUP} ${SUPFLAGS} ${SUPFILE2}
889 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
890 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
892 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
893 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
896 .if defined(CVS_UPDATE)
898 if [ -d CVS ] ; then \
899 echo "--------------------------------------------------------------" ; \
900 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
901 echo "--------------------------------------------------------------" ; \
902 echo ${CVS} -R -q update ${CVSFLAGS} ; \
903 ${CVS} -R -q update ${CVSFLAGS} ; \
906 .if defined(SVN_UPDATE)
908 if [ -d .svn ] ; then \
909 echo "--------------------------------------------------------------" ; \
910 echo ">>> Updating ${.CURDIR} using Subversion" ; \
911 echo "--------------------------------------------------------------" ; \
912 echo ${SVN} update ${SVNFLAGS} ; \
913 ${SVN} update ${SVNFLAGS} ; \
918 # ------------------------------------------------------------------------
920 # From here onwards are utility targets used by the 'make world' and
921 # related targets. If your 'world' breaks, you may like to try to fix
922 # the problem and manually run the following targets to attempt to
923 # complete the build. Beware, this is *not* guaranteed to work, you
924 # need to have a pretty good grip on the current state of the system
925 # to attempt to manually finish it. If in doubt, 'make world' again.
929 # legacy: Build compatibility shims for the next three targets
932 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
933 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
936 .for _tool in tools/build
937 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
938 cd ${.CURDIR}/${_tool}; \
939 ${MAKE} DIRPRFX=${_tool}/ obj; \
940 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
941 ${MAKE} DIRPRFX=${_tool}/ depend; \
942 ${MAKE} DIRPRFX=${_tool}/ all; \
943 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
947 # bootstrap-tools: Build tools needed for compatibility
949 .if ${MK_GAMES} != "no"
950 _strfile= games/fortune/strfile
953 .if ${MK_CXX} != "no"
954 _gperf= gnu/usr.bin/gperf
955 .if ${BOOTSTRAPPING} < 700004
956 _groff= gnu/usr.bin/groff
958 _groff= gnu/usr.bin/groff/tmac
962 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
966 .if ${BOOTSTRAPPING} < 800013
967 _mklocale= usr.bin/mklocale
970 .if ${BOOTSTRAPPING} < 900002
974 .if ${BOOTSTRAPPING} < 900006
979 .if ${BOOTSTRAPPING} < 700018
980 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
983 .if ${MK_RESCUE} != "no" && \
984 ${BOOTSTRAPPING} < 700026
985 _crunchgen= usr.sbin/crunch/crunchgen
988 # XXX: There is no way to specify bootstrap tools depending on MK-flags
989 # with different per-architecture default values. Always build tblgen.
991 lib/clang/libllvmsupport \
992 lib/clang/libllvmsystem \
995 .if ${MK_CDDL} != "no"
996 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
997 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1000 .if ${MK_FDT} != "no"
1001 _dtc= gnu/usr.bin/dtc
1014 usr.bin/makewhatis \
1024 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1025 cd ${.CURDIR}/${_tool}; \
1026 ${MAKE} DIRPRFX=${_tool}/ obj; \
1027 ${MAKE} DIRPRFX=${_tool}/ depend; \
1028 ${MAKE} DIRPRFX=${_tool}/ all; \
1029 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1033 # build-tools: Build special purpose build tools
1035 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1036 _aicasm= sys/modules/aic7xxx/aicasm
1039 .if !defined(NO_SHARE)
1040 _share= share/syscons/scrnmaps
1043 .if ${MK_KERBEROS} != "no"
1044 _kerberos5_tools= kerberos5/tools
1047 .if ${MK_RESCUE} != "no"
1048 _rescue= rescue/rescue
1056 lib/ncurses/ncurses \
1057 lib/ncurses/ncursesw \
1063 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1064 cd ${.CURDIR}/${_tool}; \
1065 ${MAKE} DIRPRFX=${_tool}/ obj; \
1066 ${MAKE} DIRPRFX=${_tool}/ build-tools
1069 gnu/usr.bin/cc/cc_tools \
1071 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1072 cd ${.CURDIR}/${_tool}; \
1073 ${MAKE} DIRPRFX=${_tool}/ obj; \
1074 ${MAKE} DIRPRFX=${_tool}/ depend; \
1075 ${MAKE} DIRPRFX=${_tool}/ all
1079 # cross-tools: Build cross-building tools
1081 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1082 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1083 _btxld= usr.sbin/btxld
1086 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1087 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1088 _crunchide= usr.sbin/crunch/crunchide
1090 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1091 _kgzip= usr.sbin/kgzip
1095 .if ${CC:T:Mclang} == "clang"
1096 _clang= usr.bin/clang
1097 _clang_libs= lib/clang
1104 gnu/usr.bin/binutils \
1106 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1110 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1111 cd ${.CURDIR}/${_tool}; \
1112 ${MAKE} DIRPRFX=${_tool}/ obj; \
1113 ${MAKE} DIRPRFX=${_tool}/ depend; \
1114 ${MAKE} DIRPRFX=${_tool}/ all; \
1115 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1119 # hierarchy - ensure that all the needed directories are present
1122 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
1125 # libraries - build all libraries, and install them under ${DESTDIR}.
1127 # The list of libraries with dependents (${_prebuild_libs}) and their
1128 # interdependencies (__L) are built automatically by the
1129 # ${.CURDIR}/tools/make_libdeps.sh script.
1133 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1134 ${MAKE} -f Makefile.inc1 _startup_libs; \
1135 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1136 ${MAKE} -f Makefile.inc1 _generic_libs;
1139 # static libgcc.a prerequisite for shared libc
1141 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1143 # These dependencies are not automatically generated:
1145 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1146 # all shared libraries for ELF.
1148 _startup_libs= gnu/lib/csu
1149 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1150 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1151 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1152 _startup_libs+= lib/csu/${MACHINE_ARCH}
1154 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1156 _startup_libs+= gnu/lib/libgcc
1157 _startup_libs+= lib/libcompiler_rt
1158 _startup_libs+= lib/libc
1160 gnu/lib/libgcc__L: lib/libc__L
1162 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
1163 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1164 ${_kerberos5_lib_libroken} \
1165 lib/libbz2 lib/libcom_err lib/libcrypt \
1166 lib/libexpat lib/libfetch \
1167 ${_lib_libgssapi} ${_lib_libipx} \
1168 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1169 lib/ncurses/ncurses lib/ncurses/ncursesw \
1170 lib/libopie lib/libpam ${_lib_libthr} \
1171 lib/libradius lib/libsbuf lib/libtacplus \
1172 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1173 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1174 ${_secure_lib_libssl}
1176 .if ${MK_LIBTHR} != "no"
1177 _lib_libthr= lib/libthr
1180 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1182 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1184 .if ${MK_CDDL} != "no"
1188 .if ${MK_CRYPT} != "no"
1189 .if ${MK_OPENSSL} != "no"
1190 _secure_lib_libcrypto= secure/lib/libcrypto
1191 _secure_lib_libssl= secure/lib/libssl
1192 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1193 lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L
1194 .if ${MK_OPENSSH} != "no"
1195 _secure_lib_libssh= secure/lib/libssh
1196 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1197 .if ${MK_KERBEROS_SUPPORT} != "no"
1198 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1199 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1200 lib/libmd__L kerberos5/lib/libroken__L
1204 _secure_lib= secure/lib
1207 .if ${MK_GSSAPI} != "no"
1208 _lib_libgssapi= lib/libgssapi
1211 .if ${MK_IPX} != "no"
1212 _lib_libipx= lib/libipx
1215 .if ${MK_KERBEROS} != "no"
1216 _kerberos5_lib= kerberos5/lib
1217 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1218 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1219 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1220 _kerberos5_lib_libroken= kerberos5/lib/libroken
1221 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1224 .if ${MK_NIS} != "no"
1225 _lib_libypclnt= lib/libypclnt
1228 .if ${MK_OPENSSL} == "no"
1229 lib/libfetch__L lib/libradius__L: lib/libmd__L
1232 .for _lib in ${_prereq_libs}
1234 .if exists(${.CURDIR}/${_lib})
1235 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1236 cd ${.CURDIR}/${_lib}; \
1237 ${MAKE} DIRPRFX=${_lib}/ obj; \
1238 ${MAKE} DIRPRFX=${_lib}/ depend; \
1239 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1240 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1244 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1246 .if exists(${.CURDIR}/${_lib})
1247 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1248 cd ${.CURDIR}/${_lib}; \
1249 ${MAKE} DIRPRFX=${_lib}/ obj; \
1250 ${MAKE} DIRPRFX=${_lib}/ depend; \
1251 ${MAKE} DIRPRFX=${_lib}/ all; \
1252 ${MAKE} DIRPRFX=${_lib}/ install
1256 # libpam is special: we need to build static PAM modules before
1257 # static PAM library, and dynamic PAM library before dynamic PAM
1259 lib/libpam__L: .PHONY
1260 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1261 cd ${.CURDIR}/lib/libpam; \
1262 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1263 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1264 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1265 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1267 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1268 _startup_libs: ${_startup_libs:S/$/__L/}
1269 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1270 _generic_libs: ${_generic_libs:S/$/__L/}
1272 .for __target in all clean cleandepend cleandir depend includes obj
1273 .for entry in ${SUBDIR}
1274 ${entry}.${__target}__D: .PHONY
1275 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1276 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1277 edir=${entry}.${MACHINE_ARCH}; \
1278 cd ${.CURDIR}/$${edir}; \
1280 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1282 cd ${.CURDIR}/$${edir}; \
1284 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1286 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1289 .include <bsd.subdir.mk>
1291 .if make(check-old) || make(check-old-dirs) || \
1292 make(check-old-files) || make(check-old-libs) || \
1293 make(delete-old) || make(delete-old-dirs) || \
1294 make(delete-old-files) || make(delete-old-libs)
1297 # check for / delete old files section
1300 .include "ObsoleteFiles.inc"
1302 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1303 else you can not start such an application. Consult UPDATING for more \
1304 information regarding how to cope with the removal/revision bump of a \
1307 .if !defined(BATCH_DELETE_OLD_FILES)
1314 @echo ">>> Removing old files (only deletes safe to delete libs)"
1315 # Ask for every old file if the user really wants to remove it.
1316 # It's annoying, but better safe than sorry.
1317 @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \
1318 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1319 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1320 rm ${RM_I} "${DESTDIR}/$${file}"; \
1323 # Remove catpages without corresponding manpages.
1325 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1326 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1327 while read catpage; do \
1329 if [ ! -e "$${manpage}" ]; then \
1330 rm ${RM_I} $${catpage} <&3 ; \
1333 @echo ">>> Old files removed"
1336 @echo ">>> Checking for old files"
1337 @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \
1338 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1339 echo "${DESTDIR}/$${file}"; \
1342 # Check for catpages without corresponding manpages.
1343 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1344 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1345 while read catpage; do \
1347 if [ ! -e "$${manpage}" ]; then \
1348 echo $${catpage} ; \
1353 @echo ">>> Removing old libraries"
1354 @echo "${OLD_LIBS_MESSAGE}" | fmt
1355 @for file in ${OLD_LIBS}; do \
1356 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1357 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1358 rm ${RM_I} "${DESTDIR}/$${file}"; \
1361 @echo ">>> Old libraries removed"
1364 @echo ">>> Checking for old libraries"
1365 @for file in ${OLD_LIBS}; do \
1366 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1367 echo "${DESTDIR}/$${file}"; \
1372 @echo ">>> Removing old directories"
1373 @for dir in ${OLD_DIRS}; do \
1374 if [ -d "${DESTDIR}/$${dir}" ]; then \
1375 rmdir -v "${DESTDIR}/$${dir}" || true; \
1376 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1377 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1380 @echo ">>> Old directories removed"
1383 @echo ">>> Checking for old directories"
1384 @for dir in ${OLD_DIRS}; do \
1385 if [ -d "${DESTDIR}/$${dir}" ]; then \
1386 echo "${DESTDIR}/$${dir}"; \
1387 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1388 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1392 delete-old: delete-old-files delete-old-dirs
1393 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1395 check-old: check-old-files check-old-libs check-old-dirs
1396 @echo "To remove old files and directories run '${MAKE} delete-old'."
1397 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1402 # showconfig - show build configuration.
1405 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1410 .if defined(XDEV) && defined(XDEV_ARCH)
1412 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1413 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1414 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS
1416 XDDIR=${XDEV}-freebsd
1418 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1419 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH}
1421 _SHLIBDIRPREFIX=${XDTP} \
1422 TOOLS_PREFIX=${XDTP}
1424 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1426 CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1427 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1428 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1429 XDDESTDIR=${DESTDIR}${XDTP}
1431 OSREL!= uname -r | sed -e 's/[-(].*//'
1434 .ORDER: xdev-build xdev-install
1435 xdev: xdev-build xdev-install
1437 .ORDER: _xb-build-tools _xb-cross-tools
1438 xdev-build: _xb-build-tools _xb-cross-tools
1441 ${_+_}cd ${.CURDIR}; \
1442 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1446 gnu/usr.bin/binutils \
1448 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1449 cd ${.CURDIR}/${_tool}; \
1450 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1451 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1452 ${CDMAKE} DIRPRFX=${_tool}/ all
1456 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1457 mkdir -p ${XDDESTDIR}
1458 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1459 -p ${XDDESTDIR} >/dev/null
1460 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1461 -p ${XDDESTDIR}/usr >/dev/null
1462 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1463 -p ${XDDESTDIR}/usr/include >/dev/null
1465 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1466 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1469 @echo "_xi-cross-tools"
1471 gnu/usr.bin/binutils \
1473 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1474 cd ${.CURDIR}/${_tool}; \
1475 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1479 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1480 DESTDIR=${XDDESTDIR}
1483 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1484 DESTDIR=${XDDESTDIR}
1487 ${_+_}cd ${XDDESTDIR}/usr/bin; \
1489 ln -sf ../../${XDTP}/usr/bin/$$i \
1490 ../../../../usr/bin/${XDDIR}-$$i; \
1491 ln -sf ../../${XDTP}/usr/bin/$$i \
1492 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
1496 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1497 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1499 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1500 .if exists(${KERNCONFDIR}/${KERNCONF})
1501 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1502 ${KERNCONFDIR}/${KERNCONF}
1508 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1509 DTBOUTPUTPATH= ${.CURDIR}
1513 # Build 'standalone' Device Tree Blob
1516 @if [ "${FDT_DTS_FILE}" = "" ]; then \
1517 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1520 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1521 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1525 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \
1526 echo "WARNING: DTB will be placed in the current working \
1531 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1532 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}