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