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