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