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