Makefile.inc1 revision 156764
1#
2# $FreeBSD: head/Makefile.inc1 156764 2006-03-16 07:31:50Z 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!=	uname -p
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
212.if empty(TARGET_CPUTYPE)
213LIB32CPUTYPE=	k8
214.else
215LIB32CPUTYPE=	${TARGET_CPUTYPE}
216.endif
217LIB32PREFLAGS=	-m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
218LIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
219		-L${LIB32TMP}/usr/lib32 \
220		-B${LIB32TMP}/usr/lib32
221LIB32CC=	${LIB32PREFLAGS} \
222		${LIB32POSTFLAGS}
223LIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
224		${LIB32POSTFLAGS}
225LIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
226		${LIB32POSTFLAGS}
227
228# Yes, the flags are redundant.
229LIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
230		_SHLIBDIRPREFIX=${LIB32TMP} \
231		MACHINE=i386 \
232		MACHINE_ARCH=i386 \
233		INSTALL="sh ${.CURDIR}/tools/install.sh" \
234		PATH=${TMPPATH} \
235		CC="${CC} ${LIB32CC}" \
236		CXX="${CXX} ${LIB32CXX}" \
237		OBJC="${OBJC} ${LIB32OBJC}" \
238		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
239		AS="${AS} --32" \
240		LIBDIR=/usr/lib32 \
241		SHLIBDIR=/usr/lib32
242
243LIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
244		-DNO_BIND -DNO_MAN -DNO_NLS -DNO_INFO -DNO_HTML
245LIB32IMAKE=	${LIB32MAKE:NINSTALL=*} -DNO_INCS
246.endif
247
248# install stage
249.if empty(.MAKEFLAGS:M-n)
250IMAKEENV=	${CROSSENV} \
251		PATH=${STRICTTMPPATH}:${INSTALLTMP}
252.else
253IMAKEENV=	${CROSSENV} \
254		PATH=${TMPPATH}:${INSTALLTMP}
255.endif
256IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
257
258# kernel stage
259KMAKEENV=	${WMAKEENV}
260KMAKE=		${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
261
262#
263# buildworld
264#
265# Attempt to rebuild the entire system, with reasonable chance of
266# success, regardless of how old your existing system is.
267#
268_worldtmp:
269.if ${.CURDIR:C/[^,]//g} != ""
270#	The m4 build of sendmail files doesn't like it if ',' is used
271#	anywhere in the path of it's files.
272	@echo
273	@echo "*** Error: path to source tree contains a comma ','"
274	@echo
275	false
276.endif
277	@echo
278	@echo "--------------------------------------------------------------"
279	@echo ">>> Rebuilding the temporary build tree"
280	@echo "--------------------------------------------------------------"
281.if !defined(NO_CLEAN)
282	rm -rf ${WORLDTMP}
283.if ${TARGET_ARCH} == "amd64"
284	rm -rf ${LIB32TMP}
285.endif
286.else
287	rm -rf ${WORLDTMP}/legacy/usr/include
288#	XXX - These two can depend on any header file.
289	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
290	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
291.endif
292.for _dir in \
293    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
294    usr/libexec usr/sbin usr/share/dict \
295    usr/share/groff_font/devX100 \
296    usr/share/groff_font/devX100-12 \
297    usr/share/groff_font/devX75 \
298    usr/share/groff_font/devX75-12 \
299    usr/share/groff_font/devascii \
300    usr/share/groff_font/devcp1047 \
301    usr/share/groff_font/devdvi \
302    usr/share/groff_font/devhtml \
303    usr/share/groff_font/devkoi8-r \
304    usr/share/groff_font/devlatin1 \
305    usr/share/groff_font/devlbp \
306    usr/share/groff_font/devlj4 \
307    usr/share/groff_font/devps \
308    usr/share/groff_font/devutf8 \
309    usr/share/tmac/mdoc usr/share/tmac/mm
310	mkdir -p ${WORLDTMP}/legacy/${_dir}
311.endfor
312.for _dir in \
313    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
314    usr/libexec usr/sbin usr/share/misc \
315    usr/share/snmp/defs usr/share/snmp/mibs
316	mkdir -p ${WORLDTMP}/${_dir}
317.endfor
318	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
319	    -p ${WORLDTMP}/usr/include >/dev/null
320	ln -sf ${.CURDIR}/sys ${WORLDTMP}
321.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
322	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
323	    -p ${WORLDTMP}/usr/include >/dev/null
324.endif
325_legacy:
326	@echo
327	@echo "--------------------------------------------------------------"
328	@echo ">>> stage 1.1: legacy release compatibility shims"
329	@echo "--------------------------------------------------------------"
330	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
331_bootstrap-tools:
332	@echo
333	@echo "--------------------------------------------------------------"
334	@echo ">>> stage 1.2: bootstrap tools"
335	@echo "--------------------------------------------------------------"
336	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
337_cleanobj:
338.if !defined(NO_CLEAN)
339	@echo
340	@echo "--------------------------------------------------------------"
341	@echo ">>> stage 2.1: cleaning up the object tree"
342	@echo "--------------------------------------------------------------"
343	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
344.if ${TARGET_ARCH} == "amd64"
345	rm -rf ${OBJTREE}/lib32
346.endif
347.endif
348_obj:
349	@echo
350	@echo "--------------------------------------------------------------"
351	@echo ">>> stage 2.2: rebuilding the object tree"
352	@echo "--------------------------------------------------------------"
353	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
354_build-tools:
355	@echo
356	@echo "--------------------------------------------------------------"
357	@echo ">>> stage 2.3: build tools"
358	@echo "--------------------------------------------------------------"
359	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
360_cross-tools:
361	@echo
362	@echo "--------------------------------------------------------------"
363	@echo ">>> stage 3: cross tools"
364	@echo "--------------------------------------------------------------"
365	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
366_includes:
367	@echo
368	@echo "--------------------------------------------------------------"
369	@echo ">>> stage 4.1: building includes"
370	@echo "--------------------------------------------------------------"
371	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
372_libraries:
373	@echo
374	@echo "--------------------------------------------------------------"
375	@echo ">>> stage 4.2: building libraries"
376	@echo "--------------------------------------------------------------"
377	${_+_}cd ${.CURDIR}; \
378	    ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN \
379	    -DNO_NLS -DNO_PROFILE libraries
380_depend:
381	@echo
382	@echo "--------------------------------------------------------------"
383	@echo ">>> stage 4.3: make dependencies"
384	@echo "--------------------------------------------------------------"
385	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
386everything:
387	@echo
388	@echo "--------------------------------------------------------------"
389	@echo ">>> stage 4.4: building everything"
390	@echo "--------------------------------------------------------------"
391	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
392.if ${TARGET_ARCH} == "amd64"
393build32:
394	@echo
395	@echo "--------------------------------------------------------------"
396	@echo ">>> stage 5.1: building 32 bit shim libraries"
397	@echo "--------------------------------------------------------------"
398.for _dir in \
399    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
400    usr/libexec usr/sbin usr/share/misc \
401    usr/share/snmp/defs usr/share/snmp/mibs
402	mkdir -p ${LIB32TMP}/${_dir}
403.endfor
404	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
405	    -p ${LIB32TMP}/usr/include >/dev/null
406	mkdir -p ${WORLDTMP}
407	ln -sf ${.CURDIR}/sys ${WORLDTMP}
408.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
409.for _t in obj depend all
410	cd ${.CURDIR}/kerberos5/tools; \
411	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
412.endfor
413.endif
414.for _t in obj includes
415	cd ${.CURDIR}/include; \
416	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
417	cd ${.CURDIR}/lib; \
418	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419	cd ${.CURDIR}/gnu/lib; \
420	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
421.if !defined(NO_CRYPT)
422	cd ${.CURDIR}/secure/lib; \
423	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
424.endif
425.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
426	cd ${.CURDIR}/kerberos5/lib; \
427	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
428.endif
429.endfor
430.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
431	cd ${.CURDIR}/${_dir}; \
432	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
433.endfor
434.for _dir in lib/libncurses lib/libmagic
435	cd ${.CURDIR}/${_dir}; \
436	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
437.endfor
438	cd ${.CURDIR}; \
439	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
440.for _t in obj depend all
441	cd ${.CURDIR}/libexec/rtld-elf; \
442	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
443.endfor
444
445distribute32 install32:
446.if make(distribute32)
447	mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32	# XXX add to mtree
448.else
449	mkdir -p ${DESTDIR}/usr/lib32			# XXX add to mtree
450.endif
451	cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
452	cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
453.if !defined(NO_CRYPT)
454	cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
455.endif
456	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
457.endif
458
459
460WMAKE_TGTS=
461.if !defined(SUBDIR_OVERRIDE)
462WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
463.endif
464WMAKE_TGTS+=	_cleanobj _obj _build-tools
465.if !defined(SUBDIR_OVERRIDE)
466WMAKE_TGTS+=	_cross-tools
467.endif
468WMAKE_TGTS+=	_includes _libraries _depend everything
469.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
470WMAKE_TGTS+=	build32
471.endif
472
473buildworld: ${WMAKE_TGTS}
474.ORDER: ${WMAKE_TGTS}
475
476buildenv:
477	@echo Entering world for ${TARGET_ARCH}:${TARGET}
478	@cd ${.CURDIR} && env ${WMAKEENV} sh || true
479
480TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
481toolchain: ${TOOLCHAIN_TGTS}
482kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
483
484#
485# installcheck
486#
487# Checks to be sure system is ready for installworld/installkernel.
488#
489installcheck:
490
491#
492# Require DESTDIR to be set if installing for a different architecture.
493#
494.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
495.if !make(distributeworld)
496installcheck: installcheck_DESTDIR
497installcheck_DESTDIR:
498.if !defined(DESTDIR) || empty(DESTDIR)
499	@echo "ERROR: Please set DESTDIR!"; \
500	false
501.endif
502.endif
503.endif
504
505#
506# Check for missing UIDs/GIDs.
507#
508CHECK_UIDS=
509CHECK_GIDS=	audit
510.if !defined(NO_SENDMAIL)
511CHECK_UIDS+=	smmsp
512CHECK_GIDS+=	smmsp
513.endif
514.if !defined(NO_PF)
515CHECK_UIDS+=	proxy
516CHECK_GIDS+=	proxy authpf
517.endif
518installcheck: installcheck_UGID
519installcheck_UGID:
520.for uid in ${CHECK_UIDS}
521	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
522		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
523		false; \
524	fi
525.endfor
526.for gid in ${CHECK_GIDS}
527	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
528		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
529		false; \
530	fi
531.endfor
532
533#
534# distributeworld
535#
536# Distributes everything compiled by a `buildworld'.
537#
538# installworld
539#
540# Installs everything compiled by a 'buildworld'.
541#
542distributeworld installworld: installcheck
543	mkdir -p ${INSTALLTMP}
544	for prog in [ awk cap_mkdb cat chflags chmod chown \
545	    date echo egrep find grep install-info \
546	    ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
547	    test true uname wc zic; do \
548		cp `which $$prog` ${INSTALLTMP}; \
549	done
550	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
551	rm -rf ${INSTALLTMP}
552
553#
554# reinstall
555#
556# If you have a build server, you can NFS mount the source and obj directories
557# and do a 'make reinstall' on the *client* to install new binaries from the
558# most recent server build.
559#
560reinstall:
561	@echo "--------------------------------------------------------------"
562	@echo ">>> Making hierarchy"
563	@echo "--------------------------------------------------------------"
564	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
565	@echo
566	@echo "--------------------------------------------------------------"
567	@echo ">>> Installing everything"
568	@echo "--------------------------------------------------------------"
569	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
570.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
571	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
572.endif
573
574redistribute:
575	@echo "--------------------------------------------------------------"
576	@echo ">>> Distributing everything"
577	@echo "--------------------------------------------------------------"
578	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
579.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
580	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
581.endif
582
583distrib-dirs distribution:
584	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
585
586#
587# buildkernel and installkernel
588#
589# Which kernels to build and/or install is specified by setting
590# KERNCONF. If not defined a GENERIC kernel is built/installed.
591# Only the existing (depending TARGET) config files are used
592# for building kernels and only the first of these is designated
593# as the one being installed.
594#
595# Note that we have to use TARGET instead of TARGET_ARCH when
596# we're in kernel-land. Since only TARGET_ARCH is (expected) to
597# be set to cross-build, we have to make sure TARGET is set
598# properly.
599
600.if !defined(KERNCONF) && defined(KERNEL)
601KERNCONF=	${KERNEL}
602KERNWARN=
603.else
604KERNCONF?=	GENERIC
605.endif
606INSTKERNNAME?=	kernel
607
608KERNSRCDIR?=	${.CURDIR}/sys
609KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
610KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
611KERNCONFDIR?=	${KRNLCONFDIR}
612
613BUILDKERNELS=
614INSTALLKERNEL=
615.for _kernel in ${KERNCONF}
616.if exists(${KERNCONFDIR}/${_kernel})
617BUILDKERNELS+=	${_kernel}
618.if empty(INSTALLKERNEL)
619INSTALLKERNEL= ${_kernel}
620.endif
621.endif
622.endfor
623
624#
625# buildkernel
626#
627# Builds all kernels defined by BUILDKERNELS.
628#
629buildkernel:
630.if empty(BUILDKERNELS)
631	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
632	false
633.endif
634.if defined(KERNWARN)
635	@echo "--------------------------------------------------------------"
636	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
637	@echo "--------------------------------------------------------------"
638	@sleep 3
639.endif
640	@echo
641.for _kernel in ${BUILDKERNELS}
642	@echo "--------------------------------------------------------------"
643	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
644	@echo "--------------------------------------------------------------"
645	@echo "===> ${_kernel}"
646	mkdir -p ${KRNLOBJDIR}
647.if !defined(NO_KERNELCONFIG)
648	@echo
649	@echo "--------------------------------------------------------------"
650	@echo ">>> stage 1: configuring the kernel"
651	@echo "--------------------------------------------------------------"
652	cd ${KRNLCONFDIR}; \
653		PATH=${TMPPATH} \
654		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
655			${KERNCONFDIR}/${_kernel}
656.endif
657.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
658	@echo
659	@echo "--------------------------------------------------------------"
660	@echo ">>> stage 2.1: cleaning up the object tree"
661	@echo "--------------------------------------------------------------"
662	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
663.endif
664	@echo
665	@echo "--------------------------------------------------------------"
666	@echo ">>> stage 2.2: rebuilding the object tree"
667	@echo "--------------------------------------------------------------"
668	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
669	@echo
670	@echo "--------------------------------------------------------------"
671	@echo ">>> stage 2.3: build tools"
672	@echo "--------------------------------------------------------------"
673	cd ${KRNLOBJDIR}/${_kernel}; \
674	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
675	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
676# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
677.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
678.for target in obj depend all
679	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
680	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
681	    ${MAKE} -DNO_CPU_CFLAGS ${target}
682.endfor
683.endif
684.if !defined(NO_KERNELDEPEND)
685	@echo
686	@echo "--------------------------------------------------------------"
687	@echo ">>> stage 3.1: making dependencies"
688	@echo "--------------------------------------------------------------"
689	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
690.endif
691	@echo
692	@echo "--------------------------------------------------------------"
693	@echo ">>> stage 3.2: building everything"
694	@echo "--------------------------------------------------------------"
695	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
696	@echo "--------------------------------------------------------------"
697	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
698	@echo "--------------------------------------------------------------"
699.endfor
700
701#
702# installkernel, etc.
703#
704# Install the kernel defined by INSTALLKERNEL
705#
706installkernel installkernel.debug \
707reinstallkernel reinstallkernel.debug: installcheck
708.if empty(INSTALLKERNEL)
709	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
710	false
711.endif
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
827.if ${BOOTSTRAPPING} < 700014
828_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
829.endif
830
831bootstrap-tools:
832.for _tool in \
833    ${_strfile} \
834    ${_gperf} \
835    ${_groff} \
836    ${_texinfo} \
837    ${_cap_mkdb} \
838    ${_colldef} \
839    ${_gencat} \
840    usr.bin/lorder \
841    usr.bin/makewhatis \
842    ${_mklocale} \
843    usr.bin/rpcgen \
844    usr.bin/xinstall \
845    usr.sbin/config \
846    ${_gensnmptree} \
847    ${_crunchgen} \
848    ${_pwd_mkdb}
849	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
850		cd ${.CURDIR}/${_tool}; \
851		${MAKE} DIRPRFX=${_tool}/ obj; \
852		${MAKE} DIRPRFX=${_tool}/ depend; \
853		${MAKE} DIRPRFX=${_tool}/ all; \
854		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
855.endfor
856
857#
858# build-tools: Build special purpose build tools
859#
860.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
861_aicasm= sys/modules/aic7xxx/aicasm
862.endif
863
864.if !defined(NO_SHARE)
865_share=	share/syscons/scrnmaps
866.endif
867
868.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
869_kerberos5_tools= kerberos5/tools
870.endif
871
872.if !defined(NO_RESCUE)
873_rescue= rescue/rescue
874.endif
875
876build-tools:
877.for _tool in \
878    bin/csh \
879    bin/sh \
880    ${_rescue} \
881    lib/libncurses \
882    ${_share} \
883    ${_aicasm} \
884    usr.bin/awk \
885    lib/libmagic \
886    usr.sbin/sysinstall
887	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
888		cd ${.CURDIR}/${_tool}; \
889		${MAKE} DIRPRFX=${_tool}/ obj; \
890		${MAKE} DIRPRFX=${_tool}/ build-tools
891.endfor
892.for _tool in \
893    gnu/usr.bin/cc/cc_tools \
894    ${_kerberos5_tools}
895	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
896		cd ${.CURDIR}/${_tool}; \
897		${MAKE} DIRPRFX=${_tool}/ obj; \
898		${MAKE} DIRPRFX=${_tool}/ depend; \
899		${MAKE} DIRPRFX=${_tool}/ all
900.endfor
901
902#
903# cross-tools: Build cross-building tools
904#
905.if ${TARGET_ARCH} != ${MACHINE_ARCH}
906.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
907_btxld=		usr.sbin/btxld
908.endif
909.if !defined(NO_RESCUE) || defined(RELEASEDIR)
910_crunchide=	usr.sbin/crunch/crunchide
911.endif
912.if ${TARGET_ARCH} == "alpha"
913_elf2exe=	usr.sbin/elf2exe
914.endif
915.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
916_kgzip=		usr.sbin/kgzip
917.endif
918.endif
919
920cross-tools:
921.for _tool in \
922    gnu/usr.bin/binutils \
923    gnu/usr.bin/cc \
924    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
925    ${_btxld} \
926    ${_crunchide} \
927    ${_elf2exe} \
928    ${_kgzip}
929	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
930		cd ${.CURDIR}/${_tool}; \
931		${MAKE} DIRPRFX=${_tool}/ obj; \
932		${MAKE} DIRPRFX=${_tool}/ depend; \
933		${MAKE} DIRPRFX=${_tool}/ all; \
934		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
935.endfor
936
937#
938# hierarchy - ensure that all the needed directories are present
939#
940hierarchy:
941	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
942
943#
944# libraries - build all libraries, and install them under ${DESTDIR}.
945#
946# The list of libraries with dependents (${_prebuild_libs}) and their
947# interdependencies (__L) are built automatically by the
948# ${.CURDIR}/tools/make_libdeps.sh script.
949#
950libraries:
951	cd ${.CURDIR}; \
952	    ${MAKE} -f Makefile.inc1 _startup_libs; \
953	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
954	    ${MAKE} -f Makefile.inc1 _generic_libs;
955
956# These dependencies are not automatically generated:
957#
958# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
959# shared libraries for ELF.
960#
961_startup_libs=	gnu/lib/csu gnu/lib/libgcc
962.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
963_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
964.else
965_startup_libs+=	lib/csu/${MACHINE_ARCH}
966.endif
967
968_prebuild_libs=
969
970_generic_libs=	gnu/lib
971
972.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
973_prebuild_libs+=	kerberos5/lib/libasn1
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 lib/libgssapi
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: lib/libgssapi__L
999.endif
1000.endif
1001.endif
1002_generic_libs+=	secure/lib
1003.endif
1004
1005.if defined(NO_CRYPT) || defined(NO_OPENSSL)
1006lib/libradius__L: lib/libmd__L
1007.endif
1008
1009.if !defined(NO_NIS)
1010_prebuild_libs+=	lib/libypclnt
1011.endif
1012
1013_generic_libs+=	usr.bin/lex/lib
1014
1015.if ${MACHINE} == "i386"
1016_generic_libs+=	usr.sbin/pcvt/keycap
1017.endif
1018
1019.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1020${_lib}__L: .PHONY
1021.if exists(${.CURDIR}/${_lib})
1022	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1023		cd ${.CURDIR}/${_lib}; \
1024		${MAKE} DIRPRFX=${_lib}/ depend; \
1025		${MAKE} DIRPRFX=${_lib}/ all; \
1026		${MAKE} DIRPRFX=${_lib}/ install
1027.endif
1028.endfor
1029
1030# libpam is special: we need to build static PAM modules before
1031# static PAM library, and dynamic PAM library before dynamic PAM
1032# modules.
1033lib/libpam__L: .PHONY
1034	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1035		cd ${.CURDIR}/lib/libpam; \
1036		${MAKE} DIRPRFX=lib/libpam/ depend; \
1037		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1038		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1039
1040_startup_libs: ${_startup_libs:S/$/__L/}
1041_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1042_generic_libs: ${_generic_libs:S/$/__L/}
1043
1044.for __target in all clean cleandepend cleandir depend includes obj
1045.for entry in ${SUBDIR}
1046${entry}.${__target}__D: .PHONY
1047	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1048		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1049		edir=${entry}.${MACHINE_ARCH}; \
1050		cd ${.CURDIR}/$${edir}; \
1051	else \
1052		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1053		edir=${entry}; \
1054		cd ${.CURDIR}/$${edir}; \
1055	fi; \
1056	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1057.endfor
1058par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1059.endfor
1060
1061.include <bsd.subdir.mk>
1062
1063.if make(delete-old) || make(delete-old-libs) || make(check-old)
1064
1065#
1066# check for / delete old files section
1067#
1068
1069.include "ObsoleteFiles.inc"
1070
1071OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1072else you can not start such an application. Consult UPDATING for more \
1073information regarding how to cope with the removal/revision bump of a \
1074specific library."
1075
1076.if !defined(BATCH_DELETE_OLD_FILES)
1077RM_I=-i
1078.else
1079RM_I=-v
1080.endif
1081
1082delete-old-files:
1083	@echo ">>> Removing old files (only deletes safe to delete libs)"
1084.for file in ${OLD_FILES}
1085# Ask for every old file if the user really wants to remove it.
1086# It's annoying, but better safe than sorry.
1087	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1088		rm ${RM_I} "${DESTDIR}/${file}" || true; \
1089		if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1090			echo "Removing schg flag on ${DESTDIR}/${file}"; \
1091			chflags noschg "${DESTDIR}/${file}"; \
1092			rm ${RM_I} "${DESTDIR}/${file}"; \
1093		fi; \
1094	fi
1095.endfor
1096# Remove catpages without corresponding manpages.
1097	@3<&0; \
1098	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1099	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1100	while read catpage; do \
1101		read manpage; \
1102		if [ ! -e "$${manpage}" ]; then \
1103			rm ${RM_I} $${catpage} <&3 ; \
1104	        fi; \
1105	done
1106	@echo ">>> Old files removed"
1107
1108check-old-files:
1109	@echo ">>> Checking for old files"
1110.for file in ${OLD_FILES}
1111	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1112		 echo "${DESTDIR}/${file}"; \
1113	fi
1114.endfor
1115# Check for catpages without corresponding manpages.
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			echo $${catpage} ; \
1122	        fi; \
1123	done
1124
1125delete-old-libs:
1126	@echo ">>> Removing old libraries"
1127	@echo "${OLD_LIBS_MESSAGE}" | fmt
1128.for file in ${OLD_LIBS}
1129	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1130		rm ${RM_I} "${DESTDIR}/${file}" || true; \
1131		if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1132			echo "Removing schg flag on ${DESTDIR}/${file}"; \
1133			chflags noschg "${DESTDIR}/${file}"; \
1134			rm ${RM_I} "${DESTDIR}/${file}"; \
1135		fi; \
1136	fi
1137.endfor
1138	@echo ">>> Old libraries removed"
1139
1140check-old-libs:
1141	@echo ">>> Checking for old libraries"
1142.for file in ${OLD_LIBS}
1143	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1144		echo "${DESTDIR}/${file}"; \
1145	fi
1146.endfor
1147
1148delete-old-dirs:
1149	@echo ">>> Removing old directories"
1150.for dir in ${OLD_DIRS}
1151# Don't fail if an old directory isn't empty.
1152	@if [ -d "${DESTDIR}/${dir}" ]; then \
1153		rmdir -v "${DESTDIR}/${dir}" || true; \
1154	else \
1155		if [ -L "${DESTDIR}/${dir}" ]; then \
1156			echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1157		fi; \
1158	fi
1159.endfor
1160	@echo ">>> Old directories removed"
1161
1162check-old-dirs:
1163	@echo ">>> Checking for old directories"
1164.for dir in ${OLD_DIRS}
1165	@if [ -d "${DESTDIR}/${dir}" ]; then \
1166		echo "${DESTDIR}/${dir}"; \
1167	else \
1168		if [ -L "${DESTDIR}/${dir}" ]; then \
1169			echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1170		fi; \
1171	fi
1172.endfor
1173
1174delete-old: delete-old-files delete-old-dirs
1175	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1176
1177check-old: check-old-files check-old-libs check-old-dirs
1178	@echo "To remove old files and directories run '${MAKE} delete-old'."
1179	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1180
1181.endif
1182
1183