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