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