Makefile.inc1 revision 178828
1234353Sdim#
2221337Sdim# $FreeBSD: head/Makefile.inc1 178828 2008-05-07 13:53:12Z dfr $
3221337Sdim#
4221337Sdim# Make command line options:
5221337Sdim#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6221337Sdim#	-DNO_CLEAN do not clean at all
7221337Sdim#	-DNO_SHARE do not go into share subdir
8221337Sdim#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9221337Sdim#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10221337Sdim#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11221337Sdim#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
12221337Sdim#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
13221337Sdim#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
14221337Sdim#	TARGET="machine" to crossbuild world for a different machine type
15221337Sdim
16249423Sdim#
17249423Sdim# The intended user-driven targets are:
18221337Sdim# buildworld  - rebuild *everything*, including glue to help do upgrades
19221337Sdim# installworld- install everything built by "buildworld"
20221337Sdim# doxygen     - build API documentation of the kernel
21221337Sdim# update      - convenient way to update your source tree (eg: cvsup/cvs)
22226633Sdim#
23226633Sdim# Standard targets (not defined here) are documented in the makefiles in
24226633Sdim# /usr/share/mk.  These include:
25221337Sdim#		obj depend all install clean cleandepend cleanobj
26221337Sdim
27221337Sdim.include <bsd.own.mk>
28234353Sdim
29226633Sdim# We must do share/info early so that installation of info `dir'
30221337Sdim# entries works correctly.  Do it first since it is less likely to
31221337Sdim# grow dependencies on include and lib than vice versa.
32221337Sdim#
33221337Sdim# We must do lib/ and libexec/ before bin/, because if installworld
34221337Sdim# installs a new /bin/sh, the 'make' command will *immediately*
35234353Sdim# use that new version.  And the new (dynamically-linked) /bin/sh
36221337Sdim# will expect to find appropriate libraries in /lib and /libexec.
37221337Sdim#
38221337SdimSUBDIR=	share/info lib libexec
39221337SdimSUBDIR+=bin
40221337Sdim.if ${MK_GAMES} != "no"
41221337SdimSUBDIR+=games
42239462Sdim.endif
43221337Sdim.if ${MK_CDDL} != "no"
44221337SdimSUBDIR+=cddl
45221337Sdim.endif
46221337SdimSUBDIR+=gnu include
47221337Sdim.if ${MK_KERBEROS} != "no"
48221337SdimSUBDIR+=kerberos5
49224145Sdim.endif
50224145Sdim.if ${MK_RESCUE} != "no"
51224145SdimSUBDIR+=rescue
52224145Sdim.endif
53224145SdimSUBDIR+=sbin
54224145Sdim.if ${MK_CRYPT} != "no"
55224145SdimSUBDIR+=secure
56224145Sdim.endif
57224145Sdim.if !defined(NO_SHARE)
58224145SdimSUBDIR+=share
59224145Sdim.endif
60224145SdimSUBDIR+=sys usr.bin usr.sbin
61221337Sdim#
62221337Sdim# We must do etc/ last for install/distribute to work.
63221337Sdim#
64239462SdimSUBDIR+=etc
65239462Sdim
66221337Sdim# These are last, since it is nice to at least get the base system
67221337Sdim# rebuilt before you do them.
68221337Sdim.for _DIR in ${LOCAL_DIRS}
69221337Sdim.if exists(${.CURDIR}/${_DIR}/Makefile)
70239462SdimSUBDIR+= ${_DIR}
71239462Sdim.endif
72239462Sdim.endfor
73221337Sdim
74221337Sdim.if defined(SUBDIR_OVERRIDE)
75221337SdimSUBDIR=		${SUBDIR_OVERRIDE}
76221337Sdim.endif
77221337Sdim
78221337Sdim.if defined(NOCLEAN)
79224145SdimNO_CLEAN=	${NOCLEAN}
80221337Sdim.endif
81221337Sdim.if defined(NO_CLEANDIR)
82221337SdimCLEANDIR=	clean cleandepend
83221337Sdim.else
84221337SdimCLEANDIR=	cleandir
85221337Sdim.endif
86221337Sdim
87239462SdimCVS?=		cvs
88239462SdimCVSFLAGS?=	-A -P -d -I!
89239462SdimSUP?=		/usr/bin/csup
90239462SdimSUPFLAGS?=	-g -L 2
91239462Sdim.if defined(SUPHOST)
92221337SdimSUPFLAGS+=	-h ${SUPHOST}
93221337Sdim.endif
94221337Sdim
95221337SdimMAKEOBJDIRPREFIX?=	/usr/obj
96239462Sdim.if !defined(OSRELDATE)
97239462Sdim.if exists(/usr/include/osreldate.h)
98239462SdimOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
99221337Sdim		/usr/include/osreldate.h
100239462Sdim.else
101221337SdimOSRELDATE=	0
102221337Sdim.endif
103221337Sdim.endif
104221337Sdim
105221337Sdim# Guess machine architecture from machine type, and vice versa.
106221337Sdim.if !defined(TARGET_ARCH) && defined(TARGET)
107221337SdimTARGET_ARCH=	${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
108221337Sdim.elif !defined(TARGET) && defined(TARGET_ARCH) && \
109221337Sdim    ${TARGET_ARCH} != ${MACHINE_ARCH}
110221337SdimTARGET=		${TARGET_ARCH}
111221337Sdim.endif
112239462Sdim# Otherwise, default to current machine type and architecture.
113239462SdimTARGET?=	${MACHINE}
114239462SdimTARGET_ARCH?=	${MACHINE_ARCH}
115239462Sdim
116239462SdimKNOWN_ARCHES?=	amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
117239462Sdim.if ${TARGET} == ${TARGET_ARCH}
118239462Sdim_t=		${TARGET}
119239462Sdim.else
120239462Sdim_t=		${TARGET_ARCH}/${TARGET}
121239462Sdim.endif
122239462Sdim.for _t in ${_t}
123239462Sdim.if empty(KNOWN_ARCHES:M${_t})
124239462Sdim.error Unknown target ${TARGET_ARCH}:${TARGET}.
125239462Sdim.endif
126221337Sdim.endfor
127221337Sdim
128221337Sdim.if ${TARGET} == ${MACHINE}
129221337SdimTARGET_CPUTYPE?=${CPUTYPE}
130221337Sdim.else
131234353SdimTARGET_CPUTYPE?=
132234353Sdim.endif
133221337Sdim
134221337Sdim.if !empty(TARGET_CPUTYPE)
135221337Sdim_TARGET_CPUTYPE=${TARGET_CPUTYPE}
136221337Sdim.else
137239462Sdim_TARGET_CPUTYPE=dummy
138239462Sdim.endif
139239462Sdim_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
140221337Sdim		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
141221337Sdim.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
142221337Sdim.error CPUTYPE global should be set with ?=.
143221337Sdim.endif
144221337Sdim.if make(buildworld)
145221337SdimBUILD_ARCH!=	uname -p
146221337Sdim.if ${MACHINE_ARCH} != ${BUILD_ARCH}
147221337Sdim.error To cross-build, set TARGET_ARCH.
148221337Sdim.endif
149239462Sdim.endif
150239462Sdim.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
151239462SdimOBJTREE=	${MAKEOBJDIRPREFIX}
152239462Sdim.else
153239462SdimOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
154239462Sdim.endif
155239462SdimWORLDTMP=	${OBJTREE}${.CURDIR}/tmp
156239462Sdim# /usr/games added for fortune which depend on strfile
157239462SdimBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
158239462SdimXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
159239462SdimSTRICTTMPPATH=	${BPATH}:${XPATH}
160239462SdimTMPPATH=	${STRICTTMPPATH}:${PATH}
161239462Sdim
162234353Sdim#
163234353Sdim# Avoid running mktemp(1) unless actually needed.
164234353Sdim# It may not be functional, e.g., due to new ABI
165234353Sdim# when in the middle of installing over this system.
166234353Sdim#
167234353Sdim.if make(distributeworld) || make(installworld)
168234353SdimINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
169234353Sdim.endif
170234353Sdim
171234353Sdim#
172234353Sdim# Building a world goes through the following stages
173234353Sdim#
174221337Sdim# 1. legacy stage [BMAKE]
175221337Sdim#	This stage is responsible for creating compatibility
176221337Sdim#	shims that are needed by the bootstrap-tools,
177221337Sdim#	build-tools and cross-tools stages.
178221337Sdim# 1. bootstrap-tools stage [BMAKE]
179221337Sdim#	This stage is responsible for creating programs that
180221337Sdim#	are needed for backward compatibility reasons. They
181221337Sdim#	are not built as cross-tools.
182221337Sdim# 2. build-tools stage [TMAKE]
183221337Sdim#	This stage is responsible for creating the object
184221337Sdim#	tree and building any tools that are needed during
185221337Sdim#	the build process.
186221337Sdim# 3. cross-tools stage [XMAKE]
187221337Sdim#	This stage is responsible for creating any tools that
188221337Sdim#	are needed for cross-builds. A cross-compiler is one
189239462Sdim#	of them.
190239462Sdim# 4. world stage [WMAKE]
191221337Sdim#	This stage actually builds the world.
192221337Sdim# 5. install stage (optional) [IMAKE]
193221337Sdim#	This stage installs a previously built world.
194221337Sdim#
195221337Sdim
196221337SdimBOOTSTRAPPING?=	0
197221337Sdim
198221337Sdim# Common environment for world related stages
199221337SdimCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
200221337Sdim		MACHINE_ARCH=${TARGET_ARCH} \
201221337Sdim		MACHINE=${TARGET} \
202221337Sdim		CPUTYPE=${TARGET_CPUTYPE} \
203234353Sdim		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
204239462Sdim		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
205239462Sdim		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
206239462Sdim.if ${OSRELDATE} < 700044
207263508SdimCROSSENV+=	AR=gnu-ar RANLIB=gnu-ranlib
208263508Sdim.endif
209239462Sdim
210263508Sdim# bootstrap-tools stage
211263508SdimBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
212239462Sdim		PATH=${BPATH}:${PATH} \
213239462Sdim		WORLDTMP=${WORLDTMP} \
214239462Sdim		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
215239462SdimBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
216239462Sdim		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
217239462Sdim		DESTDIR= \
218239462Sdim		BOOTSTRAPPING=${OSRELDATE} \
219239462Sdim		-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
220239462Sdim		-DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
221234353Sdim		-DNO_CPU_CFLAGS -DNO_WARNS
222234353Sdim
223234353Sdim# build-tools stage
224234353SdimTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
225234353Sdim		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
226234353Sdim		TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
227234353Sdim		DESTDIR= \
228234353Sdim		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
229234353Sdim
230234353Sdim# cross-tools stage
231221337SdimXMAKE=		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} || ${BOOTSTRAPPING} < 800035
967.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
968_btxld=		usr.sbin/btxld
969.endif
970.endif
971.if ${TARGET_ARCH} != ${MACHINE_ARCH}
972.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
973_crunchide=	usr.sbin/crunch/crunchide
974.endif
975.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
976_kgzip=		usr.sbin/kgzip
977.endif
978.endif
979
980cross-tools:
981.for _tool in \
982    gnu/usr.bin/binutils \
983    gnu/usr.bin/cc \
984    usr.bin/sed \
985    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
986    ${_btxld} \
987    ${_crunchide} \
988    ${_kgzip}
989	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
990		cd ${.CURDIR}/${_tool}; \
991		${MAKE} DIRPRFX=${_tool}/ obj; \
992		${MAKE} DIRPRFX=${_tool}/ depend; \
993		${MAKE} DIRPRFX=${_tool}/ all; \
994		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
995.endfor
996
997#
998# hierarchy - ensure that all the needed directories are present
999#
1000hierarchy:
1001	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
1002
1003#
1004# libraries - build all libraries, and install them under ${DESTDIR}.
1005#
1006# The list of libraries with dependents (${_prebuild_libs}) and their
1007# interdependencies (__L) are built automatically by the
1008# ${.CURDIR}/tools/make_libdeps.sh script.
1009#
1010libraries:
1011	cd ${.CURDIR}; \
1012	    ${MAKE} -f Makefile.inc1 _prereq_libs; \
1013	    ${MAKE} -f Makefile.inc1 _startup_libs; \
1014	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1015	    ${MAKE} -f Makefile.inc1 _generic_libs;
1016
1017#
1018# static libgcc.a prerequisite for shared libc
1019#
1020_prereq_libs= gnu/lib/libgcc
1021
1022# These dependencies are not automatically generated:
1023#
1024# gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1025# all shared libraries for ELF.
1026#
1027_startup_libs=	gnu/lib/csu
1028.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1029_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
1030.else
1031_startup_libs+=	lib/csu/${MACHINE_ARCH}
1032.endif
1033_startup_libs+=	gnu/lib/libgcc
1034_startup_libs+=	lib/libc
1035
1036gnu/lib/libgcc__L: lib/libc__L
1037
1038_prebuild_libs=	${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1039		${_kerberos5_lib_libhx509} ${_kerberos5_lib_libroken} \
1040		${_kerberos5_lib_libheimntlm} ${_kerberos5_lib_libgssapi_krb5} \
1041		lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1042		${_lib_libgssapi} ${_lib_libipx} \
1043		lib/libkiconv lib/libkvm lib/libmd \
1044		lib/ncurses/ncurses lib/ncurses/ncursesw \
1045		lib/libopie lib/libpam ${_lib_libthr} \
1046		lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1047		${_lib_libypclnt} lib/libz lib/msun \
1048		${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1049		${_secure_lib_libssl}
1050
1051.if ${MK_LIBTHR} != "no"
1052_lib_libthr=	lib/libthr
1053.endif
1054
1055_generic_libs=	${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1056
1057lib/libopie__L lib/libtacplus__L: lib/libmd__L
1058
1059.if ${MK_CDDL} != "no"
1060_cddl_lib= cddl/lib
1061.endif
1062
1063.if ${MK_CRYPT} != "no"
1064.if ${MK_OPENSSL} != "no"
1065_secure_lib_libcrypto= secure/lib/libcrypto
1066_secure_lib_libssl= secure/lib/libssl
1067lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1068.if ${MK_OPENSSH} != "no"
1069_secure_lib_libssh= secure/lib/libssh
1070secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1071.if ${MK_KERBEROS} != "no"
1072kerberos5/lib/libgssapi_krb5__L: kerberos5/lib/libkrb5__L \
1073    kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1074    lib/libmd__L kerberos5/lib/libroken__L secure/lib/libcrypto__L \
1075    lib/libcrypt__L
1076secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libgssapi_krb5__L
1077.endif
1078.endif
1079.endif
1080_secure_lib=	secure/lib
1081.endif
1082
1083.if ${MK_IPX} != "no"
1084_lib_libipx=	lib/libipx
1085.endif
1086
1087.if ${MK_KERBEROS} != "no"
1088_kerberos5_lib=	kerberos5/lib
1089_kerberos5_lib_libasn1= kerberos5/lib/libasn1
1090_kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1091_kerberos5_lib_libhx509= kerberos5/lib/libhx509
1092_kerberos5_lib_libroken= kerberos5/lib/libroken
1093_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1094_kerberos5_lib_libgssapi_krb5= kerberos5/lib/libgssapi_krb5
1095_lib_libgssapi=	lib/libgssapi
1096.endif
1097
1098.if ${MK_NIS} != "no"
1099_lib_libypclnt=	lib/libypclnt
1100.endif
1101
1102.if ${MK_OPENSSL} == "no"
1103lib/libradius__L: lib/libmd__L
1104.endif
1105
1106.for _lib in ${_prereq_libs}
1107${_lib}__PL: .PHONY
1108.if exists(${.CURDIR}/${_lib})
1109	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1110		cd ${.CURDIR}/${_lib}; \
1111		${MAKE} DIRPRFX=${_lib}/ obj; \
1112		${MAKE} DIRPRFX=${_lib}/ depend; \
1113		${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1114		${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1115.endif
1116.endfor
1117
1118.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1119${_lib}__L: .PHONY
1120.if exists(${.CURDIR}/${_lib})
1121	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1122		cd ${.CURDIR}/${_lib}; \
1123		${MAKE} DIRPRFX=${_lib}/ obj; \
1124		${MAKE} DIRPRFX=${_lib}/ depend; \
1125		${MAKE} DIRPRFX=${_lib}/ all; \
1126		${MAKE} DIRPRFX=${_lib}/ install
1127.endif
1128.endfor
1129
1130# libpam is special: we need to build static PAM modules before
1131# static PAM library, and dynamic PAM library before dynamic PAM
1132# modules.
1133lib/libpam__L: .PHONY
1134	${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1135		cd ${.CURDIR}/lib/libpam; \
1136		${MAKE} DIRPRFX=lib/libpam/ obj; \
1137		${MAKE} DIRPRFX=lib/libpam/ depend; \
1138		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1139		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1140
1141_prereq_libs: ${_prereq_libs:S/$/__PL/}
1142_startup_libs: ${_startup_libs:S/$/__L/}
1143_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1144_generic_libs: ${_generic_libs:S/$/__L/}
1145
1146.for __target in all clean cleandepend cleandir depend includes obj
1147.for entry in ${SUBDIR}
1148${entry}.${__target}__D: .PHONY
1149	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1150		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1151		edir=${entry}.${MACHINE_ARCH}; \
1152		cd ${.CURDIR}/$${edir}; \
1153	else \
1154		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1155		edir=${entry}; \
1156		cd ${.CURDIR}/$${edir}; \
1157	fi; \
1158	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1159.endfor
1160par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1161.endfor
1162
1163.include <bsd.subdir.mk>
1164
1165.if make(check-old) || make(check-old-dirs) || \
1166    make(check-old-files) || make(check-old-libs) || \
1167    make(delete-old) || make(delete-old-dirs) || \
1168    make(delete-old-files) || make(delete-old-libs)
1169
1170#
1171# check for / delete old files section
1172#
1173
1174.include "ObsoleteFiles.inc"
1175
1176OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1177else you can not start such an application. Consult UPDATING for more \
1178information regarding how to cope with the removal/revision bump of a \
1179specific library."
1180
1181.if !defined(BATCH_DELETE_OLD_FILES)
1182RM_I=-i
1183.else
1184RM_I=-v
1185.endif
1186
1187delete-old-files:
1188	@echo ">>> Removing old files (only deletes safe to delete libs)"
1189# Ask for every old file if the user really wants to remove it.
1190# It's annoying, but better safe than sorry.
1191	@for file in ${OLD_FILES}; do \
1192		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1193			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1194			rm ${RM_I} "${DESTDIR}/$${file}"; \
1195		fi; \
1196	done
1197# Remove catpages without corresponding manpages.
1198	@3<&0; \
1199	find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1200	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1201	while read catpage; do \
1202		read manpage; \
1203		if [ ! -e "$${manpage}" ]; then \
1204			rm ${RM_I} $${catpage} <&3 ; \
1205	        fi; \
1206	done
1207	@echo ">>> Old files removed"
1208
1209check-old-files:
1210	@echo ">>> Checking for old files"
1211	@for file in ${OLD_FILES}; do \
1212		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1213		 	echo "${DESTDIR}/$${file}"; \
1214		fi; \
1215	done
1216# Check for catpages without corresponding manpages.
1217	@find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1218	sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1219	while read catpage; do \
1220		read manpage; \
1221		if [ ! -e "$${manpage}" ]; then \
1222			echo $${catpage} ; \
1223	        fi; \
1224	done
1225
1226delete-old-libs:
1227	@echo ">>> Removing old libraries"
1228	@echo "${OLD_LIBS_MESSAGE}" | fmt
1229	@for file in ${OLD_LIBS}; do \
1230		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1231			chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1232			rm ${RM_I} "${DESTDIR}/$${file}"; \
1233		fi; \
1234	done
1235	@echo ">>> Old libraries removed"
1236
1237check-old-libs:
1238	@echo ">>> Checking for old libraries"
1239	@for file in ${OLD_LIBS}; do \
1240		if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1241			echo "${DESTDIR}/$${file}"; \
1242		fi; \
1243	done
1244
1245delete-old-dirs:
1246	@echo ">>> Removing old directories"
1247	@for dir in ${OLD_DIRS}; do \
1248		if [ -d "${DESTDIR}/$${dir}" ]; then \
1249			rmdir -v "${DESTDIR}/$${dir}" || true; \
1250		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1251			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1252		fi; \
1253	done
1254	@echo ">>> Old directories removed"
1255
1256check-old-dirs:
1257	@echo ">>> Checking for old directories"
1258	@for dir in ${OLD_DIRS}; do \
1259		if [ -d "${DESTDIR}/$${dir}" ]; then \
1260			echo "${DESTDIR}/$${dir}"; \
1261		elif [ -L "${DESTDIR}/$${dir}" ]; then \
1262			echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1263		fi; \
1264	done
1265
1266delete-old: delete-old-files delete-old-dirs
1267	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1268
1269check-old: check-old-files check-old-libs check-old-dirs
1270	@echo "To remove old files and directories run '${MAKE} delete-old'."
1271	@echo "To remove old libraries run '${MAKE} delete-old-libs'."
1272
1273.endif
1274
1275#
1276# showconfig - show build configuration.
1277#
1278showconfig:
1279	@${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1280