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