Deleted Added
full compact
Makefile.inc1 (169596) Makefile.inc1 (169597)
1#
1#
2# $FreeBSD: head/Makefile.inc1 169596 2007-05-16 08:39:46Z des $
2# $FreeBSD: head/Makefile.inc1 169597 2007-05-16 08:46:35Z des $
3#
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# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
12# -DNO_DOCUPDATE do not update doc in ${MAKE} update
13# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
14# TARGET="machine" to crossbuild world for a different machine type
15
16#
17# The intended user-driven targets are:
18# buildworld - rebuild *everything*, including glue to help do upgrades
19# installworld- install everything built by "buildworld"
20# doxygen - build API documentation of the kernel
21# update - convenient way to update your source tree (eg: cvsup/cvs)
22#
23# Standard targets (not defined here) are documented in the makefiles in
24# /usr/share/mk. These include:
25# obj depend all install clean cleandepend cleanobj
26
27.include <bsd.own.mk>
28
29# We must do share/info early so that installation of info `dir'
30# entries works correctly. Do it first since it is less likely to
31# grow dependencies on include and lib than vice versa.
32#
33# We must do lib/ and libexec/ before bin/, because if installworld
34# installs a new /bin/sh, the 'make' command will *immediately*
35# use that new version. And the new (dynamically-linked) /bin/sh
36# will expect to find appropriate libraries in /lib and /libexec.
37#
38SUBDIR= share/info lib libexec
39SUBDIR+=bin
40.if ${MK_GAMES} != "no"
41SUBDIR+=games
42.endif
43.if ${MK_CDDL} != "no"
44SUBDIR+=cddl
45.endif
46SUBDIR+=gnu include
47.if ${MK_KERBEROS} != "no"
48SUBDIR+=kerberos5
49.endif
50.if ${MK_RESCUE} != "no"
51SUBDIR+=rescue
52.endif
53SUBDIR+=sbin
54.if ${MK_CRYPT} != "no"
55SUBDIR+=secure
56.endif
57.if !defined(NO_SHARE)
58SUBDIR+=share
59.endif
60SUBDIR+=sys usr.bin usr.sbin
61#
62# We must do etc/ last for install/distribute to work.
63#
64SUBDIR+=etc
65
66# These are last, since it is nice to at least get the base system
67# rebuilt before you do them.
68.for _DIR in ${LOCAL_DIRS}
69.if exists(${.CURDIR}/${_DIR}/Makefile)
70SUBDIR+= ${_DIR}
71.endif
72.endfor
73
74.if defined(SUBDIR_OVERRIDE)
75SUBDIR= ${SUBDIR_OVERRIDE}
76.endif
77
78.if defined(NOCLEAN)
79NO_CLEAN= ${NOCLEAN}
80.endif
81.if defined(NO_CLEANDIR)
82CLEANDIR= clean cleandepend
83.else
84CLEANDIR= cleandir
85.endif
86
87CVS?= cvs
88CVSFLAGS?= -A -P -d -I!
89SUP?= /usr/bin/csup
90SUPFLAGS?= -g -L 2
91.if defined(SUPHOST)
92SUPFLAGS+= -h ${SUPHOST}
93.endif
94
95MAKEOBJDIRPREFIX?= /usr/obj
96.if !defined(OSRELDATE)
97.if exists(/usr/include/osreldate.h)
98OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
99 /usr/include/osreldate.h
100.else
101OSRELDATE= 0
102.endif
103.endif
104
105# Guess machine architecture from machine type, and vice versa.
106.if !defined(TARGET_ARCH) && defined(TARGET)
107TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
108.elif !defined(TARGET) && defined(TARGET_ARCH) && \
109 ${TARGET_ARCH} != ${MACHINE_ARCH}
110TARGET= ${TARGET_ARCH}
111.endif
112# Otherwise, default to current machine type and architecture.
113TARGET?= ${MACHINE}
114TARGET_ARCH?= ${MACHINE_ARCH}
115
116KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
117.if ${TARGET} == ${TARGET_ARCH}
118_t= ${TARGET}
119.else
120_t= ${TARGET_ARCH}/${TARGET}
121.endif
122.for _t in ${_t}
123.if empty(KNOWN_ARCHES:M${_t})
124.error Unknown target ${TARGET_ARCH}:${TARGET}.
125.endif
126.endfor
127
128.if ${TARGET} == ${MACHINE}
129TARGET_CPUTYPE?=${CPUTYPE}
130.else
131TARGET_CPUTYPE?=
132.endif
133
134.if !empty(TARGET_CPUTYPE)
135_TARGET_CPUTYPE=${TARGET_CPUTYPE}
136.else
137_TARGET_CPUTYPE=dummy
138.endif
139_CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
140 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
141.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
142.error CPUTYPE global should be set with ?=.
143.endif
144.if make(buildworld)
145BUILD_ARCH!= uname -p
146.if ${MACHINE_ARCH} != ${BUILD_ARCH}
147.error To cross-build, set TARGET_ARCH.
148.endif
149.endif
150.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
151OBJTREE= ${MAKEOBJDIRPREFIX}
152.else
153OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
154.endif
155WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
156# /usr/games added for fortune which depend on strfile
157BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
158XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
159STRICTTMPPATH= ${BPATH}:${XPATH}
160TMPPATH= ${STRICTTMPPATH}:${PATH}
161
162INSTALLTMP!= /usr/bin/mktemp -d -u -t install
163
164#
165# Building a world goes through the following stages
166#
167# 1. legacy stage [BMAKE]
168# This stage is responsible for creating compatibility
169# shims that are needed by the bootstrap-tools,
170# build-tools and cross-tools stages.
171# 1. bootstrap-tools stage [BMAKE]
172# This stage is responsible for creating programs that
173# are needed for backward compatibility reasons. They
174# are not built as cross-tools.
175# 2. build-tools stage [TMAKE]
176# This stage is responsible for creating the object
177# tree and building any tools that are needed during
178# the build process.
179# 3. cross-tools stage [XMAKE]
180# This stage is responsible for creating any tools that
181# are needed for cross-builds. A cross-compiler is one
182# of them.
183# 4. world stage [WMAKE]
184# This stage actually builds the world.
185# 5. install stage (optional) [IMAKE]
186# This stage installs a previously built world.
187#
188
189BOOTSTRAPPING?= 0
190
191# Common environment for world related stages
192CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
193 MACHINE_ARCH=${TARGET_ARCH} \
194 MACHINE=${TARGET} \
195 CPUTYPE=${TARGET_CPUTYPE} \
196 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
197 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
198 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
199
200# bootstrap-tools stage
201BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
202 PATH=${BPATH}:${PATH} \
203 WORLDTMP=${WORLDTMP} \
204 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
205BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
206 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
207 DESTDIR= \
208 BOOTSTRAPPING=${OSRELDATE} \
209 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
210 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
211 -DNO_CPU_CFLAGS -DNO_WARNS
212
213# build-tools stage
214TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
215 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
216 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
217 DESTDIR= \
218 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
219
220# cross-tools stage
221XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
222 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
223 -DWITHOUT_FORTRAN -DWITHOUT_GDB
224
225# world stage
226WMAKEENV= ${CROSSENV} \
227 _SHLIBDIRPREFIX=${WORLDTMP} \
228 INSTALL="sh ${.CURDIR}/tools/install.sh" \
229 PATH=${TMPPATH}
230WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
231
232.if ${TARGET_ARCH} == "amd64"
233# 32 bit world
234LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
235
236.if empty(TARGET_CPUTYPE)
237LIB32CPUTYPE= k8
238.else
239LIB32CPUTYPE= ${TARGET_CPUTYPE}
240.endif
241LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
242 -iprefix ${LIB32TMP}/usr/ \
243 -L${LIB32TMP}/usr/lib32 \
244 -B${LIB32TMP}/usr/lib32
245
246# Yes, the flags are redundant.
247LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
248 _SHLIBDIRPREFIX=${LIB32TMP} \
249 MACHINE=i386 \
250 MACHINE_ARCH=i386 \
251 INSTALL="sh ${.CURDIR}/tools/install.sh" \
252 PATH=${TMPPATH} \
253 CC="${CC} ${LIB32FLAGS}" \
254 CXX="${CXX} ${LIB32FLAGS}" \
255 OBJC="${OBJC} ${LIB32FLAGS}" \
256 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
257 AS="${AS} --32" \
258 LIBDIR=/usr/lib32 \
259 SHLIBDIR=/usr/lib32
260
261LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
262 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
263 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
264LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
265.endif
266
267# install stage
268.if empty(.MAKEFLAGS:M-n)
269IMAKEENV= ${CROSSENV} \
270 PATH=${STRICTTMPPATH}:${INSTALLTMP}
271.else
272IMAKEENV= ${CROSSENV} \
273 PATH=${TMPPATH}:${INSTALLTMP}
274.endif
275IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
276
277# kernel stage
278KMAKEENV= ${WMAKEENV}
279KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
280
281#
282# buildworld
283#
284# Attempt to rebuild the entire system, with reasonable chance of
285# success, regardless of how old your existing system is.
286#
287_worldtmp:
288.if ${.CURDIR:C/[^,]//g} != ""
289# The m4 build of sendmail files doesn't like it if ',' is used
290# anywhere in the path of it's files.
291 @echo
292 @echo "*** Error: path to source tree contains a comma ','"
293 @echo
294 false
295.endif
296 @echo
297 @echo "--------------------------------------------------------------"
298 @echo ">>> Rebuilding the temporary build tree"
299 @echo "--------------------------------------------------------------"
300.if !defined(NO_CLEAN)
301 rm -rf ${WORLDTMP}
302.if ${TARGET_ARCH} == "amd64"
303 rm -rf ${LIB32TMP}
304.endif
305.else
306 rm -rf ${WORLDTMP}/legacy/usr/include
307# XXX - These two can depend on any header file.
308 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
309 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
310.endif
311.for _dir in \
312 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
313 usr/libexec usr/sbin usr/share/dict \
314 usr/share/groff_font/devX100 \
315 usr/share/groff_font/devX100-12 \
316 usr/share/groff_font/devX75 \
317 usr/share/groff_font/devX75-12 \
318 usr/share/groff_font/devascii \
319 usr/share/groff_font/devcp1047 \
320 usr/share/groff_font/devdvi \
321 usr/share/groff_font/devhtml \
322 usr/share/groff_font/devkoi8-r \
323 usr/share/groff_font/devlatin1 \
324 usr/share/groff_font/devlbp \
325 usr/share/groff_font/devlj4 \
326 usr/share/groff_font/devps \
327 usr/share/groff_font/devutf8 \
328 usr/share/tmac/mdoc usr/share/tmac/mm
329 mkdir -p ${WORLDTMP}/legacy/${_dir}
330.endfor
331.for _dir in \
332 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
333 usr/libexec usr/sbin usr/share/misc \
334 usr/share/snmp/defs usr/share/snmp/mibs
335 mkdir -p ${WORLDTMP}/${_dir}
336.endfor
337 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
338 -p ${WORLDTMP}/usr/include >/dev/null
339 ln -sf ${.CURDIR}/sys ${WORLDTMP}
340.if ${MK_BIND_LIBS} != "no"
341 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
342 -p ${WORLDTMP}/usr/include >/dev/null
343.endif
344_legacy:
345 @echo
346 @echo "--------------------------------------------------------------"
347 @echo ">>> stage 1.1: legacy release compatibility shims"
348 @echo "--------------------------------------------------------------"
349 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
350_bootstrap-tools:
351 @echo
352 @echo "--------------------------------------------------------------"
353 @echo ">>> stage 1.2: bootstrap tools"
354 @echo "--------------------------------------------------------------"
355 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
356_cleanobj:
357.if !defined(NO_CLEAN)
358 @echo
359 @echo "--------------------------------------------------------------"
360 @echo ">>> stage 2.1: cleaning up the object tree"
361 @echo "--------------------------------------------------------------"
362 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
363.if ${TARGET_ARCH} == "amd64"
364 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
365.endif
366.endif
367_obj:
368 @echo
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 2.2: rebuilding the object tree"
371 @echo "--------------------------------------------------------------"
372 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
373_build-tools:
374 @echo
375 @echo "--------------------------------------------------------------"
376 @echo ">>> stage 2.3: build tools"
377 @echo "--------------------------------------------------------------"
378 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
379_cross-tools:
380 @echo
381 @echo "--------------------------------------------------------------"
382 @echo ">>> stage 3: cross tools"
383 @echo "--------------------------------------------------------------"
384 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
385_includes:
386 @echo
387 @echo "--------------------------------------------------------------"
388 @echo ">>> stage 4.1: building includes"
389 @echo "--------------------------------------------------------------"
390 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
391_libraries:
392 @echo
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 4.2: building libraries"
395 @echo "--------------------------------------------------------------"
396 ${_+_}cd ${.CURDIR}; \
397 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
398 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
399_depend:
400 @echo
401 @echo "--------------------------------------------------------------"
402 @echo ">>> stage 4.3: make dependencies"
403 @echo "--------------------------------------------------------------"
404 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
405everything:
406 @echo
407 @echo "--------------------------------------------------------------"
408 @echo ">>> stage 4.4: building everything"
409 @echo "--------------------------------------------------------------"
410 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
411.if ${TARGET_ARCH} == "amd64"
412build32:
413 @echo
414 @echo "--------------------------------------------------------------"
415 @echo ">>> stage 5.1: building 32 bit shim libraries"
416 @echo "--------------------------------------------------------------"
417.for _dir in \
418 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
419 usr/libexec usr/sbin usr/share/misc \
420 usr/share/snmp/defs usr/share/snmp/mibs
421 mkdir -p ${LIB32TMP}/${_dir}
422.endfor
423 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
424 -p ${LIB32TMP}/usr/include >/dev/null
425 mkdir -p ${WORLDTMP}
426 ln -sf ${.CURDIR}/sys ${WORLDTMP}
427.if ${MK_KERBEROS} != "no"
428.for _t in obj depend all
429 cd ${.CURDIR}/kerberos5/tools; \
430 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
431.endfor
432.endif
433.for _t in obj includes
434 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
435 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
436.if ${MK_CDDL} != "no"
437 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
438.endif
439 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
440.if ${MK_CRYPT} != "no"
441 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
442.endif
443.if ${MK_KERBEROS} != "no"
444 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
445.endif
446.endfor
447.for _dir in usr.bin/lex/lib
448 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
449.endfor
450.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
451 cd ${.CURDIR}/${_dir}; \
452 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
453.endfor
454 cd ${.CURDIR}; \
455 ${LIB32WMAKE} -f Makefile.inc1 libraries
456.for _t in obj depend all
457 cd ${.CURDIR}/libexec/rtld-elf; \
458 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
459.endfor
460
461distribute32 install32:
462.if make(distribute32)
463 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
464.else
465 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
466.endif
467 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
468 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
469.if ${MK_CRYPT} != "no"
470 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
471.endif
472 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
473.endif
474
475
476WMAKE_TGTS=
477.if !defined(SUBDIR_OVERRIDE)
478WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
479.endif
480WMAKE_TGTS+= _cleanobj _obj _build-tools
481.if !defined(SUBDIR_OVERRIDE)
482WMAKE_TGTS+= _cross-tools
483.endif
484WMAKE_TGTS+= _includes _libraries _depend everything
485.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
486WMAKE_TGTS+= build32
487.endif
488
489buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
490.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
491
492buildworld_prologue:
493 @echo "--------------------------------------------------------------"
494 @echo ">>> World build started on `LC_ALL=C date`"
495 @echo "--------------------------------------------------------------"
496
497buildworld_epilogue:
498 @echo
499 @echo "--------------------------------------------------------------"
500 @echo ">>> World build completed on `LC_ALL=C date`"
501 @echo "--------------------------------------------------------------"
502
503#
504# We need to have this as a target because the indirection between Makefile
505# and Makefile.inc1 causes the correct PATH to be used, rather than a
506# modification of the current environment's PATH. In addition, we need
507# to quote multiword values.
508#
509buildenvvars:
510 @echo ${WMAKEENV:Q}
511
512buildenv:
513 @echo Entering world for ${TARGET_ARCH}:${TARGET}
514 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
515
516TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
517toolchain: ${TOOLCHAIN_TGTS}
518kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
519
520#
521# installcheck
522#
523# Checks to be sure system is ready for installworld/installkernel.
524#
525installcheck:
526
527#
528# Require DESTDIR to be set if installing for a different architecture.
529#
530.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
531.if !make(distributeworld)
532installcheck: installcheck_DESTDIR
533installcheck_DESTDIR:
534.if !defined(DESTDIR) || empty(DESTDIR)
535 @echo "ERROR: Please set DESTDIR!"; \
536 false
537.endif
538.endif
539.endif
540
541#
542# Check for missing UIDs/GIDs.
543#
544CHECK_UIDS=
545CHECK_GIDS= audit
546.if ${MK_SENDMAIL} != "no"
547CHECK_UIDS+= smmsp
548CHECK_GIDS+= smmsp
549.endif
550.if ${MK_PF} != "no"
551CHECK_UIDS+= proxy
552CHECK_GIDS+= proxy authpf
553.endif
554installcheck: installcheck_UGID
555installcheck_UGID:
556.for uid in ${CHECK_UIDS}
557 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
558 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
559 false; \
560 fi
561.endfor
562.for gid in ${CHECK_GIDS}
563 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
564 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
565 false; \
566 fi
567.endfor
568
569#
570# distributeworld
571#
572# Distributes everything compiled by a `buildworld'.
573#
574# installworld
575#
576# Installs everything compiled by a 'buildworld'.
577#
578distributeworld installworld: installcheck
579 mkdir -p ${INSTALLTMP}
580 for prog in [ awk cap_mkdb cat chflags chmod chown \
581 date echo egrep find grep install-info \
582 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
583 test true uname wc zic; do \
584 cp `which $$prog` ${INSTALLTMP}; \
585 done
586 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
587 rm -rf ${INSTALLTMP}
588
589#
590# reinstall
591#
592# If you have a build server, you can NFS mount the source and obj directories
593# and do a 'make reinstall' on the *client* to install new binaries from the
594# most recent server build.
595#
596reinstall:
597 @echo "--------------------------------------------------------------"
598 @echo ">>> Making hierarchy"
599 @echo "--------------------------------------------------------------"
600 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
601 @echo
602 @echo "--------------------------------------------------------------"
603 @echo ">>> Installing everything"
604 @echo "--------------------------------------------------------------"
605 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
606.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
607 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
608.endif
609
610redistribute:
611 @echo "--------------------------------------------------------------"
612 @echo ">>> Distributing everything"
613 @echo "--------------------------------------------------------------"
614 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
615.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
616 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
617.endif
618
619distrib-dirs distribution:
620 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
621
622#
623# buildkernel and installkernel
624#
625# Which kernels to build and/or install is specified by setting
626# KERNCONF. If not defined a GENERIC kernel is built/installed.
627# Only the existing (depending TARGET) config files are used
628# for building kernels and only the first of these is designated
629# as the one being installed.
630#
631# Note that we have to use TARGET instead of TARGET_ARCH when
632# we're in kernel-land. Since only TARGET_ARCH is (expected) to
633# be set to cross-build, we have to make sure TARGET is set
634# properly.
635
636.if !defined(KERNCONF) && defined(KERNEL)
637KERNCONF= ${KERNEL}
638KERNWARN=
639.else
640KERNCONF?= GENERIC
641.endif
642INSTKERNNAME?= kernel
643
644KERNSRCDIR?= ${.CURDIR}/sys
645KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
646KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
647KERNCONFDIR?= ${KRNLCONFDIR}
648
649BUILDKERNELS=
650INSTALLKERNEL=
651.for _kernel in ${KERNCONF}
652.if exists(${KERNCONFDIR}/${_kernel})
653BUILDKERNELS+= ${_kernel}
654.if empty(INSTALLKERNEL)
655INSTALLKERNEL= ${_kernel}
656.endif
657.endif
658.endfor
659
660#
661# buildkernel
662#
663# Builds all kernels defined by BUILDKERNELS.
664#
665buildkernel:
666.if empty(BUILDKERNELS)
667 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
668 false
669.endif
670.if defined(KERNWARN)
671 @echo "--------------------------------------------------------------"
672 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
673 @echo "--------------------------------------------------------------"
674 @sleep 3
675.endif
676 @echo
677.for _kernel in ${BUILDKERNELS}
678 @echo "--------------------------------------------------------------"
679 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
680 @echo "--------------------------------------------------------------"
681 @echo "===> ${_kernel}"
682 mkdir -p ${KRNLOBJDIR}
683.if !defined(NO_KERNELCONFIG)
684 @echo
685 @echo "--------------------------------------------------------------"
686 @echo ">>> stage 1: configuring the kernel"
687 @echo "--------------------------------------------------------------"
688 cd ${KRNLCONFDIR}; \
689 PATH=${TMPPATH} \
690 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
691 ${KERNCONFDIR}/${_kernel}
692.endif
693.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
694 @echo
695 @echo "--------------------------------------------------------------"
696 @echo ">>> stage 2.1: cleaning up the object tree"
697 @echo "--------------------------------------------------------------"
698 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
699.endif
700 @echo
701 @echo "--------------------------------------------------------------"
702 @echo ">>> stage 2.2: rebuilding the object tree"
703 @echo "--------------------------------------------------------------"
704 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
705 @echo
706 @echo "--------------------------------------------------------------"
707 @echo ">>> stage 2.3: build tools"
708 @echo "--------------------------------------------------------------"
709 cd ${KRNLOBJDIR}/${_kernel}; \
710 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
711 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
712# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
713.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
714.for target in obj depend all
715 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
716 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
717 ${MAKE} -DNO_CPU_CFLAGS ${target}
718.endfor
719.endif
720.if !defined(NO_KERNELDEPEND)
721 @echo
722 @echo "--------------------------------------------------------------"
723 @echo ">>> stage 3.1: making dependencies"
724 @echo "--------------------------------------------------------------"
725 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
726.endif
727 @echo
728 @echo "--------------------------------------------------------------"
729 @echo ">>> stage 3.2: building everything"
730 @echo "--------------------------------------------------------------"
731 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
732 @echo "--------------------------------------------------------------"
733 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
734 @echo "--------------------------------------------------------------"
735.endfor
736
737#
738# installkernel, etc.
739#
740# Install the kernel defined by INSTALLKERNEL
741#
742installkernel installkernel.debug \
743reinstallkernel reinstallkernel.debug: installcheck
744.if empty(INSTALLKERNEL)
745 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
746 false
747.endif
748 @echo "--------------------------------------------------------------"
749 @echo ">>> Installing kernel"
750 @echo "--------------------------------------------------------------"
751 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
752 ${CROSSENV} PATH=${TMPPATH} \
753 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
754
755#
756# doxygen
757#
758# Build the API documentation with doxygen
759#
760doxygen:
761 @if [ ! -x `/usr/bin/which doxygen` ]; then \
762 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
763 exit 1; \
764 fi
765 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
766
767#
768# update
769#
770# Update the source tree, by running cvsup and/or running cvs to update to the
771# latest copy.
772#
773update:
774.if defined(SUP_UPDATE)
775 @echo "--------------------------------------------------------------"
776 @echo ">>> Running ${SUP}"
777 @echo "--------------------------------------------------------------"
778.if defined(SUPFILE)
779 @${SUP} ${SUPFLAGS} ${SUPFILE}
780.endif
781.if defined(SUPFILE1)
782 @${SUP} ${SUPFLAGS} ${SUPFILE1}
783.endif
784.if defined(SUPFILE2)
785 @${SUP} ${SUPFLAGS} ${SUPFILE2}
786.endif
787.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
788 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
789.endif
790.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
791 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
792.endif
793.endif
794.if defined(CVS_UPDATE)
795 @echo "--------------------------------------------------------------"
796 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
797 @echo "--------------------------------------------------------------"
798 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
799.endif
800
801#
802# ------------------------------------------------------------------------
803#
804# From here onwards are utility targets used by the 'make world' and
805# related targets. If your 'world' breaks, you may like to try to fix
806# the problem and manually run the following targets to attempt to
807# complete the build. Beware, this is *not* guaranteed to work, you
808# need to have a pretty good grip on the current state of the system
809# to attempt to manually finish it. If in doubt, 'make world' again.
810#
811
812#
813# legacy: Build compatibility shims for the next three targets
814#
815legacy:
816.if ${BOOTSTRAPPING} < 503000
817 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
818 false
819.endif
820.for _tool in tools/build
821 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
822 cd ${.CURDIR}/${_tool}; \
823 ${MAKE} DIRPRFX=${_tool}/ obj; \
824 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
825 ${MAKE} DIRPRFX=${_tool}/ depend; \
826 ${MAKE} DIRPRFX=${_tool}/ all; \
827 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
828.endfor
829
830#
831# bootstrap-tools: Build tools needed for compatibility
832#
833.if ${MK_GAMES} != "no"
834_strfile= games/fortune/strfile
835.endif
836
837.if ${MK_CXX} != "no"
838_gperf= gnu/usr.bin/gperf
839.if ${BOOTSTRAPPING} < 700004
840_groff= gnu/usr.bin/groff
841.else
842_groff= gnu/usr.bin/groff/tmac
843.endif
844.endif
845
846.if ${BOOTSTRAPPING} < 600029
847_texinfo= gnu/usr.bin/texinfo
848.endif
849
850.if ${BOOTSTRAPPING} < 600015
851_cap_mkdb= usr.bin/cap_mkdb
852.endif
853
854.if ${BOOTSTRAPPING} < 600018
855_colldef= usr.bin/colldef
856.endif
857
858.if ${BOOTSTRAPPING} < 600017
859_gencat= usr.bin/gencat
860.endif
861
862.if ${BOOTSTRAPPING} < 600016
863_mklocale= usr.bin/mklocale
864.endif
865
866.if ${BOOTSTRAPPING} < 700018
867_gensnmptree= usr.sbin/bsnmpd/gensnmptree
868.endif
869
870.if ${MK_RESCUE} != "no" && \
871 ${BOOTSTRAPPING} < 700026
872_crunchgen= usr.sbin/crunch/crunchgen
873.endif
874
875.if ${BOOTSTRAPPING} < 600020
876_pwd_mkdb= usr.sbin/pwd_mkdb
877.endif
878
879bootstrap-tools:
880.for _tool in \
881 ${_strfile} \
882 ${_gperf} \
883 ${_groff} \
884 ${_texinfo} \
885 ${_cap_mkdb} \
886 ${_colldef} \
887 ${_gencat} \
888 usr.bin/lorder \
889 usr.bin/makewhatis \
890 ${_mklocale} \
891 usr.bin/rpcgen \
892 usr.bin/xinstall \
893 ${_gensnmptree} \
894 usr.sbin/config \
895 ${_crunchgen} \
896 ${_pwd_mkdb}
897 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
898 cd ${.CURDIR}/${_tool}; \
899 ${MAKE} DIRPRFX=${_tool}/ obj; \
900 ${MAKE} DIRPRFX=${_tool}/ depend; \
901 ${MAKE} DIRPRFX=${_tool}/ all; \
902 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
903.endfor
904
905#
906# build-tools: Build special purpose build tools
907#
908.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
909_aicasm= sys/modules/aic7xxx/aicasm
910.endif
911
912.if !defined(NO_SHARE)
913_share= share/syscons/scrnmaps
914.endif
915
916.if ${MK_KERBEROS} != "no"
917_kerberos5_tools= kerberos5/tools
918.endif
919
920.if ${MK_RESCUE} != "no"
921_rescue= rescue/rescue
922.endif
923
924build-tools:
925.for _tool in \
926 bin/csh \
927 bin/sh \
928 ${_rescue} \
929 lib/ncurses/ncurses \
930 lib/ncurses/ncursesw \
931 ${_share} \
932 ${_aicasm} \
933 usr.bin/awk \
934 lib/libmagic \
935 usr.sbin/sysinstall
936 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
937 cd ${.CURDIR}/${_tool}; \
938 ${MAKE} DIRPRFX=${_tool}/ obj; \
939 ${MAKE} DIRPRFX=${_tool}/ build-tools
940.endfor
941.for _tool in \
942 gnu/usr.bin/cc/cc_tools \
943 ${_kerberos5_tools}
944 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
945 cd ${.CURDIR}/${_tool}; \
946 ${MAKE} DIRPRFX=${_tool}/ obj; \
947 ${MAKE} DIRPRFX=${_tool}/ depend; \
948 ${MAKE} DIRPRFX=${_tool}/ all
949.endfor
950
951#
952# cross-tools: Build cross-building tools
953#
954.if ${TARGET_ARCH} != ${MACHINE_ARCH}
955.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
956_btxld= usr.sbin/btxld
957.endif
958.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
959_crunchide= usr.sbin/crunch/crunchide
960.endif
961.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
962_kgzip= usr.sbin/kgzip
963.endif
964.endif
965
966cross-tools:
967.for _tool in \
968 gnu/usr.bin/binutils \
969 gnu/usr.bin/cc \
970 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
971 ${_btxld} \
972 ${_crunchide} \
973 ${_kgzip}
974 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
975 cd ${.CURDIR}/${_tool}; \
976 ${MAKE} DIRPRFX=${_tool}/ obj; \
977 ${MAKE} DIRPRFX=${_tool}/ depend; \
978 ${MAKE} DIRPRFX=${_tool}/ all; \
979 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
980.endfor
981
982#
983# hierarchy - ensure that all the needed directories are present
984#
985hierarchy:
986 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
987
988#
989# libraries - build all libraries, and install them under ${DESTDIR}.
990#
991# The list of libraries with dependents (${_prebuild_libs}) and their
992# interdependencies (__L) are built automatically by the
993# ${.CURDIR}/tools/make_libdeps.sh script.
994#
995libraries:
996 cd ${.CURDIR}; \
997 ${MAKE} -f Makefile.inc1 _startup_libs; \
998 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
999 ${MAKE} -f Makefile.inc1 _generic_libs;
1000
1001# These dependencies are not automatically generated:
1002#
1003# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
1004# shared libraries for ELF.
1005#
1006_startup_libs= gnu/lib/csu gnu/lib/libgcc
1007.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1008_startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1009.else
1010_startup_libs+= lib/csu/${MACHINE_ARCH}
1011.endif
1012
1013_prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1014 ${_kerberos5_lib_libroken} \
1015 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1016 ${_lib_libgssapi} ${_lib_libipx} \
1017 lib/libkiconv lib/libkvm lib/libmd \
1018 lib/ncurses/ncurses lib/ncurses/ncursesw \
1019 lib/libopie lib/libpam lib/${DEFAULT_THREAD_LIB} \
1020 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1021 ${_lib_libypclnt} lib/libz lib/msun \
1022 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1023 ${_secure_lib_libssl}
1024
1025_generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1026
1027lib/libopie__L lib/libtacplus__L: lib/libmd__L
1028
1029.if ${MK_CDDL} != "no"
1030_cddl_lib= cddl/lib
1031.endif
1032
1033.if ${MK_CRYPT} != "no"
1034.if ${MK_OPENSSL} != "no"
1035_secure_lib_libcrypto= secure/lib/libcrypto
1036_secure_lib_libssl= secure/lib/libssl
1037lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1038.if ${MK_OPENSSH} != "no"
1039_secure_lib_libssh= secure/lib/libssh
1040secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1041.if ${MK_KERBEROS} != "no"
1042secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1043 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1044 kerberos5/lib/libroken__L
1045.endif
1046.endif
1047.endif
1048_secure_lib= secure/lib
1049.endif
1050
1051.if ${MK_IPX} != "no"
1052_lib_libipx= lib/libipx
1053.endif
1054
1055.if ${MK_KERBEROS} != "no"
1056_kerberos5_lib= kerberos5/lib
1057_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1058_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1059_kerberos5_lib_libroken= kerberos5/lib/libroken
1060_lib_libgssapi= lib/libgssapi
1061.endif
1062
1063.if ${MK_NIS} != "no"
1064_lib_libypclnt= lib/libypclnt
1065.endif
1066
1067.if ${MK_OPENSSL} == "no"
1068lib/libradius__L: lib/libmd__L
1069.endif
1070
1071.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1072${_lib}__L: .PHONY
1073.if exists(${.CURDIR}/${_lib})
1074 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1075 cd ${.CURDIR}/${_lib}; \
1076 ${MAKE} DIRPRFX=${_lib}/ obj; \
1077 ${MAKE} DIRPRFX=${_lib}/ depend; \
1078 ${MAKE} DIRPRFX=${_lib}/ all; \
1079 ${MAKE} DIRPRFX=${_lib}/ install
1080.endif
1081.endfor
1082
1083# libpam is special: we need to build static PAM modules before
1084# static PAM library, and dynamic PAM library before dynamic PAM
1085# modules.
1086lib/libpam__L: .PHONY
1087 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1088 cd ${.CURDIR}/lib/libpam; \
1089 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1090 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1091 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1092 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1093
1094_startup_libs: ${_startup_libs:S/$/__L/}
1095_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1096_generic_libs: ${_generic_libs:S/$/__L/}
1097
1098.for __target in all clean cleandepend cleandir depend includes obj
1099.for entry in ${SUBDIR}
1100${entry}.${__target}__D: .PHONY
1101 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1102 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1103 edir=${entry}.${MACHINE_ARCH}; \
1104 cd ${.CURDIR}/$${edir}; \
1105 else \
1106 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1107 edir=${entry}; \
1108 cd ${.CURDIR}/$${edir}; \
1109 fi; \
1110 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1111.endfor
1112par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1113.endfor
1114
1115.include <bsd.subdir.mk>
1116
3#
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# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
12# -DNO_DOCUPDATE do not update doc in ${MAKE} update
13# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
14# TARGET="machine" to crossbuild world for a different machine type
15
16#
17# The intended user-driven targets are:
18# buildworld - rebuild *everything*, including glue to help do upgrades
19# installworld- install everything built by "buildworld"
20# doxygen - build API documentation of the kernel
21# update - convenient way to update your source tree (eg: cvsup/cvs)
22#
23# Standard targets (not defined here) are documented in the makefiles in
24# /usr/share/mk. These include:
25# obj depend all install clean cleandepend cleanobj
26
27.include <bsd.own.mk>
28
29# We must do share/info early so that installation of info `dir'
30# entries works correctly. Do it first since it is less likely to
31# grow dependencies on include and lib than vice versa.
32#
33# We must do lib/ and libexec/ before bin/, because if installworld
34# installs a new /bin/sh, the 'make' command will *immediately*
35# use that new version. And the new (dynamically-linked) /bin/sh
36# will expect to find appropriate libraries in /lib and /libexec.
37#
38SUBDIR= share/info lib libexec
39SUBDIR+=bin
40.if ${MK_GAMES} != "no"
41SUBDIR+=games
42.endif
43.if ${MK_CDDL} != "no"
44SUBDIR+=cddl
45.endif
46SUBDIR+=gnu include
47.if ${MK_KERBEROS} != "no"
48SUBDIR+=kerberos5
49.endif
50.if ${MK_RESCUE} != "no"
51SUBDIR+=rescue
52.endif
53SUBDIR+=sbin
54.if ${MK_CRYPT} != "no"
55SUBDIR+=secure
56.endif
57.if !defined(NO_SHARE)
58SUBDIR+=share
59.endif
60SUBDIR+=sys usr.bin usr.sbin
61#
62# We must do etc/ last for install/distribute to work.
63#
64SUBDIR+=etc
65
66# These are last, since it is nice to at least get the base system
67# rebuilt before you do them.
68.for _DIR in ${LOCAL_DIRS}
69.if exists(${.CURDIR}/${_DIR}/Makefile)
70SUBDIR+= ${_DIR}
71.endif
72.endfor
73
74.if defined(SUBDIR_OVERRIDE)
75SUBDIR= ${SUBDIR_OVERRIDE}
76.endif
77
78.if defined(NOCLEAN)
79NO_CLEAN= ${NOCLEAN}
80.endif
81.if defined(NO_CLEANDIR)
82CLEANDIR= clean cleandepend
83.else
84CLEANDIR= cleandir
85.endif
86
87CVS?= cvs
88CVSFLAGS?= -A -P -d -I!
89SUP?= /usr/bin/csup
90SUPFLAGS?= -g -L 2
91.if defined(SUPHOST)
92SUPFLAGS+= -h ${SUPHOST}
93.endif
94
95MAKEOBJDIRPREFIX?= /usr/obj
96.if !defined(OSRELDATE)
97.if exists(/usr/include/osreldate.h)
98OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
99 /usr/include/osreldate.h
100.else
101OSRELDATE= 0
102.endif
103.endif
104
105# Guess machine architecture from machine type, and vice versa.
106.if !defined(TARGET_ARCH) && defined(TARGET)
107TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
108.elif !defined(TARGET) && defined(TARGET_ARCH) && \
109 ${TARGET_ARCH} != ${MACHINE_ARCH}
110TARGET= ${TARGET_ARCH}
111.endif
112# Otherwise, default to current machine type and architecture.
113TARGET?= ${MACHINE}
114TARGET_ARCH?= ${MACHINE_ARCH}
115
116KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
117.if ${TARGET} == ${TARGET_ARCH}
118_t= ${TARGET}
119.else
120_t= ${TARGET_ARCH}/${TARGET}
121.endif
122.for _t in ${_t}
123.if empty(KNOWN_ARCHES:M${_t})
124.error Unknown target ${TARGET_ARCH}:${TARGET}.
125.endif
126.endfor
127
128.if ${TARGET} == ${MACHINE}
129TARGET_CPUTYPE?=${CPUTYPE}
130.else
131TARGET_CPUTYPE?=
132.endif
133
134.if !empty(TARGET_CPUTYPE)
135_TARGET_CPUTYPE=${TARGET_CPUTYPE}
136.else
137_TARGET_CPUTYPE=dummy
138.endif
139_CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
140 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
141.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
142.error CPUTYPE global should be set with ?=.
143.endif
144.if make(buildworld)
145BUILD_ARCH!= uname -p
146.if ${MACHINE_ARCH} != ${BUILD_ARCH}
147.error To cross-build, set TARGET_ARCH.
148.endif
149.endif
150.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
151OBJTREE= ${MAKEOBJDIRPREFIX}
152.else
153OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
154.endif
155WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
156# /usr/games added for fortune which depend on strfile
157BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
158XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
159STRICTTMPPATH= ${BPATH}:${XPATH}
160TMPPATH= ${STRICTTMPPATH}:${PATH}
161
162INSTALLTMP!= /usr/bin/mktemp -d -u -t install
163
164#
165# Building a world goes through the following stages
166#
167# 1. legacy stage [BMAKE]
168# This stage is responsible for creating compatibility
169# shims that are needed by the bootstrap-tools,
170# build-tools and cross-tools stages.
171# 1. bootstrap-tools stage [BMAKE]
172# This stage is responsible for creating programs that
173# are needed for backward compatibility reasons. They
174# are not built as cross-tools.
175# 2. build-tools stage [TMAKE]
176# This stage is responsible for creating the object
177# tree and building any tools that are needed during
178# the build process.
179# 3. cross-tools stage [XMAKE]
180# This stage is responsible for creating any tools that
181# are needed for cross-builds. A cross-compiler is one
182# of them.
183# 4. world stage [WMAKE]
184# This stage actually builds the world.
185# 5. install stage (optional) [IMAKE]
186# This stage installs a previously built world.
187#
188
189BOOTSTRAPPING?= 0
190
191# Common environment for world related stages
192CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
193 MACHINE_ARCH=${TARGET_ARCH} \
194 MACHINE=${TARGET} \
195 CPUTYPE=${TARGET_CPUTYPE} \
196 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
197 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
198 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
199
200# bootstrap-tools stage
201BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
202 PATH=${BPATH}:${PATH} \
203 WORLDTMP=${WORLDTMP} \
204 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
205BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
206 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
207 DESTDIR= \
208 BOOTSTRAPPING=${OSRELDATE} \
209 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
210 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
211 -DNO_CPU_CFLAGS -DNO_WARNS
212
213# build-tools stage
214TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
215 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
216 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
217 DESTDIR= \
218 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
219
220# cross-tools stage
221XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
222 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
223 -DWITHOUT_FORTRAN -DWITHOUT_GDB
224
225# world stage
226WMAKEENV= ${CROSSENV} \
227 _SHLIBDIRPREFIX=${WORLDTMP} \
228 INSTALL="sh ${.CURDIR}/tools/install.sh" \
229 PATH=${TMPPATH}
230WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
231
232.if ${TARGET_ARCH} == "amd64"
233# 32 bit world
234LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
235
236.if empty(TARGET_CPUTYPE)
237LIB32CPUTYPE= k8
238.else
239LIB32CPUTYPE= ${TARGET_CPUTYPE}
240.endif
241LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \
242 -iprefix ${LIB32TMP}/usr/ \
243 -L${LIB32TMP}/usr/lib32 \
244 -B${LIB32TMP}/usr/lib32
245
246# Yes, the flags are redundant.
247LIB32WMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
248 _SHLIBDIRPREFIX=${LIB32TMP} \
249 MACHINE=i386 \
250 MACHINE_ARCH=i386 \
251 INSTALL="sh ${.CURDIR}/tools/install.sh" \
252 PATH=${TMPPATH} \
253 CC="${CC} ${LIB32FLAGS}" \
254 CXX="${CXX} ${LIB32FLAGS}" \
255 OBJC="${OBJC} ${LIB32FLAGS}" \
256 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
257 AS="${AS} --32" \
258 LIBDIR=/usr/lib32 \
259 SHLIBDIR=/usr/lib32
260
261LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
262 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
263 -DWITHOUT_HTML DESTDIR=${LIB32TMP}
264LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
265.endif
266
267# install stage
268.if empty(.MAKEFLAGS:M-n)
269IMAKEENV= ${CROSSENV} \
270 PATH=${STRICTTMPPATH}:${INSTALLTMP}
271.else
272IMAKEENV= ${CROSSENV} \
273 PATH=${TMPPATH}:${INSTALLTMP}
274.endif
275IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
276
277# kernel stage
278KMAKEENV= ${WMAKEENV}
279KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
280
281#
282# buildworld
283#
284# Attempt to rebuild the entire system, with reasonable chance of
285# success, regardless of how old your existing system is.
286#
287_worldtmp:
288.if ${.CURDIR:C/[^,]//g} != ""
289# The m4 build of sendmail files doesn't like it if ',' is used
290# anywhere in the path of it's files.
291 @echo
292 @echo "*** Error: path to source tree contains a comma ','"
293 @echo
294 false
295.endif
296 @echo
297 @echo "--------------------------------------------------------------"
298 @echo ">>> Rebuilding the temporary build tree"
299 @echo "--------------------------------------------------------------"
300.if !defined(NO_CLEAN)
301 rm -rf ${WORLDTMP}
302.if ${TARGET_ARCH} == "amd64"
303 rm -rf ${LIB32TMP}
304.endif
305.else
306 rm -rf ${WORLDTMP}/legacy/usr/include
307# XXX - These two can depend on any header file.
308 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
309 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
310.endif
311.for _dir in \
312 usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
313 usr/libexec usr/sbin usr/share/dict \
314 usr/share/groff_font/devX100 \
315 usr/share/groff_font/devX100-12 \
316 usr/share/groff_font/devX75 \
317 usr/share/groff_font/devX75-12 \
318 usr/share/groff_font/devascii \
319 usr/share/groff_font/devcp1047 \
320 usr/share/groff_font/devdvi \
321 usr/share/groff_font/devhtml \
322 usr/share/groff_font/devkoi8-r \
323 usr/share/groff_font/devlatin1 \
324 usr/share/groff_font/devlbp \
325 usr/share/groff_font/devlj4 \
326 usr/share/groff_font/devps \
327 usr/share/groff_font/devutf8 \
328 usr/share/tmac/mdoc usr/share/tmac/mm
329 mkdir -p ${WORLDTMP}/legacy/${_dir}
330.endfor
331.for _dir in \
332 lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
333 usr/libexec usr/sbin usr/share/misc \
334 usr/share/snmp/defs usr/share/snmp/mibs
335 mkdir -p ${WORLDTMP}/${_dir}
336.endfor
337 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
338 -p ${WORLDTMP}/usr/include >/dev/null
339 ln -sf ${.CURDIR}/sys ${WORLDTMP}
340.if ${MK_BIND_LIBS} != "no"
341 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
342 -p ${WORLDTMP}/usr/include >/dev/null
343.endif
344_legacy:
345 @echo
346 @echo "--------------------------------------------------------------"
347 @echo ">>> stage 1.1: legacy release compatibility shims"
348 @echo "--------------------------------------------------------------"
349 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
350_bootstrap-tools:
351 @echo
352 @echo "--------------------------------------------------------------"
353 @echo ">>> stage 1.2: bootstrap tools"
354 @echo "--------------------------------------------------------------"
355 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
356_cleanobj:
357.if !defined(NO_CLEAN)
358 @echo
359 @echo "--------------------------------------------------------------"
360 @echo ">>> stage 2.1: cleaning up the object tree"
361 @echo "--------------------------------------------------------------"
362 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
363.if ${TARGET_ARCH} == "amd64"
364 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
365.endif
366.endif
367_obj:
368 @echo
369 @echo "--------------------------------------------------------------"
370 @echo ">>> stage 2.2: rebuilding the object tree"
371 @echo "--------------------------------------------------------------"
372 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
373_build-tools:
374 @echo
375 @echo "--------------------------------------------------------------"
376 @echo ">>> stage 2.3: build tools"
377 @echo "--------------------------------------------------------------"
378 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
379_cross-tools:
380 @echo
381 @echo "--------------------------------------------------------------"
382 @echo ">>> stage 3: cross tools"
383 @echo "--------------------------------------------------------------"
384 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
385_includes:
386 @echo
387 @echo "--------------------------------------------------------------"
388 @echo ">>> stage 4.1: building includes"
389 @echo "--------------------------------------------------------------"
390 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
391_libraries:
392 @echo
393 @echo "--------------------------------------------------------------"
394 @echo ">>> stage 4.2: building libraries"
395 @echo "--------------------------------------------------------------"
396 ${_+_}cd ${.CURDIR}; \
397 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
398 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
399_depend:
400 @echo
401 @echo "--------------------------------------------------------------"
402 @echo ">>> stage 4.3: make dependencies"
403 @echo "--------------------------------------------------------------"
404 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
405everything:
406 @echo
407 @echo "--------------------------------------------------------------"
408 @echo ">>> stage 4.4: building everything"
409 @echo "--------------------------------------------------------------"
410 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
411.if ${TARGET_ARCH} == "amd64"
412build32:
413 @echo
414 @echo "--------------------------------------------------------------"
415 @echo ">>> stage 5.1: building 32 bit shim libraries"
416 @echo "--------------------------------------------------------------"
417.for _dir in \
418 lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
419 usr/libexec usr/sbin usr/share/misc \
420 usr/share/snmp/defs usr/share/snmp/mibs
421 mkdir -p ${LIB32TMP}/${_dir}
422.endfor
423 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
424 -p ${LIB32TMP}/usr/include >/dev/null
425 mkdir -p ${WORLDTMP}
426 ln -sf ${.CURDIR}/sys ${WORLDTMP}
427.if ${MK_KERBEROS} != "no"
428.for _t in obj depend all
429 cd ${.CURDIR}/kerberos5/tools; \
430 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
431.endfor
432.endif
433.for _t in obj includes
434 cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
435 cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
436.if ${MK_CDDL} != "no"
437 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
438.endif
439 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
440.if ${MK_CRYPT} != "no"
441 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
442.endif
443.if ${MK_KERBEROS} != "no"
444 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
445.endif
446.endfor
447.for _dir in usr.bin/lex/lib
448 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
449.endfor
450.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
451 cd ${.CURDIR}/${_dir}; \
452 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
453.endfor
454 cd ${.CURDIR}; \
455 ${LIB32WMAKE} -f Makefile.inc1 libraries
456.for _t in obj depend all
457 cd ${.CURDIR}/libexec/rtld-elf; \
458 PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
459.endfor
460
461distribute32 install32:
462.if make(distribute32)
463 mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32 # XXX add to mtree
464.else
465 mkdir -p ${DESTDIR}/usr/lib32 # XXX add to mtree
466.endif
467 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
468 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
469.if ${MK_CRYPT} != "no"
470 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
471.endif
472 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
473.endif
474
475
476WMAKE_TGTS=
477.if !defined(SUBDIR_OVERRIDE)
478WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
479.endif
480WMAKE_TGTS+= _cleanobj _obj _build-tools
481.if !defined(SUBDIR_OVERRIDE)
482WMAKE_TGTS+= _cross-tools
483.endif
484WMAKE_TGTS+= _includes _libraries _depend everything
485.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
486WMAKE_TGTS+= build32
487.endif
488
489buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
490.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
491
492buildworld_prologue:
493 @echo "--------------------------------------------------------------"
494 @echo ">>> World build started on `LC_ALL=C date`"
495 @echo "--------------------------------------------------------------"
496
497buildworld_epilogue:
498 @echo
499 @echo "--------------------------------------------------------------"
500 @echo ">>> World build completed on `LC_ALL=C date`"
501 @echo "--------------------------------------------------------------"
502
503#
504# We need to have this as a target because the indirection between Makefile
505# and Makefile.inc1 causes the correct PATH to be used, rather than a
506# modification of the current environment's PATH. In addition, we need
507# to quote multiword values.
508#
509buildenvvars:
510 @echo ${WMAKEENV:Q}
511
512buildenv:
513 @echo Entering world for ${TARGET_ARCH}:${TARGET}
514 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
515
516TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
517toolchain: ${TOOLCHAIN_TGTS}
518kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
519
520#
521# installcheck
522#
523# Checks to be sure system is ready for installworld/installkernel.
524#
525installcheck:
526
527#
528# Require DESTDIR to be set if installing for a different architecture.
529#
530.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
531.if !make(distributeworld)
532installcheck: installcheck_DESTDIR
533installcheck_DESTDIR:
534.if !defined(DESTDIR) || empty(DESTDIR)
535 @echo "ERROR: Please set DESTDIR!"; \
536 false
537.endif
538.endif
539.endif
540
541#
542# Check for missing UIDs/GIDs.
543#
544CHECK_UIDS=
545CHECK_GIDS= audit
546.if ${MK_SENDMAIL} != "no"
547CHECK_UIDS+= smmsp
548CHECK_GIDS+= smmsp
549.endif
550.if ${MK_PF} != "no"
551CHECK_UIDS+= proxy
552CHECK_GIDS+= proxy authpf
553.endif
554installcheck: installcheck_UGID
555installcheck_UGID:
556.for uid in ${CHECK_UIDS}
557 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
558 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
559 false; \
560 fi
561.endfor
562.for gid in ${CHECK_GIDS}
563 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
564 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
565 false; \
566 fi
567.endfor
568
569#
570# distributeworld
571#
572# Distributes everything compiled by a `buildworld'.
573#
574# installworld
575#
576# Installs everything compiled by a 'buildworld'.
577#
578distributeworld installworld: installcheck
579 mkdir -p ${INSTALLTMP}
580 for prog in [ awk cap_mkdb cat chflags chmod chown \
581 date echo egrep find grep install-info \
582 ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
583 test true uname wc zic; do \
584 cp `which $$prog` ${INSTALLTMP}; \
585 done
586 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
587 rm -rf ${INSTALLTMP}
588
589#
590# reinstall
591#
592# If you have a build server, you can NFS mount the source and obj directories
593# and do a 'make reinstall' on the *client* to install new binaries from the
594# most recent server build.
595#
596reinstall:
597 @echo "--------------------------------------------------------------"
598 @echo ">>> Making hierarchy"
599 @echo "--------------------------------------------------------------"
600 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
601 @echo
602 @echo "--------------------------------------------------------------"
603 @echo ">>> Installing everything"
604 @echo "--------------------------------------------------------------"
605 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
606.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
607 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
608.endif
609
610redistribute:
611 @echo "--------------------------------------------------------------"
612 @echo ">>> Distributing everything"
613 @echo "--------------------------------------------------------------"
614 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
615.if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
616 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
617.endif
618
619distrib-dirs distribution:
620 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
621
622#
623# buildkernel and installkernel
624#
625# Which kernels to build and/or install is specified by setting
626# KERNCONF. If not defined a GENERIC kernel is built/installed.
627# Only the existing (depending TARGET) config files are used
628# for building kernels and only the first of these is designated
629# as the one being installed.
630#
631# Note that we have to use TARGET instead of TARGET_ARCH when
632# we're in kernel-land. Since only TARGET_ARCH is (expected) to
633# be set to cross-build, we have to make sure TARGET is set
634# properly.
635
636.if !defined(KERNCONF) && defined(KERNEL)
637KERNCONF= ${KERNEL}
638KERNWARN=
639.else
640KERNCONF?= GENERIC
641.endif
642INSTKERNNAME?= kernel
643
644KERNSRCDIR?= ${.CURDIR}/sys
645KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
646KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
647KERNCONFDIR?= ${KRNLCONFDIR}
648
649BUILDKERNELS=
650INSTALLKERNEL=
651.for _kernel in ${KERNCONF}
652.if exists(${KERNCONFDIR}/${_kernel})
653BUILDKERNELS+= ${_kernel}
654.if empty(INSTALLKERNEL)
655INSTALLKERNEL= ${_kernel}
656.endif
657.endif
658.endfor
659
660#
661# buildkernel
662#
663# Builds all kernels defined by BUILDKERNELS.
664#
665buildkernel:
666.if empty(BUILDKERNELS)
667 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
668 false
669.endif
670.if defined(KERNWARN)
671 @echo "--------------------------------------------------------------"
672 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
673 @echo "--------------------------------------------------------------"
674 @sleep 3
675.endif
676 @echo
677.for _kernel in ${BUILDKERNELS}
678 @echo "--------------------------------------------------------------"
679 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
680 @echo "--------------------------------------------------------------"
681 @echo "===> ${_kernel}"
682 mkdir -p ${KRNLOBJDIR}
683.if !defined(NO_KERNELCONFIG)
684 @echo
685 @echo "--------------------------------------------------------------"
686 @echo ">>> stage 1: configuring the kernel"
687 @echo "--------------------------------------------------------------"
688 cd ${KRNLCONFDIR}; \
689 PATH=${TMPPATH} \
690 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
691 ${KERNCONFDIR}/${_kernel}
692.endif
693.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
694 @echo
695 @echo "--------------------------------------------------------------"
696 @echo ">>> stage 2.1: cleaning up the object tree"
697 @echo "--------------------------------------------------------------"
698 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
699.endif
700 @echo
701 @echo "--------------------------------------------------------------"
702 @echo ">>> stage 2.2: rebuilding the object tree"
703 @echo "--------------------------------------------------------------"
704 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
705 @echo
706 @echo "--------------------------------------------------------------"
707 @echo ">>> stage 2.3: build tools"
708 @echo "--------------------------------------------------------------"
709 cd ${KRNLOBJDIR}/${_kernel}; \
710 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
711 ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
712# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
713.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
714.for target in obj depend all
715 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
716 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
717 ${MAKE} -DNO_CPU_CFLAGS ${target}
718.endfor
719.endif
720.if !defined(NO_KERNELDEPEND)
721 @echo
722 @echo "--------------------------------------------------------------"
723 @echo ">>> stage 3.1: making dependencies"
724 @echo "--------------------------------------------------------------"
725 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
726.endif
727 @echo
728 @echo "--------------------------------------------------------------"
729 @echo ">>> stage 3.2: building everything"
730 @echo "--------------------------------------------------------------"
731 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
732 @echo "--------------------------------------------------------------"
733 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
734 @echo "--------------------------------------------------------------"
735.endfor
736
737#
738# installkernel, etc.
739#
740# Install the kernel defined by INSTALLKERNEL
741#
742installkernel installkernel.debug \
743reinstallkernel reinstallkernel.debug: installcheck
744.if empty(INSTALLKERNEL)
745 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
746 false
747.endif
748 @echo "--------------------------------------------------------------"
749 @echo ">>> Installing kernel"
750 @echo "--------------------------------------------------------------"
751 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
752 ${CROSSENV} PATH=${TMPPATH} \
753 ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
754
755#
756# doxygen
757#
758# Build the API documentation with doxygen
759#
760doxygen:
761 @if [ ! -x `/usr/bin/which doxygen` ]; then \
762 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
763 exit 1; \
764 fi
765 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
766
767#
768# update
769#
770# Update the source tree, by running cvsup and/or running cvs to update to the
771# latest copy.
772#
773update:
774.if defined(SUP_UPDATE)
775 @echo "--------------------------------------------------------------"
776 @echo ">>> Running ${SUP}"
777 @echo "--------------------------------------------------------------"
778.if defined(SUPFILE)
779 @${SUP} ${SUPFLAGS} ${SUPFILE}
780.endif
781.if defined(SUPFILE1)
782 @${SUP} ${SUPFLAGS} ${SUPFILE1}
783.endif
784.if defined(SUPFILE2)
785 @${SUP} ${SUPFLAGS} ${SUPFILE2}
786.endif
787.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
788 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
789.endif
790.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
791 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
792.endif
793.endif
794.if defined(CVS_UPDATE)
795 @echo "--------------------------------------------------------------"
796 @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
797 @echo "--------------------------------------------------------------"
798 cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
799.endif
800
801#
802# ------------------------------------------------------------------------
803#
804# From here onwards are utility targets used by the 'make world' and
805# related targets. If your 'world' breaks, you may like to try to fix
806# the problem and manually run the following targets to attempt to
807# complete the build. Beware, this is *not* guaranteed to work, you
808# need to have a pretty good grip on the current state of the system
809# to attempt to manually finish it. If in doubt, 'make world' again.
810#
811
812#
813# legacy: Build compatibility shims for the next three targets
814#
815legacy:
816.if ${BOOTSTRAPPING} < 503000
817 @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
818 false
819.endif
820.for _tool in tools/build
821 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
822 cd ${.CURDIR}/${_tool}; \
823 ${MAKE} DIRPRFX=${_tool}/ obj; \
824 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
825 ${MAKE} DIRPRFX=${_tool}/ depend; \
826 ${MAKE} DIRPRFX=${_tool}/ all; \
827 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
828.endfor
829
830#
831# bootstrap-tools: Build tools needed for compatibility
832#
833.if ${MK_GAMES} != "no"
834_strfile= games/fortune/strfile
835.endif
836
837.if ${MK_CXX} != "no"
838_gperf= gnu/usr.bin/gperf
839.if ${BOOTSTRAPPING} < 700004
840_groff= gnu/usr.bin/groff
841.else
842_groff= gnu/usr.bin/groff/tmac
843.endif
844.endif
845
846.if ${BOOTSTRAPPING} < 600029
847_texinfo= gnu/usr.bin/texinfo
848.endif
849
850.if ${BOOTSTRAPPING} < 600015
851_cap_mkdb= usr.bin/cap_mkdb
852.endif
853
854.if ${BOOTSTRAPPING} < 600018
855_colldef= usr.bin/colldef
856.endif
857
858.if ${BOOTSTRAPPING} < 600017
859_gencat= usr.bin/gencat
860.endif
861
862.if ${BOOTSTRAPPING} < 600016
863_mklocale= usr.bin/mklocale
864.endif
865
866.if ${BOOTSTRAPPING} < 700018
867_gensnmptree= usr.sbin/bsnmpd/gensnmptree
868.endif
869
870.if ${MK_RESCUE} != "no" && \
871 ${BOOTSTRAPPING} < 700026
872_crunchgen= usr.sbin/crunch/crunchgen
873.endif
874
875.if ${BOOTSTRAPPING} < 600020
876_pwd_mkdb= usr.sbin/pwd_mkdb
877.endif
878
879bootstrap-tools:
880.for _tool in \
881 ${_strfile} \
882 ${_gperf} \
883 ${_groff} \
884 ${_texinfo} \
885 ${_cap_mkdb} \
886 ${_colldef} \
887 ${_gencat} \
888 usr.bin/lorder \
889 usr.bin/makewhatis \
890 ${_mklocale} \
891 usr.bin/rpcgen \
892 usr.bin/xinstall \
893 ${_gensnmptree} \
894 usr.sbin/config \
895 ${_crunchgen} \
896 ${_pwd_mkdb}
897 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
898 cd ${.CURDIR}/${_tool}; \
899 ${MAKE} DIRPRFX=${_tool}/ obj; \
900 ${MAKE} DIRPRFX=${_tool}/ depend; \
901 ${MAKE} DIRPRFX=${_tool}/ all; \
902 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
903.endfor
904
905#
906# build-tools: Build special purpose build tools
907#
908.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
909_aicasm= sys/modules/aic7xxx/aicasm
910.endif
911
912.if !defined(NO_SHARE)
913_share= share/syscons/scrnmaps
914.endif
915
916.if ${MK_KERBEROS} != "no"
917_kerberos5_tools= kerberos5/tools
918.endif
919
920.if ${MK_RESCUE} != "no"
921_rescue= rescue/rescue
922.endif
923
924build-tools:
925.for _tool in \
926 bin/csh \
927 bin/sh \
928 ${_rescue} \
929 lib/ncurses/ncurses \
930 lib/ncurses/ncursesw \
931 ${_share} \
932 ${_aicasm} \
933 usr.bin/awk \
934 lib/libmagic \
935 usr.sbin/sysinstall
936 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
937 cd ${.CURDIR}/${_tool}; \
938 ${MAKE} DIRPRFX=${_tool}/ obj; \
939 ${MAKE} DIRPRFX=${_tool}/ build-tools
940.endfor
941.for _tool in \
942 gnu/usr.bin/cc/cc_tools \
943 ${_kerberos5_tools}
944 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
945 cd ${.CURDIR}/${_tool}; \
946 ${MAKE} DIRPRFX=${_tool}/ obj; \
947 ${MAKE} DIRPRFX=${_tool}/ depend; \
948 ${MAKE} DIRPRFX=${_tool}/ all
949.endfor
950
951#
952# cross-tools: Build cross-building tools
953#
954.if ${TARGET_ARCH} != ${MACHINE_ARCH}
955.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
956_btxld= usr.sbin/btxld
957.endif
958.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
959_crunchide= usr.sbin/crunch/crunchide
960.endif
961.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
962_kgzip= usr.sbin/kgzip
963.endif
964.endif
965
966cross-tools:
967.for _tool in \
968 gnu/usr.bin/binutils \
969 gnu/usr.bin/cc \
970 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
971 ${_btxld} \
972 ${_crunchide} \
973 ${_kgzip}
974 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
975 cd ${.CURDIR}/${_tool}; \
976 ${MAKE} DIRPRFX=${_tool}/ obj; \
977 ${MAKE} DIRPRFX=${_tool}/ depend; \
978 ${MAKE} DIRPRFX=${_tool}/ all; \
979 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
980.endfor
981
982#
983# hierarchy - ensure that all the needed directories are present
984#
985hierarchy:
986 cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
987
988#
989# libraries - build all libraries, and install them under ${DESTDIR}.
990#
991# The list of libraries with dependents (${_prebuild_libs}) and their
992# interdependencies (__L) are built automatically by the
993# ${.CURDIR}/tools/make_libdeps.sh script.
994#
995libraries:
996 cd ${.CURDIR}; \
997 ${MAKE} -f Makefile.inc1 _startup_libs; \
998 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
999 ${MAKE} -f Makefile.inc1 _generic_libs;
1000
1001# These dependencies are not automatically generated:
1002#
1003# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
1004# shared libraries for ELF.
1005#
1006_startup_libs= gnu/lib/csu gnu/lib/libgcc
1007.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1008_startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1009.else
1010_startup_libs+= lib/csu/${MACHINE_ARCH}
1011.endif
1012
1013_prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1014 ${_kerberos5_lib_libroken} \
1015 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1016 ${_lib_libgssapi} ${_lib_libipx} \
1017 lib/libkiconv lib/libkvm lib/libmd \
1018 lib/ncurses/ncurses lib/ncurses/ncursesw \
1019 lib/libopie lib/libpam lib/${DEFAULT_THREAD_LIB} \
1020 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1021 ${_lib_libypclnt} lib/libz lib/msun \
1022 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1023 ${_secure_lib_libssl}
1024
1025_generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1026
1027lib/libopie__L lib/libtacplus__L: lib/libmd__L
1028
1029.if ${MK_CDDL} != "no"
1030_cddl_lib= cddl/lib
1031.endif
1032
1033.if ${MK_CRYPT} != "no"
1034.if ${MK_OPENSSL} != "no"
1035_secure_lib_libcrypto= secure/lib/libcrypto
1036_secure_lib_libssl= secure/lib/libssl
1037lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1038.if ${MK_OPENSSH} != "no"
1039_secure_lib_libssh= secure/lib/libssh
1040secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1041.if ${MK_KERBEROS} != "no"
1042secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1043 kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1044 kerberos5/lib/libroken__L
1045.endif
1046.endif
1047.endif
1048_secure_lib= secure/lib
1049.endif
1050
1051.if ${MK_IPX} != "no"
1052_lib_libipx= lib/libipx
1053.endif
1054
1055.if ${MK_KERBEROS} != "no"
1056_kerberos5_lib= kerberos5/lib
1057_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1058_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1059_kerberos5_lib_libroken= kerberos5/lib/libroken
1060_lib_libgssapi= lib/libgssapi
1061.endif
1062
1063.if ${MK_NIS} != "no"
1064_lib_libypclnt= lib/libypclnt
1065.endif
1066
1067.if ${MK_OPENSSL} == "no"
1068lib/libradius__L: lib/libmd__L
1069.endif
1070
1071.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1072${_lib}__L: .PHONY
1073.if exists(${.CURDIR}/${_lib})
1074 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1075 cd ${.CURDIR}/${_lib}; \
1076 ${MAKE} DIRPRFX=${_lib}/ obj; \
1077 ${MAKE} DIRPRFX=${_lib}/ depend; \
1078 ${MAKE} DIRPRFX=${_lib}/ all; \
1079 ${MAKE} DIRPRFX=${_lib}/ install
1080.endif
1081.endfor
1082
1083# libpam is special: we need to build static PAM modules before
1084# static PAM library, and dynamic PAM library before dynamic PAM
1085# modules.
1086lib/libpam__L: .PHONY
1087 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1088 cd ${.CURDIR}/lib/libpam; \
1089 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1090 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1091 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1092 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1093
1094_startup_libs: ${_startup_libs:S/$/__L/}
1095_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1096_generic_libs: ${_generic_libs:S/$/__L/}
1097
1098.for __target in all clean cleandepend cleandir depend includes obj
1099.for entry in ${SUBDIR}
1100${entry}.${__target}__D: .PHONY
1101 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1102 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1103 edir=${entry}.${MACHINE_ARCH}; \
1104 cd ${.CURDIR}/$${edir}; \
1105 else \
1106 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1107 edir=${entry}; \
1108 cd ${.CURDIR}/$${edir}; \
1109 fi; \
1110 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1111.endfor
1112par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1113.endfor
1114
1115.include <bsd.subdir.mk>
1116
1117.if make(delete-old) || make(delete-old-libs) || make(check-old)
1117.if make(check-old) || make(check-old-dirs) || \
1118 make(check-old-files) || make(check-old-libs) || \
1119 make(delete-old) || make(delete-old-dirs) || \
1120 make(delete-old-files) || make(delete-old-libs)
1118
1119#
1120# check for / delete old files section
1121#
1122
1123.include "ObsoleteFiles.inc"
1124
1125OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1126else you can not start such an application. Consult UPDATING for more \
1127information regarding how to cope with the removal/revision bump of a \
1128specific library."
1129
1130.if !defined(BATCH_DELETE_OLD_FILES)
1131RM_I=-i
1132.else
1133RM_I=-v
1134.endif
1135
1136delete-old-files:
1137 @echo ">>> Removing old files (only deletes safe to delete libs)"
1138# Ask for every old file if the user really wants to remove it.
1139# It's annoying, but better safe than sorry.
1140 @(for file in ${OLD_FILES}; do \
1141 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1142 rm ${RM_I} "${DESTDIR}/$${file}"; \
1143 fi; \
1144 done)
1145# Remove catpages without corresponding manpages.
1146 @3<&0; \
1147 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1148 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1149 while read catpage; do \
1150 read manpage; \
1151 if [ ! -e "$${manpage}" ]; then \
1152 rm ${RM_I} $${catpage} <&3 ; \
1153 fi; \
1154 done
1155 @echo ">>> Old files removed"
1156
1157check-old-files:
1158 @echo ">>> Checking for old files"
1159 @(for file in ${OLD_FILES}; do \
1160 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1161 echo "${DESTDIR}/$${file}"; \
1162 fi; \
1163 done)
1164# Check for catpages without corresponding manpages.
1165 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1166 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1167 while read catpage; do \
1168 read manpage; \
1169 if [ ! -e "$${manpage}" ]; then \
1170 echo $${catpage} ; \
1171 fi; \
1172 done
1173
1174delete-old-libs:
1175 @echo ">>> Removing old libraries"
1176 @echo "${OLD_LIBS_MESSAGE}" | fmt
1177 @(for file in ${OLD_LIBS}; do \
1178 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1179 rm ${RM_I} "${DESTDIR}/$${file}"; \
1180 fi; \
1181 done)
1182 @echo ">>> Old libraries removed"
1183
1184check-old-libs:
1185 @echo ">>> Checking for old libraries"
1186 @(for file in ${OLD_LIBS}; do \
1187 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1188 echo "${DESTDIR}/$${file}"; \
1189 fi; \
1190 done)
1191
1192delete-old-dirs:
1193 @echo ">>> Removing old directories"
1194 @(for dir in ${OLD_DIRS}; do \
1195 if [ -d "${DESTDIR}/$${dir}" ]; then \
1196 rmdir -v "${DESTDIR}/$${dir}" || true; \
1197 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1198 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1199 fi; \
1200 done)
1201 @echo ">>> Old directories removed"
1202
1203check-old-dirs:
1204 @echo ">>> Checking for old directories"
1205 @(for dir in ${OLD_DIRS}; do \
1206 if [ -d "${DESTDIR}/$${dir}" ]; then \
1207 echo "${DESTDIR}/$${dir}"; \
1208 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1209 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1210 fi; \
1211 done)
1212
1213delete-old: delete-old-files delete-old-dirs
1214 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1215
1216check-old: check-old-files check-old-libs check-old-dirs
1217 @echo "To remove old files and directories run '${MAKE} delete-old'."
1218 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1219
1220.endif
1221
1222#
1223# showconfig - show build configuration.
1224#
1225showconfig:
1226 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1121
1122#
1123# check for / delete old files section
1124#
1125
1126.include "ObsoleteFiles.inc"
1127
1128OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1129else you can not start such an application. Consult UPDATING for more \
1130information regarding how to cope with the removal/revision bump of a \
1131specific library."
1132
1133.if !defined(BATCH_DELETE_OLD_FILES)
1134RM_I=-i
1135.else
1136RM_I=-v
1137.endif
1138
1139delete-old-files:
1140 @echo ">>> Removing old files (only deletes safe to delete libs)"
1141# Ask for every old file if the user really wants to remove it.
1142# It's annoying, but better safe than sorry.
1143 @(for file in ${OLD_FILES}; do \
1144 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1145 rm ${RM_I} "${DESTDIR}/$${file}"; \
1146 fi; \
1147 done)
1148# Remove catpages without corresponding manpages.
1149 @3<&0; \
1150 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1151 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1152 while read catpage; do \
1153 read manpage; \
1154 if [ ! -e "$${manpage}" ]; then \
1155 rm ${RM_I} $${catpage} <&3 ; \
1156 fi; \
1157 done
1158 @echo ">>> Old files removed"
1159
1160check-old-files:
1161 @echo ">>> Checking for old files"
1162 @(for file in ${OLD_FILES}; do \
1163 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1164 echo "${DESTDIR}/$${file}"; \
1165 fi; \
1166 done)
1167# Check for catpages without corresponding manpages.
1168 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1169 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1170 while read catpage; do \
1171 read manpage; \
1172 if [ ! -e "$${manpage}" ]; then \
1173 echo $${catpage} ; \
1174 fi; \
1175 done
1176
1177delete-old-libs:
1178 @echo ">>> Removing old libraries"
1179 @echo "${OLD_LIBS_MESSAGE}" | fmt
1180 @(for file in ${OLD_LIBS}; do \
1181 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1182 rm ${RM_I} "${DESTDIR}/$${file}"; \
1183 fi; \
1184 done)
1185 @echo ">>> Old libraries removed"
1186
1187check-old-libs:
1188 @echo ">>> Checking for old libraries"
1189 @(for file in ${OLD_LIBS}; do \
1190 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1191 echo "${DESTDIR}/$${file}"; \
1192 fi; \
1193 done)
1194
1195delete-old-dirs:
1196 @echo ">>> Removing old directories"
1197 @(for dir in ${OLD_DIRS}; do \
1198 if [ -d "${DESTDIR}/$${dir}" ]; then \
1199 rmdir -v "${DESTDIR}/$${dir}" || true; \
1200 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1201 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1202 fi; \
1203 done)
1204 @echo ">>> Old directories removed"
1205
1206check-old-dirs:
1207 @echo ">>> Checking for old directories"
1208 @(for dir in ${OLD_DIRS}; do \
1209 if [ -d "${DESTDIR}/$${dir}" ]; then \
1210 echo "${DESTDIR}/$${dir}"; \
1211 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1212 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1213 fi; \
1214 done)
1215
1216delete-old: delete-old-files delete-old-dirs
1217 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1218
1219check-old: check-old-files check-old-libs check-old-dirs
1220 @echo "To remove old files and directories run '${MAKE} delete-old'."
1221 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1222
1223.endif
1224
1225#
1226# showconfig - show build configuration.
1227#
1228showconfig:
1229 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort