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