4 # Make command line options:
5 # -DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6 # -DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7 # -DNO_RESCUE do not build rescue binaries
8 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9 # -DNO_CLEAN do not clean at all
10 # -DNO_CRYPT will prevent building of crypt versions
11 # -DNO_MAN do not build the manual pages
12 # -DNO_NLS do not build Native Language Support files
13 # -DNO_PROFILE do not build profiled libraries
14 # -DNO_GAMES do not go into games subdir
15 # -DNO_SHARE do not go into share subdir
16 # -DNO_INFO do not make or install info files
17 # -DNO_LIBC_R do not build libc_r.
18 # -DNO_FORTRAN do not build g77 and related libraries.
19 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
20 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
21 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
22 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
23 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
24 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
25 # TARGET_ARCH="arch" to crossbuild world to a different arch
28 # The intended user-driven targets are:
29 # buildworld - rebuild *everything*, including glue to help do upgrades
30 # installworld- install everything built by "buildworld"
31 # update - convenient way to update your source tree (eg: cvsup/cvs)
33 # Standard targets (not defined here) are documented in the makefiles in
34 # /usr/share/mk. These include:
35 # obj depend all install clean cleandepend cleanobj
37 # We must do share/info early so that installation of info `dir'
38 # entries works correctly. Do it first since it is less likely to
39 # grow dependencies on include and lib than vice versa.
41 # We must do lib and libexec before bin, because if installworld
42 # installs a new /bin/sh, the 'make' command will *immediately*
43 # use that new version. And the new (dynamically-linked) /bin/sh
44 # will expect to find appropriate libraries in /lib and /libexec.
46 # We must do etc last for install/distribute to work.
48 SUBDIR= share/info include lib libexec bin
49 .if !defined(NO_GAMES)
53 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
56 .if !defined(NO_RESCUE)
60 .if !defined(NO_CRYPT)
63 .if !defined(NO_SHARE)
66 SUBDIR+=sys usr.bin usr.sbin etc
68 # These are last, since it is nice to at least get the base system
69 # rebuilt before you do them.
70 .for _DIR in ${LOCAL_DIRS}
71 .if exists(${.CURDIR}/${_DIR}/Makefile)
76 .if defined(SUBDIR_OVERRIDE)
77 SUBDIR= ${SUBDIR_OVERRIDE}
83 .if defined(NO_CLEANDIR)
84 CLEANDIR= clean cleandepend
90 CVSFLAGS?= -A -P -d -I!
91 SUP?= /usr/local/bin/cvsup
92 SUPFLAGS?= -g -L 2 -P -
94 SUPFLAGS+= -h ${SUPHOST}
97 MAKEOBJDIRPREFIX?= /usr/obj
98 .if !defined(OSRELDATE)
99 .if exists(/usr/include/osreldate.h)
100 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
101 /usr/include/osreldate.h
106 TARGET_ARCH?= ${MACHINE_ARCH}
107 .if ${TARGET_ARCH} == ${MACHINE_ARCH}
109 TARGET_CPUTYPE?=${CPUTYPE}
111 TARGET?= ${TARGET_ARCH}
114 .if !empty(TARGET_CPUTYPE)
115 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
117 _TARGET_CPUTYPE=dummy
119 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
120 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
121 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
122 .error CPUTYPE global should be set with ?=.
125 BUILD_ARCH!= sysctl -n hw.machine_arch
126 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
127 .error To cross-build, set TARGET_ARCH.
130 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
131 OBJTREE= ${MAKEOBJDIRPREFIX}
133 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
135 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
136 # /usr/games added for fortune which depend on strfile
137 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
138 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
139 STRICTTMPPATH= ${BPATH}:${XPATH}
140 TMPPATH= ${STRICTTMPPATH}:${PATH}
142 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
145 # Building a world goes through the following stages
147 # 1. legacy stage [BMAKE]
148 # This stage is responsible for creating compatibility
149 # shims that are needed by the bootstrap-tools,
150 # build-tools and cross-tools stages.
151 # 1. bootstrap-tools stage [BMAKE]
152 # This stage is responsible for creating programs that
153 # are needed for backward compatibility reasons. They
154 # are not built as cross-tools.
155 # 2. build-tools stage [TMAKE]
156 # This stage is responsible for creating the object
157 # tree and building any tools that are needed during
159 # 3. cross-tools stage [XMAKE]
160 # This stage is responsible for creating any tools that
161 # are needed for cross-builds. A cross-compiler is one
163 # 4. world stage [WMAKE]
164 # This stage actually builds the world.
165 # 5. install stage (optional) [IMAKE]
166 # This stage installs a previously built world.
171 # Common environment for world related stages
172 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
173 MACHINE_ARCH=${TARGET_ARCH} \
175 CPUTYPE=${TARGET_CPUTYPE} \
176 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
177 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
178 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
180 # bootstrap-tools stage
181 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
182 PATH=${BPATH}:${PATH} \
183 WORLDTMP=${WORLDTMP} \
184 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
185 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
186 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
188 BOOTSTRAPPING=${OSRELDATE} \
189 -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_NLS -DNO_PIC \
190 -DNO_PROFILE -DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
193 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
194 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
196 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
199 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
202 WMAKEENV= ${CROSSENV} \
203 _SHLIBDIRPREFIX=${WORLDTMP} \
204 INSTALL="sh ${.CURDIR}/tools/install.sh" \
206 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
208 .if ${TARGET_ARCH} == "amd64"
210 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
212 LIB32PREFLAGS= -m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
213 LIB32POSTFLAGS= -I${LIB32TMP}/usr/include \
214 -L${LIB32TMP}/usr/lib32 \
215 -B${LIB32TMP}/usr/lib32
216 LIB32CC= ${LIB32PREFLAGS} \
218 LIB32CXX= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
220 LIB32OBJC= ${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
223 # Yes, the flags are redundant.
224 LIB32MAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
225 _SHLIBDIRPREFIX=${LIB32TMP} \
228 INSTALL="sh ${.CURDIR}/tools/install.sh" \
230 CC="${CC} ${LIB32CC}" \
231 CXX="${CXX} ${LIB32CXX}" \
232 OBJC="${OBJC} ${LIB32OBJC}" \
233 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
238 LIB32MAKE= ${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
239 -DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
240 LIB32IMAKE= ${LIB32MAKE:NINSTALL=*}
244 .if empty(.MAKEFLAGS:M-n)
245 IMAKEENV= ${CROSSENV} \
246 PATH=${STRICTTMPPATH}:${INSTALLTMP}
248 IMAKEENV= ${CROSSENV} \
249 PATH=${TMPPATH}:${INSTALLTMP}
251 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
254 KMAKEENV= ${WMAKEENV}
259 # Attempt to rebuild the entire system, with reasonable chance of
260 # success, regardless of how old your existing system is.
263 .if ${.CURDIR:C/[^,]//g} != ""
264 # The m4 build of sendmail files doesn't like it if ',' is used
265 # anywhere in the path of it's files.
267 @echo "*** Error: path to source tree contains a comma ','"
272 @echo "--------------------------------------------------------------"
273 @echo ">>> Rebuilding the temporary build tree"
274 @echo "--------------------------------------------------------------"
275 .if !defined(NO_CLEAN)
277 .if ${TARGET_ARCH} == "amd64"
281 rm -rf ${WORLDTMP}/legacy/usr/include
282 # XXX - These two can depend on any header file.
283 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
284 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
287 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
288 usr/libexec usr/sbin usr/share/dict \
289 usr/share/groff_font/devX100 \
290 usr/share/groff_font/devX100-12 \
291 usr/share/groff_font/devX75 \
292 usr/share/groff_font/devX75-12 \
293 usr/share/groff_font/devascii \
294 usr/share/groff_font/devcp1047 \
295 usr/share/groff_font/devdvi \
296 usr/share/groff_font/devhtml \
297 usr/share/groff_font/devkoi8-r \
298 usr/share/groff_font/devlatin1 \
299 usr/share/groff_font/devlbp \
300 usr/share/groff_font/devlj4 \
301 usr/share/groff_font/devps \
302 usr/share/groff_font/devutf8 \
303 usr/share/tmac/mdoc usr/share/tmac/mm
304 mkdir -p ${WORLDTMP}/legacy/${_dir}
307 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
308 usr/libexec usr/sbin usr/share/misc \
309 usr/share/snmp/defs usr/share/snmp/mibs
310 mkdir -p ${WORLDTMP}/${_dir}
312 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
313 -p ${WORLDTMP}/usr/include >/dev/null
314 ln -sf ${.CURDIR}/sys ${WORLDTMP}
315 .if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
316 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
317 -p ${WORLDTMP}/usr/include >/dev/null
321 @echo "--------------------------------------------------------------"
322 @echo ">>> stage 1.1: legacy release compatibility shims"
323 @echo "--------------------------------------------------------------"
324 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
327 @echo "--------------------------------------------------------------"
328 @echo ">>> stage 1.2: bootstrap tools"
329 @echo "--------------------------------------------------------------"
330 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
332 .if !defined(NO_CLEAN)
334 @echo "--------------------------------------------------------------"
335 @echo ">>> stage 2.1: cleaning up the object tree"
336 @echo "--------------------------------------------------------------"
337 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
338 .if ${TARGET_ARCH} == "amd64"
339 rm -rf ${OBJTREE}/lib32
344 @echo "--------------------------------------------------------------"
345 @echo ">>> stage 2.2: rebuilding the object tree"
346 @echo "--------------------------------------------------------------"
347 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
350 @echo "--------------------------------------------------------------"
351 @echo ">>> stage 2.3: build tools"
352 @echo "--------------------------------------------------------------"
353 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
356 @echo "--------------------------------------------------------------"
357 @echo ">>> stage 3: cross tools"
358 @echo "--------------------------------------------------------------"
359 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
362 @echo "--------------------------------------------------------------"
363 @echo ">>> stage 4.1: building includes"
364 @echo "--------------------------------------------------------------"
365 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
368 @echo "--------------------------------------------------------------"
369 @echo ">>> stage 4.2: building libraries"
370 @echo "--------------------------------------------------------------"
371 ${_+_}cd ${.CURDIR}; \
372 ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
373 -DNO_NLS -DNO_PROFILE libraries
376 @echo "--------------------------------------------------------------"
377 @echo ">>> stage 4.3: make dependencies"
378 @echo "--------------------------------------------------------------"
379 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
382 @echo "--------------------------------------------------------------"
383 @echo ">>> stage 4.4: building everything"
384 @echo "--------------------------------------------------------------"
385 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
386 .if ${TARGET_ARCH} == "amd64"
389 @echo "--------------------------------------------------------------"
390 @echo ">>> stage 5.1: building 32 bit shim libraries"
391 @echo "--------------------------------------------------------------"
393 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
394 usr/libexec usr/sbin usr/share/misc \
395 usr/share/snmp/defs usr/share/snmp/mibs
396 mkdir -p ${LIB32TMP}/${_dir}
398 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
399 -p ${LIB32TMP}/usr/include >/dev/null
401 ln -sf ${.CURDIR}/sys ${WORLDTMP}
402 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
403 .for _t in obj depend all
404 cd ${.CURDIR}/kerberos5/tools; \
405 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
408 .for _t in obj includes
409 cd ${.CURDIR}/include; \
410 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
413 cd ${.CURDIR}/gnu/lib; \
414 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
415 .if !defined(NO_CRYPT)
416 cd ${.CURDIR}/secure/lib; \
417 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
420 cd ${.CURDIR}/kerberos5/lib; \
421 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
424 .for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
425 cd ${.CURDIR}/${_dir}; \
426 ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
428 .for _dir in lib/libncurses lib/libmagic
429 cd ${.CURDIR}/${_dir}; \
430 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
433 ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries
434 .for _t in obj depend all
435 cd ${.CURDIR}/libexec/rtld-elf; \
436 PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
439 distribute32 install32:
440 .if make(distribute32)
441 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
443 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
445 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
446 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
447 .if !defined(NO_CRYPT)
448 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
450 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
455 .if !defined(SUBDIR_OVERRIDE)
456 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
458 WMAKE_TGTS+= _cleanobj _obj _build-tools
459 .if !defined(SUBDIR_OVERRIDE)
460 WMAKE_TGTS+= _cross-tools
462 WMAKE_TGTS+= _includes _libraries _depend everything
463 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
467 buildworld: ${WMAKE_TGTS}
468 .ORDER: ${WMAKE_TGTS}
471 @echo Entering world for ${TARGET_ARCH}:${TARGET}
472 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
474 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
475 toolchain: ${TOOLCHAIN_TGTS}
476 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
479 # Use this to add checks to installworld/installkernel targets.
481 SPECIAL_INSTALLCHECKS=
484 # Require DESTDIR to be set if installing for a different architecture.
486 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
487 SPECIAL_INSTALLCHECKS+= installcheck_DESTDIR
488 installcheck_DESTDIR:
489 .if !defined(DESTDIR) || empty(DESTDIR)
490 @echo "ERROR: Please set DESTDIR!"; \
498 # Checks to be sure system is ready for installworld
502 .if !defined(NO_SENDMAIL)
508 CHECK_GIDS+= proxy authpf
510 installcheck: ${SPECIAL_INSTALLCHECKS}
511 .for uid in ${CHECK_UIDS}
512 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
513 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
517 .for gid in ${CHECK_GIDS}
518 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
519 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
527 # Distributes everything compiled by a `buildworld'.
531 # Installs everything compiled by a 'buildworld'.
533 distributeworld installworld: installcheck
534 mkdir -p ${INSTALLTMP}
535 for prog in [ awk cap_mkdb cat chflags chmod chown \
536 date echo egrep find grep install-info \
537 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
538 test true uname wc zic; do \
539 cp `which $$prog` ${INSTALLTMP}; \
541 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
547 # If you have a build server, you can NFS mount the source and obj directories
548 # and do a 'make reinstall' on the *client* to install new binaries from the
549 # most recent server build.
551 reinstall: ${SPECIAL_INSTALLCHECKS}
552 @echo "--------------------------------------------------------------"
553 @echo ">>> Making hierarchy"
554 @echo "--------------------------------------------------------------"
555 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
557 @echo "--------------------------------------------------------------"
558 @echo ">>> Installing everything"
559 @echo "--------------------------------------------------------------"
560 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
561 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
562 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
566 @echo "--------------------------------------------------------------"
567 @echo ">>> Distributing everything"
568 @echo "--------------------------------------------------------------"
569 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
570 .if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
571 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
574 distrib-dirs distribution:
575 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
578 # buildkernel and installkernel
580 # Which kernels to build and/or install is specified by setting
581 # KERNCONF. If not defined a GENERIC kernel is built/installed.
582 # Only the existing (depending TARGET) config files are used
583 # for building kernels and only the first of these is designated
584 # as the one being installed.
586 # Note that we have to use TARGET instead of TARGET_ARCH when
587 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
588 # be set to cross-build, we have to make sure TARGET is set
591 .if !defined(KERNCONF) && defined(KERNEL)
597 INSTKERNNAME?= kernel
599 KERNSRCDIR?= ${.CURDIR}/sys
600 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
601 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
602 KERNCONFDIR?= ${KRNLCONFDIR}
606 .for _kernel in ${KERNCONF}
607 .if exists(${KERNCONFDIR}/${_kernel})
608 BUILDKERNELS+= ${_kernel}
609 .if empty(INSTALLKERNEL)
610 INSTALLKERNEL= ${_kernel}
618 # Builds all kernels defined by BUILDKERNELS.
621 .if empty(BUILDKERNELS)
622 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
625 .if defined(KERNWARN)
626 @echo "--------------------------------------------------------------"
627 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
628 @echo "--------------------------------------------------------------"
632 .for _kernel in ${BUILDKERNELS}
633 @echo "--------------------------------------------------------------"
634 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
635 @echo "--------------------------------------------------------------"
636 @echo "===> ${_kernel}"
637 mkdir -p ${KRNLOBJDIR}
638 .if !defined(NO_KERNELCONFIG)
640 @echo "--------------------------------------------------------------"
641 @echo ">>> stage 1: configuring the kernel"
642 @echo "--------------------------------------------------------------"
645 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
646 ${KERNCONFDIR}/${_kernel}
648 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
650 @echo "--------------------------------------------------------------"
651 @echo ">>> stage 2.1: cleaning up the object tree"
652 @echo "--------------------------------------------------------------"
653 cd ${KRNLOBJDIR}/${_kernel}; \
654 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 2.2: rebuilding the object tree"
659 @echo "--------------------------------------------------------------"
660 cd ${KRNLOBJDIR}/${_kernel}; \
661 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
663 @echo "--------------------------------------------------------------"
664 @echo ">>> stage 2.3: build tools"
665 @echo "--------------------------------------------------------------"
666 cd ${KRNLOBJDIR}/${_kernel}; \
667 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
668 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
669 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
670 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
671 .for target in obj depend all
672 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
673 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
674 ${MAKE} -DNO_CPU_CFLAGS ${target}
677 .if !defined(NO_KERNELDEPEND)
679 @echo "--------------------------------------------------------------"
680 @echo ">>> stage 3.1: making dependencies"
681 @echo "--------------------------------------------------------------"
682 cd ${KRNLOBJDIR}/${_kernel}; \
683 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
686 @echo "--------------------------------------------------------------"
687 @echo ">>> stage 3.2: building everything"
688 @echo "--------------------------------------------------------------"
689 cd ${KRNLOBJDIR}/${_kernel}; \
690 ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
691 @echo "--------------------------------------------------------------"
692 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
693 @echo "--------------------------------------------------------------"
697 # installkernel, etc.
699 # Install the kernel defined by INSTALLKERNEL
701 installkernel installkernel.debug \
702 reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
703 .if empty(INSTALLKERNEL)
704 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
707 @echo "--------------------------------------------------------------"
708 @echo ">>> Making hierarchy"
709 @echo "--------------------------------------------------------------"
711 ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
713 @echo "--------------------------------------------------------------"
714 @echo ">>> Installing kernel"
715 @echo "--------------------------------------------------------------"
716 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
717 ${CROSSENV} PATH=${TMPPATH} \
718 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
723 # Update the source tree, by running cvsup and/or running cvs to update to the
727 .if defined(SUP_UPDATE)
728 @echo "--------------------------------------------------------------"
729 @echo ">>> Running ${SUP}"
730 @echo "--------------------------------------------------------------"
732 @${SUP} ${SUPFLAGS} ${SUPFILE}
734 .if defined(SUPFILE1)
735 @${SUP} ${SUPFLAGS} ${SUPFILE1}
737 .if defined(SUPFILE2)
738 @${SUP} ${SUPFLAGS} ${SUPFILE2}
740 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
741 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
743 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
744 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
747 .if defined(CVS_UPDATE)
748 @echo "--------------------------------------------------------------"
749 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
750 @echo "--------------------------------------------------------------"
751 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
755 # ------------------------------------------------------------------------
757 # From here onwards are utility targets used by the 'make world' and
758 # related targets. If your 'world' breaks, you may like to try to fix
759 # the problem and manually run the following targets to attempt to
760 # complete the build. Beware, this is *not* guaranteed to work, you
761 # need to have a pretty good grip on the current state of the system
762 # to attempt to manually finish it. If in doubt, 'make world' again.
766 # legacy: Build compatibility shims for the next three targets
769 .if ${BOOTSTRAPPING} < 503000
770 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
773 .for _tool in tools/build
774 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
775 cd ${.CURDIR}/${_tool}; \
776 ${MAKE} DIRPRFX=${_tool}/ obj; \
777 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
778 ${MAKE} DIRPRFX=${_tool}/ depend; \
779 ${MAKE} DIRPRFX=${_tool}/ all; \
780 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
784 # bootstrap-tools: Build tools needed for compatibility
786 .if !defined(NO_GAMES)
787 _strfile= games/fortune/strfile
791 _gperf= gnu/usr.bin/gperf
792 .if ${BOOTSTRAPPING} < 700004
793 _groff= gnu/usr.bin/groff
795 _groff= gnu/usr.bin/groff/tmac
799 .if ${BOOTSTRAPPING} < 600029
800 _texinfo= gnu/usr.bin/texinfo
803 .if ${BOOTSTRAPPING} < 600015
804 _cap_mkdb= usr.bin/cap_mkdb
807 .if ${BOOTSTRAPPING} < 600018
808 _colldef= usr.bin/colldef
811 .if ${BOOTSTRAPPING} < 600017
812 _gencat= usr.bin/gencat
815 .if ${BOOTSTRAPPING} < 600016
816 _mklocale= usr.bin/mklocale
819 .if !defined(NO_RESCUE) && \
820 ${BOOTSTRAPPING} < 600008
821 _crunchgen= usr.sbin/crunch/crunchgen
824 .if ${BOOTSTRAPPING} < 600020
825 _pwd_mkdb= usr.sbin/pwd_mkdb
845 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
846 cd ${.CURDIR}/${_tool}; \
847 ${MAKE} DIRPRFX=${_tool}/ obj; \
848 ${MAKE} DIRPRFX=${_tool}/ depend; \
849 ${MAKE} DIRPRFX=${_tool}/ all; \
850 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
854 # build-tools: Build special purpose build tools
856 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
857 _aicasm= sys/modules/aic7xxx/aicasm
860 .if !defined(NO_SHARE)
861 _share= share/syscons/scrnmaps
864 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
865 _kerberos5_tools= kerberos5/tools
868 .if !defined(NO_RESCUE)
869 _rescue= rescue/rescue
883 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
884 cd ${.CURDIR}/${_tool}; \
885 ${MAKE} DIRPRFX=${_tool}/ obj; \
886 ${MAKE} DIRPRFX=${_tool}/ build-tools
889 gnu/usr.bin/cc/cc_tools \
891 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
892 cd ${.CURDIR}/${_tool}; \
893 ${MAKE} DIRPRFX=${_tool}/ obj; \
894 ${MAKE} DIRPRFX=${_tool}/ depend; \
895 ${MAKE} DIRPRFX=${_tool}/ all
899 # cross-tools: Build cross-building tools
901 .if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
902 ${TARGET_ARCH} != ${MACHINE_ARCH}
903 _btxld= usr.sbin/btxld
906 .if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
907 ${TARGET_ARCH} != ${MACHINE_ARCH}
908 _crunchide= usr.sbin/crunch/crunchide
911 .if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
912 _elf2exe= usr.sbin/elf2exe
915 .if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
917 _kgzip= usr.sbin/kgzip
922 gnu/usr.bin/binutils \
924 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
929 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
930 cd ${.CURDIR}/${_tool}; \
931 ${MAKE} DIRPRFX=${_tool}/ obj; \
932 ${MAKE} DIRPRFX=${_tool}/ depend; \
933 ${MAKE} DIRPRFX=${_tool}/ all; \
934 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
938 # hierarchy - ensure that all the needed directories are present
941 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
944 # libraries - build all libraries, and install them under ${DESTDIR}.
946 # The list of libraries with dependents (${_prebuild_libs}) and their
947 # interdependencies (__L) are built automatically by the
948 # ${.CURDIR}/tools/make_libdeps.sh script.
952 ${MAKE} -f Makefile.inc1 _startup_libs; \
953 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
954 ${MAKE} -f Makefile.inc1 _generic_libs;
956 # These dependencies are not automatically generated:
958 # gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
959 # shared libraries for ELF.
961 _startup_libs= gnu/lib/csu gnu/lib/libgcc
962 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
963 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
965 _startup_libs+= lib/csu/${MACHINE_ARCH}
970 _generic_libs= gnu/lib
972 .if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
973 _prebuild_libs+= kerberos5/lib/libasn1
974 _prebuild_libs+= kerberos5/lib/libgssapi
975 _prebuild_libs+= kerberos5/lib/libkrb5
976 _prebuild_libs+= kerberos5/lib/libroken
977 _generic_libs+= kerberos5/lib
980 _prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
981 lib/libipx lib/libkiconv lib/libkvm lib/libmd \
982 lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
984 lib/libsbuf lib/libtacplus lib/libutil \
987 lib/libopie__L lib/libtacplus__L: lib/libmd__L
991 .if !defined(NO_CRYPT)
992 .if !defined(NO_OPENSSL)
993 _prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
994 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
995 .if !defined(NO_OPENSSH)
996 _prebuild_libs+= secure/lib/libssh
997 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
998 .if !defined(NO_KERBEROS)
999 secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1000 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1001 kerberos5/lib/libroken__L
1005 _generic_libs+= secure/lib
1008 .if defined(NO_CRYPT) || defined(NO_OPENSSL)
1009 lib/libradius__L: lib/libmd__L
1012 .if !defined(NO_NIS)
1013 _prebuild_libs+= lib/libypclnt
1016 _generic_libs+= usr.bin/lex/lib
1018 .if ${MACHINE_ARCH} == "i386"
1019 _generic_libs+= usr.sbin/pcvt/keycap
1022 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1024 .if exists(${.CURDIR}/${_lib})
1025 ${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1026 cd ${.CURDIR}/${_lib}; \
1027 ${MAKE} DIRPRFX=${_lib}/ depend; \
1028 ${MAKE} DIRPRFX=${_lib}/ all; \
1029 ${MAKE} DIRPRFX=${_lib}/ install
1033 # libpam is special: we need to build static PAM modules before
1034 # static PAM library, and dynamic PAM library before dynamic PAM
1036 lib/libpam__L: .PHONY
1037 ${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1038 cd ${.CURDIR}/lib/libpam; \
1039 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1040 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1041 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1043 _startup_libs: ${_startup_libs:S/$/__L/}
1044 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1045 _generic_libs: ${_generic_libs:S/$/__L/}
1047 .for __target in all clean cleandepend cleandir depend includes obj
1048 .for entry in ${SUBDIR}
1049 ${entry}.${__target}__D: .PHONY
1050 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1051 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1052 edir=${entry}.${MACHINE_ARCH}; \
1053 cd ${.CURDIR}/$${edir}; \
1055 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1057 cd ${.CURDIR}/$${edir}; \
1059 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1061 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1064 .include <bsd.subdir.mk>
1066 .if make(delete-old) || make(delete-old-libs) || make(check-old)
1069 # check for / delete old files section
1072 .include "ObsoleteFiles.inc"
1074 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1075 else you can not start such an application. Consult UPDATING for more \
1076 information regarding how to cope with the removal/revision bump of a \
1079 .if !defined(BATCH_DELETE_OLD_FILES)
1086 @echo ">>> Removing old files (only deletes safe to delete libs)"
1087 .for file in ${OLD_FILES}
1088 # Ask for every old file if the user really wants to remove it.
1089 # It's annoying, but better safe than sorry.
1090 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1091 || ([ -f "${DESTDIR}/${file}" ] \
1092 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1093 && chflags noschg "${DESTDIR}/${file}" \
1094 && rm ${RM_I} "${DESTDIR}/${file}"))
1096 # Remove catpages without corresponding manpages.
1097 @for dir in ${DESTDIR}/usr/share/man/cat*; do \
1098 for catpage in $${dir}/*; do \
1099 manpage=$$(echo $${catpage} \
1100 | sed 's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:') \
1101 check_empty=$$(echo $${catpage} \
1102 | sed 's:.*\*:empty:'); \
1103 [ "$${check_empty}" != "empty" -a ! -e "$${manpage}" ] \
1104 && rm ${RM_I} $${catpage} || true; \
1107 @echo ">>> Old files removed"
1110 @echo ">>> Checking for old files"
1111 .for file in ${OLD_FILES}
1112 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1114 # Check for catpages without corresponding manpages.
1115 @for dir in ${DESTDIR}/usr/share/man/cat*; do \
1116 for catpage in $${dir}/*; do \
1117 manpage=$$(echo $${catpage} \
1118 | sed 's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:'); \
1119 check_empty=$$(echo $${catpage} \
1120 | sed 's:.*\*:empty:'); \
1121 [ "$${check_empty}" != "empty" -a ! -e "$${manpage}" ] \
1122 && echo $${catpage} || true; \
1127 @echo ">>> Removing old libraries"
1128 @echo "${OLD_LIBS_MESSAGE}" | fmt
1129 .for file in ${OLD_LIBS}
1130 @[ ! -f "${DESTDIR}/${file}" ] || (rm ${RM_I} "${DESTDIR}/${file}" \
1131 || ([ -f "${DESTDIR}/${file}" ] \
1132 && echo "Removing schg flag on ${DESTDIR}/${file}" \
1133 && chflags noschg "${DESTDIR}/${file}" \
1134 && rm ${RM_I} "${DESTDIR}/${file}"))
1136 @echo ">>> Old libraries removed"
1139 @echo ">>> Checking for old libraries"
1140 .for file in ${OLD_LIBS}
1141 @[ ! -f "${DESTDIR}/${file}" ] || echo "${DESTDIR}/${file}"
1145 @echo ">>> Removing old directories"
1146 .for dir in ${OLD_DIRS}
1147 # Don't fail if an old directory isn't empty.
1148 @[ ! -d "${DESTDIR}/${dir}" ] || (rmdir -v "${DESTDIR}/${dir}" || true)
1150 @echo ">>> Old directories removed"
1153 @echo ">>> Checking for old directories"
1154 .for dir in ${OLD_DIRS}
1155 @[ ! -d "${DESTDIR}/${dir}" ] || echo "${DESTDIR}/${dir}"
1158 delete-old: delete-old-files delete-old-dirs
1159 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1161 check-old: check-old-files check-old-libs check-old-dirs
1162 @echo "To remove old files and directories run '${MAKE} delete-old'."
1163 @echo "To remove old libraries run '${MAKE} delete-old-libs'."