Makefile.inc1 revision 156060
1#
2# $FreeBSD: head/Makefile.inc1 156060 2006-02-27 09:17:39Z 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
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} != ${MACHINE_ARCH}
901.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
902_btxld=		usr.sbin/btxld
903.endif
904.if !defined(NO_RESCUE) || 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 !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
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 !defined(NO_CRYPT)
986.if !defined(NO_OPENSSL)
987_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
988lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
989.if !defined(NO_OPENSSH)
990_prebuild_libs+=	secure/lib/libssh
991secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
992.if !defined(NO_KERBEROS)
993secure/lib/libssh__L: lib/libgssapi__L
994.endif
995.endif
996.endif
997_generic_libs+=	secure/lib
998.endif
999
1000.if defined(NO_CRYPT) || defined(NO_OPENSSL)
1001lib/libradius__L: lib/libmd__L
1002.endif
1003
1004.if !defined(NO_NIS)
1005_prebuild_libs+=	lib/libypclnt
1006.endif
1007
1008_generic_libs+=	usr.bin/lex/lib
1009
1010.if ${MACHINE_ARCH} == "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