Makefile.inc1 revision 156813
1#
2# $FreeBSD: head/Makefile.inc1 156813 2006-03-17 18:54:44Z ru $
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_PROFILE do not build profiled libraries
8#	-DNO_SHARE do not go into share subdir
9#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
13#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
14#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
15#	TARGET_ARCH="arch" to crossbuild world to a different arch
16
17#
18# The intended user-driven targets are:
19# buildworld  - rebuild *everything*, including glue to help do upgrades
20# installworld- install everything built by "buildworld"
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/local/bin/cvsup
84SUPFLAGS?=	-g -L 2 -P -
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
98TARGET_ARCH?=	${MACHINE_ARCH}
99.if ${TARGET_ARCH} == ${MACHINE_ARCH}
100TARGET?=	${MACHINE}
101TARGET_CPUTYPE?=${CPUTYPE}
102.else
103TARGET?=	${TARGET_ARCH}
104TARGET_CPUTYPE?=
105.endif
106.if !empty(TARGET_CPUTYPE)
107_TARGET_CPUTYPE=${TARGET_CPUTYPE}
108.else
109_TARGET_CPUTYPE=dummy
110.endif
111_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
112		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
113.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
114.error CPUTYPE global should be set with ?=.
115.endif
116.if make(buildworld)
117BUILD_ARCH!=	uname -p
118.if ${MACHINE_ARCH} != ${BUILD_ARCH}
119.error To cross-build, set TARGET_ARCH.
120.endif
121.endif
122.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
123OBJTREE=	${MAKEOBJDIRPREFIX}
124.else
125OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
126.endif
127WORLDTMP=	${OBJTREE}${.CURDIR}/tmp
128# /usr/games added for fortune which depend on strfile
129BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
130XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
131STRICTTMPPATH=	${BPATH}:${XPATH}
132TMPPATH=	${STRICTTMPPATH}:${PATH}
133
134INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
135
136#
137# Building a world goes through the following stages
138#
139# 1. legacy stage [BMAKE]
140#	This stage is responsible for creating compatibility
141#	shims that are needed by the bootstrap-tools,
142#	build-tools and cross-tools stages.
143# 1. bootstrap-tools stage [BMAKE]
144#	This stage is responsible for creating programs that
145#	are needed for backward compatibility reasons. They
146#	are not built as cross-tools.
147# 2. build-tools stage [TMAKE]
148#	This stage is responsible for creating the object
149#	tree and building any tools that are needed during
150#	the build process.
151# 3. cross-tools stage [XMAKE]
152#	This stage is responsible for creating any tools that
153#	are needed for cross-builds. A cross-compiler is one
154#	of them.
155# 4. world stage [WMAKE]
156#	This stage actually builds the world.
157# 5. install stage (optional) [IMAKE]
158#	This stage installs a previously built world.
159#
160
161BOOTSTRAPPING?=	0
162
163# Common environment for world related stages
164CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
165		MACHINE_ARCH=${TARGET_ARCH} \
166		MACHINE=${TARGET} \
167		CPUTYPE=${TARGET_CPUTYPE} \
168		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
169		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
170		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
171
172# bootstrap-tools stage
173BMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
174		PATH=${BPATH}:${PATH} \
175		WORLDTMP=${WORLDTMP} \
176		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
177BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
178		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
179		DESTDIR= \
180		BOOTSTRAPPING=${OSRELDATE} \
181		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
182		-DWITHOUT_NLS -DNO_PIC -DNO_PROFILE -DNO_SHARED \
183		-DNO_CPU_CFLAGS -DNO_WARNS
184
185# build-tools stage
186TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
187		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
188		DESTDIR= \
189		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
190
191# cross-tools stage
192XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
193		-DWITHOUT_FORTRAN -DWITHOUT_GDB
194
195# world stage
196WMAKEENV=	${CROSSENV} \
197		_SHLIBDIRPREFIX=${WORLDTMP} \
198		INSTALL="sh ${.CURDIR}/tools/install.sh" \
199		PATH=${TMPPATH}
200WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
201
202.if ${TARGET_ARCH} == "amd64"
203# 32 bit world
204LIB32TMP=	${OBJTREE}${.CURDIR}/lib32
205
206.if empty(TARGET_CPUTYPE)
207LIB32CPUTYPE=	k8
208.else
209LIB32CPUTYPE=	${TARGET_CPUTYPE}
210.endif
211LIB32PREFLAGS=	-m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT
212LIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
213		-L${LIB32TMP}/usr/lib32 \
214		-B${LIB32TMP}/usr/lib32
215LIB32CC=	${LIB32PREFLAGS} \
216		${LIB32POSTFLAGS}
217LIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
218		${LIB32POSTFLAGS}
219LIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
220		${LIB32POSTFLAGS}
221
222# Yes, the flags are redundant.
223LIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
224		_SHLIBDIRPREFIX=${LIB32TMP} \
225		MACHINE=i386 \
226		MACHINE_ARCH=i386 \
227		INSTALL="sh ${.CURDIR}/tools/install.sh" \
228		PATH=${TMPPATH} \
229		CC="${CC} ${LIB32CC}" \
230		CXX="${CXX} ${LIB32CXX}" \
231		OBJC="${OBJC} ${LIB32OBJC}" \
232		LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
233		AS="${AS} --32" \
234		LIBDIR=/usr/lib32 \
235		SHLIBDIR=/usr/lib32
236
237LIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
238		-DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
239		-DWITHOUT_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 ${MK_BIND_LIBS} != "no"
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 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
374	    -DWITHOUT_MAN -DWITHOUT_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 ${MK_KERBEROS} != "no"
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 ${MK_CRYPT} != "no"
417	cd ${.CURDIR}/secure/lib; \
418	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
419.endif
420.if ${MK_KERBEROS} != "no"
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 ${MK_CRYPT} != "no"
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# installcheck
481#
482# Checks to be sure system is ready for installworld/installkernel.
483#
484installcheck:
485
486#
487# Require DESTDIR to be set if installing for a different architecture.
488#
489.if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
490.if !make(distributeworld)
491installcheck: installcheck_DESTDIR
492installcheck_DESTDIR:
493.if !defined(DESTDIR) || empty(DESTDIR)
494	@echo "ERROR: Please set DESTDIR!"; \
495	false
496.endif
497.endif
498.endif
499
500#
501# Check for missing UIDs/GIDs.
502#
503CHECK_UIDS=
504CHECK_GIDS=	audit
505.if ${MK_SENDMAIL} != "no"
506CHECK_UIDS+=	smmsp
507CHECK_GIDS+=	smmsp
508.endif
509.if ${MK_PF} != "no"
510CHECK_UIDS+=	proxy
511CHECK_GIDS+=	proxy authpf
512.endif
513installcheck: installcheck_UGID
514installcheck_UGID:
515.for uid in ${CHECK_UIDS}
516	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
517		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
518		false; \
519	fi
520.endfor
521.for gid in ${CHECK_GIDS}
522	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
523		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
524		false; \
525	fi
526.endfor
527
528#
529# distributeworld
530#
531# Distributes everything compiled by a `buildworld'.
532#
533# installworld
534#
535# Installs everything compiled by a 'buildworld'.
536#
537distributeworld installworld: installcheck
538	mkdir -p ${INSTALLTMP}
539	for prog in [ awk cap_mkdb cat chflags chmod chown \
540	    date echo egrep find grep install-info \
541	    ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
542	    test true uname wc zic; do \
543		cp `which $$prog` ${INSTALLTMP}; \
544	done
545	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
546	rm -rf ${INSTALLTMP}
547
548#
549# reinstall
550#
551# If you have a build server, you can NFS mount the source and obj directories
552# and do a 'make reinstall' on the *client* to install new binaries from the
553# most recent server build.
554#
555reinstall:
556	@echo "--------------------------------------------------------------"
557	@echo ">>> Making hierarchy"
558	@echo "--------------------------------------------------------------"
559	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
560	@echo
561	@echo "--------------------------------------------------------------"
562	@echo ">>> Installing everything"
563	@echo "--------------------------------------------------------------"
564	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
565.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
566	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
567.endif
568
569redistribute:
570	@echo "--------------------------------------------------------------"
571	@echo ">>> Distributing everything"
572	@echo "--------------------------------------------------------------"
573	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
574.if ${TARGET_ARCH} == "amd64" && !defined(NO_LIB32)
575	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 DISTRIBUTION=lib32
576.endif
577
578distrib-dirs distribution:
579	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
580
581#
582# buildkernel and installkernel
583#
584# Which kernels to build and/or install is specified by setting
585# KERNCONF. If not defined a GENERIC kernel is built/installed.
586# Only the existing (depending TARGET) config files are used
587# for building kernels and only the first of these is designated
588# as the one being installed.
589#
590# Note that we have to use TARGET instead of TARGET_ARCH when
591# we're in kernel-land. Since only TARGET_ARCH is (expected) to
592# be set to cross-build, we have to make sure TARGET is set
593# properly.
594
595.if !defined(KERNCONF) && defined(KERNEL)
596KERNCONF=	${KERNEL}
597KERNWARN=
598.else
599KERNCONF?=	GENERIC
600.endif
601INSTKERNNAME?=	kernel
602
603KERNSRCDIR?=	${.CURDIR}/sys
604KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
605KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
606KERNCONFDIR?=	${KRNLCONFDIR}
607
608BUILDKERNELS=
609INSTALLKERNEL=
610.for _kernel in ${KERNCONF}
611.if exists(${KERNCONFDIR}/${_kernel})
612BUILDKERNELS+=	${_kernel}
613.if empty(INSTALLKERNEL)
614INSTALLKERNEL= ${_kernel}
615.endif
616.endif
617.endfor
618
619#
620# buildkernel
621#
622# Builds all kernels defined by BUILDKERNELS.
623#
624buildkernel:
625.if empty(BUILDKERNELS)
626	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
627	false
628.endif
629.if defined(KERNWARN)
630	@echo "--------------------------------------------------------------"
631	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
632	@echo "--------------------------------------------------------------"
633	@sleep 3
634.endif
635	@echo
636.for _kernel in ${BUILDKERNELS}
637	@echo "--------------------------------------------------------------"
638	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
639	@echo "--------------------------------------------------------------"
640	@echo "===> ${_kernel}"
641	mkdir -p ${KRNLOBJDIR}
642.if !defined(NO_KERNELCONFIG)
643	@echo
644	@echo "--------------------------------------------------------------"
645	@echo ">>> stage 1: configuring the kernel"
646	@echo "--------------------------------------------------------------"
647	cd ${KRNLCONFDIR}; \
648		PATH=${TMPPATH} \
649		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
650			${KERNCONFDIR}/${_kernel}
651.endif
652.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
653	@echo
654	@echo "--------------------------------------------------------------"
655	@echo ">>> stage 2.1: cleaning up the object tree"
656	@echo "--------------------------------------------------------------"
657	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
658.endif
659	@echo
660	@echo "--------------------------------------------------------------"
661	@echo ">>> stage 2.2: rebuilding the object tree"
662	@echo "--------------------------------------------------------------"
663	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
664	@echo
665	@echo "--------------------------------------------------------------"
666	@echo ">>> stage 2.3: build tools"
667	@echo "--------------------------------------------------------------"
668	cd ${KRNLOBJDIR}/${_kernel}; \
669	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
670	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
671# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
672.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
673.for target in obj depend all
674	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
675	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
676	    ${MAKE} -DNO_CPU_CFLAGS ${target}
677.endfor
678.endif
679.if !defined(NO_KERNELDEPEND)
680	@echo
681	@echo "--------------------------------------------------------------"
682	@echo ">>> stage 3.1: making dependencies"
683	@echo "--------------------------------------------------------------"
684	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
685.endif
686	@echo
687	@echo "--------------------------------------------------------------"
688	@echo ">>> stage 3.2: building everything"
689	@echo "--------------------------------------------------------------"
690	cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
691	@echo "--------------------------------------------------------------"
692	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
693	@echo "--------------------------------------------------------------"
694.endfor
695
696#
697# installkernel, etc.
698#
699# Install the kernel defined by INSTALLKERNEL
700#
701installkernel installkernel.debug \
702reinstallkernel reinstallkernel.debug: installcheck
703.if empty(INSTALLKERNEL)
704	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
705	false
706.endif
707	@echo "--------------------------------------------------------------"
708	@echo ">>> Installing kernel"
709	@echo "--------------------------------------------------------------"
710	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
711	    ${CROSSENV} PATH=${TMPPATH} \
712	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
713
714#
715# update
716#
717# Update the source tree, by running cvsup and/or running cvs to update to the
718# latest copy.
719#
720update:
721.if defined(SUP_UPDATE)
722	@echo "--------------------------------------------------------------"
723	@echo ">>> Running ${SUP}"
724	@echo "--------------------------------------------------------------"
725.if defined(SUPFILE)
726	@${SUP} ${SUPFLAGS} ${SUPFILE}
727.endif
728.if defined(SUPFILE1)
729	@${SUP} ${SUPFLAGS} ${SUPFILE1}
730.endif
731.if defined(SUPFILE2)
732	@${SUP} ${SUPFLAGS} ${SUPFILE2}
733.endif
734.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
735	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
736.endif
737.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
738	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
739.endif
740.endif
741.if defined(CVS_UPDATE)
742	@echo "--------------------------------------------------------------"
743	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
744	@echo "--------------------------------------------------------------"
745	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
746.endif
747
748#
749# ------------------------------------------------------------------------
750#
751# From here onwards are utility targets used by the 'make world' and
752# related targets.  If your 'world' breaks, you may like to try to fix
753# the problem and manually run the following targets to attempt to
754# complete the build.  Beware, this is *not* guaranteed to work, you
755# need to have a pretty good grip on the current state of the system
756# to attempt to manually finish it.  If in doubt, 'make world' again.
757#
758
759#
760# legacy: Build compatibility shims for the next three targets
761#
762legacy:
763.if ${BOOTSTRAPPING} < 503000
764	@echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
765	false
766.endif
767.for _tool in tools/build
768	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
769	    cd ${.CURDIR}/${_tool}; \
770	    ${MAKE} DIRPRFX=${_tool}/ obj; \
771	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
772	    ${MAKE} DIRPRFX=${_tool}/ depend; \
773	    ${MAKE} DIRPRFX=${_tool}/ all; \
774	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
775.endfor
776
777#
778# bootstrap-tools: Build tools needed for compatibility
779#
780.if ${MK_GAMES} != "no"
781_strfile=	games/fortune/strfile
782.endif
783
784.if ${MK_CXX} != "no"
785_gperf=		gnu/usr.bin/gperf
786.if ${BOOTSTRAPPING} < 700004
787_groff=		gnu/usr.bin/groff
788.else
789_groff=		gnu/usr.bin/groff/tmac
790.endif
791.endif
792
793.if ${BOOTSTRAPPING} < 600029
794_texinfo=	gnu/usr.bin/texinfo
795.endif
796
797.if ${BOOTSTRAPPING} < 600015
798_cap_mkdb=	usr.bin/cap_mkdb
799.endif
800
801.if ${BOOTSTRAPPING} < 600018
802_colldef=	usr.bin/colldef
803.endif
804
805.if ${BOOTSTRAPPING} < 600017
806_gencat=	usr.bin/gencat
807.endif
808
809.if ${BOOTSTRAPPING} < 600016
810_mklocale=	usr.bin/mklocale
811.endif
812
813.if ${MK_RESCUE} != "no" && \
814    ${BOOTSTRAPPING} < 600008
815_crunchgen=	usr.sbin/crunch/crunchgen
816.endif
817
818.if ${BOOTSTRAPPING} < 600020
819_pwd_mkdb=	usr.sbin/pwd_mkdb
820.endif
821
822.if ${BOOTSTRAPPING} < 700014
823_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
824.endif
825
826bootstrap-tools:
827.for _tool in \
828    ${_strfile} \
829    ${_gperf} \
830    ${_groff} \
831    ${_texinfo} \
832    ${_cap_mkdb} \
833    ${_colldef} \
834    ${_gencat} \
835    usr.bin/lorder \
836    usr.bin/makewhatis \
837    ${_mklocale} \
838    usr.bin/rpcgen \
839    usr.bin/xinstall \
840    usr.sbin/config \
841    ${_gensnmptree} \
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 ${MK_KERBEROS} != "no"
864_kerberos5_tools= kerberos5/tools
865.endif
866
867.if ${MK_RESCUE} != "no"
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} != ${MACHINE_ARCH}
901.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
902_btxld=		usr.sbin/btxld
903.endif
904.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
905_crunchide=	usr.sbin/crunch/crunchide
906.endif
907.if ${TARGET_ARCH} == "alpha"
908_elf2exe=	usr.sbin/elf2exe
909.endif
910.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
911_kgzip=		usr.sbin/kgzip
912.endif
913.endif
914
915cross-tools:
916.for _tool in \
917    gnu/usr.bin/binutils \
918    gnu/usr.bin/cc \
919    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
920    ${_btxld} \
921    ${_crunchide} \
922    ${_elf2exe} \
923    ${_kgzip}
924	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
925		cd ${.CURDIR}/${_tool}; \
926		${MAKE} DIRPRFX=${_tool}/ obj; \
927		${MAKE} DIRPRFX=${_tool}/ depend; \
928		${MAKE} DIRPRFX=${_tool}/ all; \
929		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
930.endfor
931
932#
933# hierarchy - ensure that all the needed directories are present
934#
935hierarchy:
936	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
937
938#
939# libraries - build all libraries, and install them under ${DESTDIR}.
940#
941# The list of libraries with dependents (${_prebuild_libs}) and their
942# interdependencies (__L) are built automatically by the
943# ${.CURDIR}/tools/make_libdeps.sh script.
944#
945libraries:
946	cd ${.CURDIR}; \
947	    ${MAKE} -f Makefile.inc1 _startup_libs; \
948	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
949	    ${MAKE} -f Makefile.inc1 _generic_libs;
950
951# These dependencies are not automatically generated:
952#
953# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
954# shared libraries for ELF.
955#
956_startup_libs=	gnu/lib/csu gnu/lib/libgcc
957.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
958_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
959.else
960_startup_libs+=	lib/csu/${MACHINE_ARCH}
961.endif
962
963_prebuild_libs=
964
965_generic_libs=	gnu/lib
966
967.if ${MK_KERBEROS} != "no"
968_prebuild_libs+=	kerberos5/lib/libasn1
969_prebuild_libs+=	kerberos5/lib/libkrb5
970_prebuild_libs+=	kerberos5/lib/libroken
971_generic_libs+=	kerberos5/lib
972.endif
973
974_prebuild_libs+= lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
975		lib/libipx lib/libkiconv lib/libkvm lib/libmd \
976		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
977		lib/libradius \
978		lib/libsbuf lib/libtacplus lib/libutil \
979		lib/libz lib/msun lib/libgssapi
980
981lib/libopie__L lib/libtacplus__L: lib/libmd__L
982
983_generic_libs+=	lib
984
985.if ${MK_CRYPT} != "no"
986.if ${MK_OPENSSL} != "no"
987_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
988lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
989.if ${MK_OPENSSH} != "no"
990_prebuild_libs+=	secure/lib/libssh
991secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
992.if ${MK_KERBEROS} != "no"
993secure/lib/libssh__L: lib/libgssapi__L
994.endif
995.endif
996.endif
997_generic_libs+=	secure/lib
998.endif
999
1000.if ${MK_OPENSSL} == "no"
1001lib/libradius__L: lib/libmd__L
1002.endif
1003
1004.if ${MK_NIS} != "no"
1005_prebuild_libs+=	lib/libypclnt
1006.endif
1007
1008_generic_libs+=	usr.bin/lex/lib
1009
1010.if ${MACHINE} == "i386"
1011_generic_libs+=	usr.sbin/pcvt/keycap
1012.endif
1013
1014.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1015${_lib}__L: .PHONY
1016.if exists(${.CURDIR}/${_lib})
1017	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1018		cd ${.CURDIR}/${_lib}; \
1019		${MAKE} DIRPRFX=${_lib}/ depend; \
1020		${MAKE} DIRPRFX=${_lib}/ all; \
1021		${MAKE} DIRPRFX=${_lib}/ install
1022.endif
1023.endfor
1024
1025# libpam is special: we need to build static PAM modules before
1026# static PAM library, and dynamic PAM library before dynamic PAM
1027# modules.
1028lib/libpam__L: .PHONY
1029	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1030		cd ${.CURDIR}/lib/libpam; \
1031		${MAKE} DIRPRFX=lib/libpam/ depend; \
1032		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1033		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1034
1035_startup_libs: ${_startup_libs:S/$/__L/}
1036_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1037_generic_libs: ${_generic_libs:S/$/__L/}
1038
1039.for __target in all clean cleandepend cleandir depend includes obj
1040.for entry in ${SUBDIR}
1041${entry}.${__target}__D: .PHONY
1042	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1043		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1044		edir=${entry}.${MACHINE_ARCH}; \
1045		cd ${.CURDIR}/$${edir}; \
1046	else \
1047		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1048		edir=${entry}; \
1049		cd ${.CURDIR}/$${edir}; \
1050	fi; \
1051	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1052.endfor
1053par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1054.endfor
1055
1056.include <bsd.subdir.mk>
1057
1058.if make(delete-old) || make(delete-old-libs) || make(check-old)
1059
1060#
1061# check for / delete old files section
1062#
1063
1064.include "ObsoleteFiles.inc"
1065
1066OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1067else you can not start such an application. Consult UPDATING for more \
1068information regarding how to cope with the removal/revision bump of a \
1069specific library."
1070
1071.if !defined(BATCH_DELETE_OLD_FILES)
1072RM_I=-i
1073.else
1074RM_I=-v
1075.endif
1076
1077delete-old-files:
1078	@echo ">>> Removing old files (only deletes safe to delete libs)"
1079.for file in ${OLD_FILES}
1080# Ask for every old file if the user really wants to remove it.
1081# It's annoying, but better safe than sorry.
1082	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1083		rm ${RM_I} "${DESTDIR}/${file}" || true; \
1084		if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1085			echo "Removing schg flag on ${DESTDIR}/${file}"; \
1086			chflags noschg "${DESTDIR}/${file}"; \
1087			rm ${RM_I} "${DESTDIR}/${file}"; \
1088		fi; \
1089	fi
1090.endfor
1091# Remove catpages without corresponding manpages.
1092	@3<&0; \
1093	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1094	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1095	while read catpage; do \
1096		read manpage; \
1097		if [ ! -e "$${manpage}" ]; then \
1098			rm ${RM_I} $${catpage} <&3 ; \
1099	        fi; \
1100	done
1101	@echo ">>> Old files removed"
1102
1103check-old-files:
1104	@echo ">>> Checking for old files"
1105.for file in ${OLD_FILES}
1106	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1107		 echo "${DESTDIR}/${file}"; \
1108	fi
1109.endfor
1110# Check for catpages without corresponding manpages.
1111	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1112	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1113	while read catpage; do \
1114		read manpage; \
1115		if [ ! -e "$${manpage}" ]; then \
1116			echo $${catpage} ; \
1117	        fi; \
1118	done
1119
1120delete-old-libs:
1121	@echo ">>> Removing old libraries"
1122	@echo "${OLD_LIBS_MESSAGE}" | fmt
1123.for file in ${OLD_LIBS}
1124	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1125		rm ${RM_I} "${DESTDIR}/${file}" || true; \
1126		if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then\
1127			echo "Removing schg flag on ${DESTDIR}/${file}"; \
1128			chflags noschg "${DESTDIR}/${file}"; \
1129			rm ${RM_I} "${DESTDIR}/${file}"; \
1130		fi; \
1131	fi
1132.endfor
1133	@echo ">>> Old libraries removed"
1134
1135check-old-libs:
1136	@echo ">>> Checking for old libraries"
1137.for file in ${OLD_LIBS}
1138	@if [ -f "${DESTDIR}/${file}" -o -L "${DESTDIR}/${file}" ]; then \
1139		echo "${DESTDIR}/${file}"; \
1140	fi
1141.endfor
1142
1143delete-old-dirs:
1144	@echo ">>> Removing old directories"
1145.for dir in ${OLD_DIRS}
1146# Don't fail if an old directory isn't empty.
1147	@if [ -d "${DESTDIR}/${dir}" ]; then \
1148		rmdir -v "${DESTDIR}/${dir}" || true; \
1149	else \
1150		if [ -L "${DESTDIR}/${dir}" ]; then \
1151			echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1152		fi; \
1153	fi
1154.endfor
1155	@echo ">>> Old directories removed"
1156
1157check-old-dirs:
1158	@echo ">>> Checking for old directories"
1159.for dir in ${OLD_DIRS}
1160	@if [ -d "${DESTDIR}/${dir}" ]; then \
1161		echo "${DESTDIR}/${dir}"; \
1162	else \
1163		if [ -L "${DESTDIR}/${dir}" ]; then \
1164			echo "${DESTDIR}/${dir} is a link, please remove everything manually."; \
1165		fi; \
1166	fi
1167.endfor
1168
1169delete-old: delete-old-files delete-old-dirs
1170	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1171
1172check-old: check-old-files check-old-libs check-old-dirs
1173	@echo "To remove old files and directories run '${MAKE} delete-old'."
1174	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1175
1176.endif
1177
1178