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