Makefile.inc1 revision 142683
145405Smsmith#
245405Smsmith# $FreeBSD: head/Makefile.inc1 142683 2005-02-27 19:13:41Z ru $
345405Smsmith#
445405Smsmith# Make command line options:
545405Smsmith#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
645405Smsmith#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
745405Smsmith#	-DNO_RESCUE do not build rescue binaries
845405Smsmith#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
945405Smsmith#	-DNO_CLEAN do not clean at all
1045405Smsmith#	-DNO_CRYPT will prevent building of crypt versions
1145405Smsmith#	-DNO_MAN do not build the manual pages
1245405Smsmith#	-DNO_PROFILE do not build profiled libraries
1345405Smsmith#	-DNO_GAMES do not go into games subdir
1445405Smsmith#	-DNO_SHARE do not go into share subdir
1545405Smsmith#	-DNO_INFO do not make or install info files
1645405Smsmith#	-DNO_LIBC_R do not build libc_r.
1745405Smsmith#	-DNO_FORTRAN do not build g77 and related libraries.
1845405Smsmith#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1945405Smsmith#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
2045405Smsmith#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
2145405Smsmith#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
2245405Smsmith#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2345405Smsmith#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2445405Smsmith#	TARGET_ARCH="arch" to crossbuild world to a different arch
2545405Smsmith
2645405Smsmith#
2745405Smsmith# The intended user-driven targets are:
2845405Smsmith# buildworld  - rebuild *everything*, including glue to help do upgrades
2945405Smsmith# installworld- install everything built by "buildworld"
3045405Smsmith# update      - convenient way to update your source tree (eg: cvsup/cvs)
3145405Smsmith#
3245405Smsmith# Standard targets (not defined here) are documented in the makefiles in
3345405Smsmith# /usr/share/mk.  These include:
3445405Smsmith#		obj depend all install clean cleandepend cleanobj
3545405Smsmith
3645405Smsmith# We must do share/info early so that installation of info `dir'
3745405Smsmith# entries works correctly.  Do it first since it is less likely to
3845405Smsmith# grow dependencies on include and lib than vice versa.
3945405Smsmith#
4045405Smsmith# We must do lib and libexec before bin, because if installworld
4145405Smsmith# installs a new /bin/sh, the 'make' command will *immediately*
4245405Smsmith# use that new version.  And the new (dynamically-linked) /bin/sh
4345405Smsmith# will expect to find appropriate libraries in /lib and /libexec.
4445405Smsmith#
4545405Smsmith# We must do etc last for install/distribute to work.
4645405Smsmith#
4745405SmsmithSUBDIR=	share/info include lib libexec bin
4845405Smsmith.if !defined(NO_GAMES)
4945405SmsmithSUBDIR+=games
5045405Smsmith.endif
5145405SmsmithSUBDIR+=gnu
5245405Smsmith.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
5345405SmsmithSUBDIR+=kerberos5
5445405Smsmith.endif
5545405Smsmith.if !defined(NO_RESCUE)
5645405SmsmithSUBDIR+=rescue
5745405Smsmith.endif
5845405SmsmithSUBDIR+=sbin
5945405Smsmith.if !defined(NO_CRYPT)
6045405SmsmithSUBDIR+=secure
6145405Smsmith.endif
6245405Smsmith.if !defined(NO_SHARE)
6345405SmsmithSUBDIR+=share
6445405Smsmith.endif
6545405SmsmithSUBDIR+=sys usr.bin usr.sbin etc
6645405Smsmith
6745405Smsmith# These are last, since it is nice to at least get the base system
6845405Smsmith# rebuilt before you do them.
6945405Smsmith.for _DIR in ${LOCAL_DIRS}
7045405Smsmith.if exists(${.CURDIR}/${_DIR}/Makefile)
7145405SmsmithSUBDIR+= ${_DIR}
7245405Smsmith.endif
7345405Smsmith.endfor
7445405Smsmith
7545405Smsmith.if defined(SUBDIR_OVERRIDE)
7645405SmsmithSUBDIR=		${SUBDIR_OVERRIDE}
7745405Smsmith.endif
7845405Smsmith
7945405Smsmith.if defined(NO_CLEANDIR)
8045405SmsmithCLEANDIR=	clean cleandepend
8145405Smsmith.else
8245405SmsmithCLEANDIR=	cleandir
8345405Smsmith.endif
8445405Smsmith
8545405SmsmithCVS?=		cvs
8645405SmsmithCVSFLAGS?=	-A -P -d -I!
8745405SmsmithSUP?=		/usr/local/bin/cvsup
8845405SmsmithSUPFLAGS?=	-g -L 2 -P -
8945405Smsmith.if defined(SUPHOST)
9045405SmsmithSUPFLAGS+=	-h ${SUPHOST}
9145405Smsmith.endif
9245405Smsmith
9345405SmsmithMAKEOBJDIRPREFIX?=	/usr/obj
9445405Smsmith.if !defined(OSRELDATE)
9545405Smsmith.if exists(/usr/include/osreldate.h)
9645405SmsmithOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
9745405Smsmith		/usr/include/osreldate.h
9845405Smsmith.else
9945405SmsmithOSRELDATE=	0
10045405Smsmith.endif
10145405Smsmith.endif
10245405SmsmithTARGET_ARCH?=	${MACHINE_ARCH}
10345405Smsmith.if ${TARGET_ARCH} == ${MACHINE_ARCH}
10445405SmsmithTARGET?=	${MACHINE}
10545405SmsmithTARGET_CPUTYPE?=${CPUTYPE}
10645405Smsmith.else
10745405SmsmithTARGET?=	${TARGET_ARCH}
10845405SmsmithTARGET_CPUTYPE?=
10945405Smsmith.endif
11045405Smsmith.if !empty(TARGET_CPUTYPE)
11145405Smsmith_TARGET_CPUTYPE=${TARGET_CPUTYPE}
11245405Smsmith.else
11345405Smsmith_TARGET_CPUTYPE=dummy
11445405Smsmith.endif
11545405Smsmith_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
11645405Smsmith		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
11745405Smsmith.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
11845405Smsmith.error CPUTYPE global should be set with ?=.
11945405Smsmith.endif
12045405Smsmith.if make(buildworld)
12145405SmsmithBUILD_ARCH!=	sysctl -n hw.machine_arch
12245405Smsmith.if ${MACHINE_ARCH} != ${BUILD_ARCH}
12345405Smsmith.error To cross-build, set TARGET_ARCH.
12445405Smsmith.endif
12545405Smsmith.endif
12645405Smsmith.if ${MACHINE} == ${TARGET}
12745405SmsmithOBJTREE=	${MAKEOBJDIRPREFIX}
12845405Smsmith.else
12945405SmsmithOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
13045405Smsmith.endif
13145405SmsmithWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
13245405Smsmith# /usr/games added for fortune which depend on strfile
13345405SmsmithBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
13445405SmsmithXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
13545405SmsmithSTRICTTMPPATH=	${BPATH}:${XPATH}
13645405SmsmithTMPPATH=	${STRICTTMPPATH}:${PATH}
13745405Smsmith
13845405SmsmithINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
13945405Smsmith
14045405Smsmith#
14145405Smsmith# Building a world goes through the following stages
14245405Smsmith#
14345405Smsmith# 1. legacy stage [BMAKE]
14445405Smsmith#	This stage is responsible for creating compatibility
14545405Smsmith#	shims that are needed by the bootstrap-tools,
14645405Smsmith#	build-tools and cross-tools stages.
14745405Smsmith# 1. bootstrap-tools stage [BMAKE]
14845405Smsmith#	This stage is responsible for creating programs that
14945405Smsmith#	are needed for backward compatibility reasons. They
15045405Smsmith#	are not built as cross-tools.
15145405Smsmith# 2. build-tools stage [TMAKE]
15245405Smsmith#	This stage is responsible for creating the object
15345405Smsmith#	tree and building any tools that are needed during
15445405Smsmith#	the build process.
15545405Smsmith# 3. cross-tools stage [XMAKE]
15645405Smsmith#	This stage is responsible for creating any tools that
15745405Smsmith#	are needed for cross-builds. A cross-compiler is one
15845405Smsmith#	of them.
15945405Smsmith# 4. world stage [WMAKE]
16045405Smsmith#	This stage actually builds the world.
16145405Smsmith# 5. install stage (optional) [IMAKE]
16245405Smsmith#	This stage installs a previously built world.
16345405Smsmith#
16445405Smsmith
16545405SmsmithBOOTSTRAPPING?=	0
16645405Smsmith
16745405Smsmith# Common environment for world related stages
16845405SmsmithCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
16945405Smsmith		MACHINE_ARCH=${TARGET_ARCH} \
17045405Smsmith		MACHINE=${TARGET} \
17145405Smsmith		CPUTYPE=${TARGET_CPUTYPE} \
17245405Smsmith		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
17345405Smsmith		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
17445405Smsmith		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
17545405Smsmith
17645405Smsmith# bootstrap-tools stage
17745405SmsmithBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
17845405Smsmith		PATH=${BPATH}:${PATH} \
17945405Smsmith		WORLDTMP=${WORLDTMP} \
18045405Smsmith		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
18145405SmsmithBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
18245405Smsmith		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
18345405Smsmith		DESTDIR= \
18445405Smsmith		BOOTSTRAPPING=${OSRELDATE} \
18545405Smsmith		-DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PIC -DNO_PROFILE \
18645405Smsmith		-DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
18745405Smsmith
18845405Smsmith# build-tools stage
18945405SmsmithTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
19045405Smsmith		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
19145405Smsmith		DESTDIR= \
19245405Smsmith		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
19345405Smsmith
19445405Smsmith# cross-tools stage
19545405SmsmithXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
19645405Smsmith
19745405Smsmith# world stage
19845405SmsmithWMAKEENV=	${CROSSENV} \
19945405Smsmith		_SHLIBDIRPREFIX=${WORLDTMP} \
20045405Smsmith		INSTALL="sh ${.CURDIR}/tools/install.sh" \
20145405Smsmith		PATH=${TMPPATH}
20245405SmsmithWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
20345405Smsmith
20445405Smsmith.if ${MACHINE_ARCH} == "amd64"
20545405Smsmith# 32 bit world
20645405SmsmithLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
20745405Smsmith
20845405SmsmithLIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
20945405SmsmithLIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
21045405Smsmith		-L${LIB32TMP}/usr/lib32 \
21145405Smsmith		-B${LIB32TMP}/usr/lib32
21245405SmsmithLIB32CC=	${LIB32PREFLAGS} \
21345405Smsmith		${LIB32POSTFLAGS}
21445405SmsmithLIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
21545405Smsmith		${LIB32POSTFLAGS}
21645405SmsmithLIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
21745405Smsmith		${LIB32POSTFLAGS}
21845405Smsmith
21945405Smsmith# Yes, the flags are redundant.
22045405SmsmithLIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
22145405Smsmith		_SHLIBDIRPREFIX=${LIB32TMP} \
22245405Smsmith		MACHINE_ARCH=i386 \
22345405Smsmith		INSTALL="sh ${.CURDIR}/tools/install.sh" \
22445405Smsmith		PATH=${TMPPATH} \
22545405Smsmith		CC="cc ${LIB32CC}" \
22645405Smsmith		CXX="c++ ${LIB32CXX}" \
22745405Smsmith		OBJC="cc ${LIB32OBJC}" \
22845405Smsmith		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
22945405Smsmith		AS="as --32" \
23045405Smsmith		LIBDIR=/usr/lib32 \
23145405Smsmith		SHLIBDIR=/usr/lib32
23245405Smsmith
23345405SmsmithLIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
23445405Smsmith		-DNO_BIND -DNO_MAN -DNO_INFO -DNO_HTML \
23545405Smsmith		CC="cc ${LIB32CC}" \
23645405Smsmith		CXX="c++ ${LIB32CXX}" \
23745405Smsmith		OBJC="cc ${LIB32OBJC}" \
23845405Smsmith		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
23945405Smsmith		AS="as --32" \
24045405Smsmith		LIBDIR=/usr/lib32 \
24145405Smsmith		SHLIBDIR=/usr/lib32
24245405Smsmith.endif
24345405Smsmith
24445405Smsmith# install stage
24545405Smsmith.if empty(.MAKEFLAGS:M-n)
24645405SmsmithIMAKEENV=	${CROSSENV} \
24745405Smsmith		PATH=${STRICTTMPPATH}:${INSTALLTMP}
24845405Smsmith.else
24945405SmsmithIMAKEENV=	${CROSSENV} \
25045405Smsmith		PATH=${TMPPATH}:${INSTALLTMP}
25145405Smsmith.endif
25245405SmsmithIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
25345405Smsmith
25445405Smsmith# kernel stage
25545405SmsmithKMAKEENV=	${WMAKEENV}
25645405Smsmith
25745405Smsmith#
25845405Smsmith# buildworld
25945405Smsmith#
26045405Smsmith# Attempt to rebuild the entire system, with reasonable chance of
26145405Smsmith# success, regardless of how old your existing system is.
26245405Smsmith#
26345405Smsmith_worldtmp:
26445405Smsmith.if ${.CURDIR:C/[^,]//g} != ""
26545405Smsmith#	The m4 build of sendmail files doesn't like it if ',' is used
26645405Smsmith#	anywhere in the path of it's files.
26745405Smsmith	@echo
26845405Smsmith	@echo "*** Error: path to source tree contains a comma ','"
26945405Smsmith	@echo
27045405Smsmith	false
27145405Smsmith.endif
27245405Smsmith	@echo
27345405Smsmith	@echo "--------------------------------------------------------------"
27445405Smsmith	@echo ">>> Rebuilding the temporary build tree"
27545405Smsmith	@echo "--------------------------------------------------------------"
27645405Smsmith.if !defined(NO_CLEAN)
27745405Smsmith	rm -rf ${WORLDTMP}
27845405Smsmith.else
27945405Smsmith	rm -rf ${WORLDTMP}/legacy/usr/include
28045405Smsmith	# XXX - These two can depend on any header file.
28145405Smsmith	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
28245405Smsmith	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
28345405Smsmith.endif
28445405Smsmith.for _dir in \
28545405Smsmith    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
28645405Smsmith    usr/libexec usr/sbin usr/share/dict \
28745405Smsmith    usr/share/groff_font/devX100 \
28845405Smsmith    usr/share/groff_font/devX100-12 \
28945405Smsmith    usr/share/groff_font/devX75 \
29045405Smsmith    usr/share/groff_font/devX75-12 \
29145405Smsmith    usr/share/groff_font/devascii \
29245405Smsmith    usr/share/groff_font/devcp1047 \
29345405Smsmith    usr/share/groff_font/devdvi \
29445405Smsmith    usr/share/groff_font/devhtml \
29545405Smsmith    usr/share/groff_font/devkoi8-r \
29645405Smsmith    usr/share/groff_font/devlatin1 \
29745405Smsmith    usr/share/groff_font/devlbp \
29845405Smsmith    usr/share/groff_font/devlj4 \
29945405Smsmith    usr/share/groff_font/devps \
30045405Smsmith    usr/share/groff_font/devutf8 \
30145405Smsmith    usr/share/tmac/mdoc usr/share/tmac/mm
30245405Smsmith	mkdir -p ${WORLDTMP}/legacy/${_dir}
30345405Smsmith.endfor
30445405Smsmith.for _dir in \
30545405Smsmith    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
30645405Smsmith    usr/libexec usr/sbin usr/share/misc \
30745405Smsmith    usr/share/snmp/defs usr/share/snmp/mibs
30845405Smsmith	mkdir -p ${WORLDTMP}/${_dir}
30945405Smsmith.endfor
31045405Smsmith	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
31145405Smsmith	    -p ${WORLDTMP}/usr/include >/dev/null
31245405Smsmith	ln -sf ${.CURDIR}/sys ${WORLDTMP}
31345405Smsmith.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
31445405Smsmith	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
31545405Smsmith	    -p ${WORLDTMP}/usr/include >/dev/null
31645405Smsmith.endif
31745405Smsmith_legacy:
31845405Smsmith	@echo
31945405Smsmith	@echo "--------------------------------------------------------------"
32045405Smsmith	@echo ">>> stage 1.1: legacy release compatibility shims"
32145405Smsmith	@echo "--------------------------------------------------------------"
32245405Smsmith	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
32345405Smsmith_bootstrap-tools:
32445405Smsmith	@echo
32545405Smsmith	@echo "--------------------------------------------------------------"
32645405Smsmith	@echo ">>> stage 1.2: bootstrap tools"
32745405Smsmith	@echo "--------------------------------------------------------------"
32845405Smsmith	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
32945405Smsmith_cleanobj:
33045405Smsmith.if !defined(NO_CLEAN)
33145405Smsmith	@echo
33245405Smsmith	@echo "--------------------------------------------------------------"
33345405Smsmith	@echo ">>> stage 2.1: cleaning up the object tree"
33445405Smsmith	@echo "--------------------------------------------------------------"
33545405Smsmith	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
33645405Smsmith.endif
33745405Smsmith_obj:
33845405Smsmith	@echo
33945405Smsmith	@echo "--------------------------------------------------------------"
34045405Smsmith	@echo ">>> stage 2.2: rebuilding the object tree"
34145405Smsmith	@echo "--------------------------------------------------------------"
34245405Smsmith	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
34345405Smsmith_build-tools:
34445405Smsmith	@echo
34545405Smsmith	@echo "--------------------------------------------------------------"
34645405Smsmith	@echo ">>> stage 2.3: build tools"
34745405Smsmith	@echo "--------------------------------------------------------------"
34845405Smsmith	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
34945405Smsmith_cross-tools:
35045405Smsmith	@echo
35145405Smsmith	@echo "--------------------------------------------------------------"
35245405Smsmith	@echo ">>> stage 3: cross tools"
35345405Smsmith	@echo "--------------------------------------------------------------"
35445405Smsmith	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
35545405Smsmith_includes:
35645405Smsmith	@echo
35745405Smsmith	@echo "--------------------------------------------------------------"
35845405Smsmith	@echo ">>> stage 4.1: building includes"
35945405Smsmith	@echo "--------------------------------------------------------------"
36045405Smsmith	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
36145405Smsmith_libraries:
36245405Smsmith	@echo
36345405Smsmith	@echo "--------------------------------------------------------------"
36445405Smsmith	@echo ">>> stage 4.2: building libraries"
36545405Smsmith	@echo "--------------------------------------------------------------"
36645405Smsmith	${_+_}cd ${.CURDIR}; \
36745405Smsmith	    ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PROFILE \
36845405Smsmith	    libraries
36945405Smsmith_depend:
37045405Smsmith	@echo
37145405Smsmith	@echo "--------------------------------------------------------------"
37245405Smsmith	@echo ">>> stage 4.3: make dependencies"
37345405Smsmith	@echo "--------------------------------------------------------------"
37445405Smsmith	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
37545405Smsmitheverything:
37645405Smsmith	@echo
37745405Smsmith	@echo "--------------------------------------------------------------"
37845405Smsmith	@echo ">>> stage 4.4: building everything"
37945405Smsmith	@echo "--------------------------------------------------------------"
38045405Smsmith	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
38145405Smsmith.if ${MACHINE_ARCH} == "amd64"
38245405Smsmithbuild32:
38345405Smsmith	@echo
38445405Smsmith	@echo "--------------------------------------------------------------"
38545405Smsmith	@echo ">>> stage 5.1: building 32 bit shim libraries"
38645405Smsmith	@echo "--------------------------------------------------------------"
38745405Smsmith.for _dir in \
38845405Smsmith    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
38945405Smsmith    usr/libexec usr/sbin usr/share/misc \
39045405Smsmith    usr/share/snmp/defs usr/share/snmp/mibs
39145405Smsmith	mkdir -p ${LIB32TMP}/${_dir}
39245405Smsmith.endfor
39345405Smsmith	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
39445405Smsmith	    -p ${LIB32TMP}/usr/include >/dev/null
39545405Smsmith	ln -sf ${.CURDIR}/sys ${WORLDTMP}
39645405Smsmith.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
39745405Smsmith.for _t in obj depend all
39845405Smsmith	cd ${.CURDIR}/kerberos5/tools; \
39945405Smsmith	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
40045405Smsmith.endfor
40145405Smsmith.endif
40245405Smsmith.for _t in obj includes
40345405Smsmith	cd ${.CURDIR}/include; \
40445405Smsmith	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
40545405Smsmith	cd ${.CURDIR}/lib; \
40645405Smsmith	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
40745405Smsmith	cd ${.CURDIR}/gnu/lib; \
40845405Smsmith	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
40945405Smsmith.if !defined(NO_CRYPT)
41045405Smsmith	cd ${.CURDIR}/secure/lib; \
41145405Smsmith	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
41245405Smsmith.endif
41345405Smsmith.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
41445405Smsmith	cd ${.CURDIR}/kerberos5/lib; \
41545405Smsmith	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
41645405Smsmith.endif
41745405Smsmith.endfor
41845405Smsmith.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
41945405Smsmith	cd ${.CURDIR}/${_dir}; \
42045405Smsmith	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
42145405Smsmith.endfor
42245405Smsmith.for _dir in lib/libncurses lib/libmagic
42345405Smsmith	cd ${.CURDIR}/${_dir}; \
42445405Smsmith	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
42545405Smsmith.endfor
42645405Smsmith	cd ${.CURDIR}; \
42745405Smsmith	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
42845405Smsmith.for _t in obj depend all
42945405Smsmith	cd ${.CURDIR}/libexec/rtld-elf; \
43045405Smsmith	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
43145405Smsmith.endfor
43245405Smsmith
43345405Smsmithinstall32:
43445405Smsmith	mkdir -p ${DESTDIR}/usr/lib32	# XXX add to mtree
43545405Smsmith	cd ${.CURDIR}/lib; ${LIB32MAKE} install
43645405Smsmith	cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
43745405Smsmith.if !defined(NO_CRYPT)
43845405Smsmith	cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
43945405Smsmith.endif
44045405Smsmith	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
44145405Smsmith.endif
44245405Smsmith
44345405Smsmith
44445405SmsmithWMAKE_TGTS=
44545405Smsmith.if !defined(SUBDIR_OVERRIDE)
44645405SmsmithWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
44745405Smsmith.endif
44845405SmsmithWMAKE_TGTS+=	_cleanobj _obj _build-tools
44945405Smsmith.if !defined(SUBDIR_OVERRIDE)
45045405SmsmithWMAKE_TGTS+=	_cross-tools
45145405Smsmith.endif
45245405SmsmithWMAKE_TGTS+=	_includes _libraries _depend everything
45345405Smsmith.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
45445405SmsmithWMAKE_TGTS+=	build32
45545405Smsmith.endif
45645405Smsmith
45745405Smsmithbuildworld: ${WMAKE_TGTS}
45845405Smsmith.ORDER: ${WMAKE_TGTS}
45945405Smsmith
46045405Smsmithbuildenv:
46145405Smsmith	@echo Entering world for ${TARGET_ARCH}:${TARGET}
46245405Smsmith	@cd ${.CURDIR} && env ${WMAKEENV} sh || true
46345405Smsmith
46445405SmsmithTOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
46545405Smsmithtoolchain: ${TOOLCHAIN_TGTS}
46645405Smsmithkernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
46745405Smsmith
46845405Smsmith#
46945405Smsmith# Use this to add checks to installworld/installkernel targets.
47045405Smsmith#
47145405SmsmithSPECIAL_INSTALLCHECKS=
47245405Smsmith
47345405Smsmith#
47445405Smsmith# installcheck
47545405Smsmith#
47645405Smsmith# Checks to be sure system is ready for installworld
47745405Smsmith#
47845405SmsmithCHECK_UIDS=
47945405SmsmithCHECK_GIDS=
48045405Smsmith.if !defined(NO_SENDMAIL)
48145405SmsmithCHECK_UIDS+=	smmsp
48245405SmsmithCHECK_GIDS+=	smmsp
48345405Smsmith.endif
48445405Smsmith.if !defined(NO_PF)
48545405SmsmithCHECK_UIDS+=	proxy
48645405SmsmithCHECK_GIDS+=	proxy authpf
48745405Smsmith.endif
48845405Smsmithinstallcheck: ${SPECIAL_INSTALLCHECKS}
48945405Smsmith.for uid in ${CHECK_UIDS}
49045405Smsmith	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
49145405Smsmith		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
49245405Smsmith		false; \
49345405Smsmith	fi
49445405Smsmith.endfor
49545405Smsmith.for gid in ${CHECK_GIDS}
49645405Smsmith	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
49745405Smsmith		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
49845405Smsmith		false; \
49945405Smsmith	fi
50045405Smsmith.endfor
50145405Smsmith
50245405Smsmith#
50345405Smsmith# distributeworld
50445405Smsmith#
50545405Smsmith# Distributes everything compiled by a `buildworld'.
50645405Smsmith#
50745405Smsmith# installworld
50845405Smsmith#
50945405Smsmith# Installs everything compiled by a 'buildworld'.
51045405Smsmith#
51145405Smsmithdistributeworld installworld: installcheck
51245405Smsmith	mkdir -p ${INSTALLTMP}
51345405Smsmith	for prog in [ awk cap_mkdb cat chflags chmod chown \
51445405Smsmith	    date echo egrep find grep \
51545405Smsmith	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
51645405Smsmith	    test true uname wc zic; do \
51745405Smsmith		cp `which $$prog` ${INSTALLTMP}; \
51845405Smsmith	done
51945405Smsmith	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
52045405Smsmith	rm -rf ${INSTALLTMP}
52145405Smsmith
52245405Smsmith#
52345405Smsmith# reinstall
52445405Smsmith#
52545405Smsmith# If you have a build server, you can NFS mount the source and obj directories
52645405Smsmith# and do a 'make reinstall' on the *client* to install new binaries from the
52745405Smsmith# most recent server build.
52845405Smsmith#
52945405Smsmithreinstall: ${SPECIAL_INSTALLCHECKS}
53045405Smsmith	@echo "--------------------------------------------------------------"
53145405Smsmith	@echo ">>> Making hierarchy"
53245405Smsmith	@echo "--------------------------------------------------------------"
53345405Smsmith	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
53445405Smsmith	@echo
53545405Smsmith	@echo "--------------------------------------------------------------"
53645405Smsmith	@echo ">>> Installing everything"
53745405Smsmith	@echo "--------------------------------------------------------------"
53845405Smsmith	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
53945405Smsmith.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
54045405Smsmith	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
54145405Smsmith.endif
54245405Smsmith
54345405Smsmithredistribute:
54445405Smsmith	@echo "--------------------------------------------------------------"
54545405Smsmith	@echo ">>> Distributing everything"
54645405Smsmith	@echo "--------------------------------------------------------------"
54745405Smsmith	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
54845405Smsmith
54945405Smsmithdistribution:
55045405Smsmith	cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} distribution
55145405Smsmith
55245405Smsmith#
55345405Smsmith# buildkernel and installkernel
55445405Smsmith#
555# Which kernels to build and/or install is specified by setting
556# KERNCONF. If not defined a GENERIC kernel is built/installed.
557# Only the existing (depending TARGET) config files are used
558# for building kernels and only the first of these is designated
559# as the one being installed.
560#
561# Note that we have to use TARGET instead of TARGET_ARCH when
562# we're in kernel-land. Since only TARGET_ARCH is (expected) to
563# be set to cross-build, we have to make sure TARGET is set
564# properly.
565
566.if !defined(KERNCONF) && defined(KERNEL)
567KERNCONF=	${KERNEL}
568KERNWARN=
569.else
570KERNCONF?=	GENERIC
571.endif
572INSTKERNNAME?=	kernel
573
574KERNSRCDIR?=	${.CURDIR}/sys
575KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
576KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
577KERNCONFDIR?=	${KRNLCONFDIR}
578
579BUILDKERNELS=
580INSTALLKERNEL=
581.for _kernel in ${KERNCONF}
582.if exists(${KERNCONFDIR}/${_kernel})
583BUILDKERNELS+=	${_kernel}
584.if empty(INSTALLKERNEL)
585INSTALLKERNEL= ${_kernel}
586.endif
587.endif
588.endfor
589
590#
591# buildkernel
592#
593# Builds all kernels defined by BUILDKERNELS.
594#
595buildkernel:
596.if empty(BUILDKERNELS)
597	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
598	false
599.endif
600.if defined(KERNWARN)
601	@echo "--------------------------------------------------------------"
602	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
603	@echo "--------------------------------------------------------------"
604	@sleep 3
605.endif
606	@echo
607.for _kernel in ${BUILDKERNELS}
608	@echo "--------------------------------------------------------------"
609	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
610	@echo "--------------------------------------------------------------"
611	@echo "===> ${_kernel}"
612	mkdir -p ${KRNLOBJDIR}
613.if !defined(NO_KERNELCONFIG)
614	@echo
615	@echo "--------------------------------------------------------------"
616	@echo ">>> stage 1: configuring the kernel"
617	@echo "--------------------------------------------------------------"
618	cd ${KRNLCONFDIR}; \
619		PATH=${TMPPATH} \
620		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
621			${KERNCONFDIR}/${_kernel}
622.endif
623.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
624	@echo
625	@echo "--------------------------------------------------------------"
626	@echo ">>> stage 2.1: cleaning up the object tree"
627	@echo "--------------------------------------------------------------"
628	cd ${KRNLOBJDIR}/${_kernel}; \
629	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
630.endif
631	@echo
632	@echo "--------------------------------------------------------------"
633	@echo ">>> stage 2.2: rebuilding the object tree"
634	@echo "--------------------------------------------------------------"
635	cd ${KRNLOBJDIR}/${_kernel}; \
636	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
637	@echo
638	@echo "--------------------------------------------------------------"
639	@echo ">>> stage 2.3: build tools"
640	@echo "--------------------------------------------------------------"
641	cd ${KRNLOBJDIR}/${_kernel}; \
642	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
643	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
644# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
645.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
646.for target in obj depend all
647	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
648	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
649	    ${MAKE} -DNO_CPU_CFLAGS ${target}
650.endfor
651.endif
652.if !defined(NO_KERNELDEPEND)
653	@echo
654	@echo "--------------------------------------------------------------"
655	@echo ">>> stage 3.1: making dependencies"
656	@echo "--------------------------------------------------------------"
657	cd ${KRNLOBJDIR}/${_kernel}; \
658	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
659.endif
660	@echo
661	@echo "--------------------------------------------------------------"
662	@echo ">>> stage 3.2: building everything"
663	@echo "--------------------------------------------------------------"
664	cd ${KRNLOBJDIR}/${_kernel}; \
665	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
666	@echo "--------------------------------------------------------------"
667	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
668	@echo "--------------------------------------------------------------"
669.endfor
670
671#
672# installkernel, etc.
673#
674# Install the kernel defined by INSTALLKERNEL
675#
676installkernel installkernel.debug \
677reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
678.if empty(INSTALLKERNEL)
679	@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
680	false
681.endif
682	@echo "--------------------------------------------------------------"
683	@echo ">>> Making hierarchy"
684	@echo "--------------------------------------------------------------"
685	cd ${.CURDIR}; \
686	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
687	@echo
688	@echo "--------------------------------------------------------------"
689	@echo ">>> Installing kernel"
690	@echo "--------------------------------------------------------------"
691	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
692	    ${CROSSENV} PATH=${TMPPATH} \
693	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
694
695#
696# update
697#
698# Update the source tree, by running cvsup and/or running cvs to update to the
699# latest copy.
700#
701update:
702.if defined(SUP_UPDATE)
703	@echo "--------------------------------------------------------------"
704	@echo ">>> Running ${SUP}"
705	@echo "--------------------------------------------------------------"
706.if defined(SUPFILE)
707	@${SUP} ${SUPFLAGS} ${SUPFILE}
708.endif
709.if defined(SUPFILE1)
710	@${SUP} ${SUPFLAGS} ${SUPFILE1}
711.endif
712.if defined(SUPFILE2)
713	@${SUP} ${SUPFLAGS} ${SUPFILE2}
714.endif
715.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
716	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
717.endif
718.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
719	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
720.endif
721.endif
722.if defined(CVS_UPDATE)
723	@echo "--------------------------------------------------------------"
724	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
725	@echo "--------------------------------------------------------------"
726	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
727.endif
728
729#
730# ------------------------------------------------------------------------
731#
732# From here onwards are utility targets used by the 'make world' and
733# related targets.  If your 'world' breaks, you may like to try to fix
734# the problem and manually run the following targets to attempt to
735# complete the build.  Beware, this is *not* guaranteed to work, you
736# need to have a pretty good grip on the current state of the system
737# to attempt to manually finish it.  If in doubt, 'make world' again.
738#
739
740#
741# legacy: Build compatibility shims for the next three targets
742#
743legacy:
744.if ${BOOTSTRAPPING} < 503000
745	@echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
746	false
747.endif
748.for _tool in tools/build
749	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
750	    cd ${.CURDIR}/${_tool}; \
751	    ${MAKE} DIRPRFX=${_tool}/ obj; \
752	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
753	    ${MAKE} DIRPRFX=${_tool}/ depend; \
754	    ${MAKE} DIRPRFX=${_tool}/ all; \
755	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
756.endfor
757
758#
759# bootstrap-tools: Build tools needed for compatibility
760#
761.if !defined(NO_GAMES)
762_strfile=	games/fortune/strfile
763.endif
764
765.if !defined(NO_CXX)
766_gperf=		gnu/usr.bin/gperf
767.if ${BOOTSTRAPPING} < 500113
768_groff=		gnu/usr.bin/groff
769.else
770_groff=		gnu/usr.bin/groff/tmac
771.endif
772.endif
773
774.if ${BOOTSTRAPPING} < 600015
775_cap_mkdb=	usr.bin/cap_mkdb
776.endif
777
778.if ${BOOTSTRAPPING} < 600017
779_gencat=	usr.bin/gencat
780.endif
781
782.if ${BOOTSTRAPPING} < 600016
783_mklocale=	usr.bin/mklocale
784.endif
785
786.if !defined(NO_RESCUE) && \
787    ${BOOTSTRAPPING} < 600008
788_crunchgen=	usr.sbin/crunch/crunchgen
789.endif
790
791bootstrap-tools:
792.for _tool in \
793    ${_strfile} \
794    ${_gperf} \
795    ${_groff} \
796    gnu/usr.bin/texinfo \
797    ${_cap_mkdb} \
798    usr.bin/colldef \
799    ${_gencat} \
800    usr.bin/lorder \
801    usr.bin/makewhatis \
802    ${_mklocale} \
803    usr.bin/rpcgen \
804    usr.bin/xinstall \
805    usr.sbin/config \
806    ${_crunchgen}
807	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
808		cd ${.CURDIR}/${_tool}; \
809		${MAKE} DIRPRFX=${_tool}/ obj; \
810		${MAKE} DIRPRFX=${_tool}/ depend; \
811		${MAKE} DIRPRFX=${_tool}/ all; \
812		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
813.endfor
814
815#
816# build-tools: Build special purpose build tools
817#
818.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
819_aicasm= sys/modules/aic7xxx/aicasm
820.endif
821
822.if !defined(NO_SHARE)
823_share=	share/syscons/scrnmaps
824.endif
825
826.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
827_kerberos5_tools= kerberos5/tools
828.endif
829
830.if !defined(NO_RESCUE)
831_rescue= rescue/rescue
832.endif
833
834build-tools:
835.for _tool in \
836    bin/csh \
837    bin/sh \
838    ${_rescue} \
839    lib/libncurses \
840    ${_share} \
841    ${_aicasm} \
842    usr.bin/awk \
843    lib/libmagic \
844    usr.sbin/sysinstall
845	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
846		cd ${.CURDIR}/${_tool}; \
847		${MAKE} DIRPRFX=${_tool}/ obj; \
848		${MAKE} DIRPRFX=${_tool}/ build-tools
849.endfor
850.for _tool in \
851    gnu/usr.bin/cc/cc_tools \
852    ${_kerberos5_tools}
853	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
854		cd ${.CURDIR}/${_tool}; \
855		${MAKE} DIRPRFX=${_tool}/ obj; \
856		${MAKE} DIRPRFX=${_tool}/ depend; \
857		${MAKE} DIRPRFX=${_tool}/ all
858.endfor
859
860#
861# cross-tools: Build cross-building tools
862#
863.if (${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386") && \
864    ${TARGET_ARCH} != ${MACHINE_ARCH}
865_btxld=		usr.sbin/btxld
866.endif
867
868.if (!defined(NO_RESCUE) || defined(RELEASEDIR)) && \
869    ${TARGET_ARCH} != ${MACHINE_ARCH}
870_crunchide=	usr.sbin/crunch/crunchide
871.endif
872
873.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
874_elf2exe=	usr.sbin/elf2exe
875.endif
876
877.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
878    defined(RELEASEDIR)
879_kgzip=		usr.sbin/kgzip
880.endif
881
882cross-tools:
883.for _tool in \
884    gnu/usr.bin/binutils \
885    gnu/usr.bin/cc \
886    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
887    ${_btxld} \
888    ${_crunchide} \
889    ${_elf2exe} \
890    ${_kgzip}
891	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
892		cd ${.CURDIR}/${_tool}; \
893		${MAKE} DIRPRFX=${_tool}/ obj; \
894		${MAKE} DIRPRFX=${_tool}/ depend; \
895		${MAKE} DIRPRFX=${_tool}/ all; \
896		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
897.endfor
898
899#
900# hierarchy - ensure that all the needed directories are present
901#
902hierarchy:
903	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
904
905#
906# libraries - build all libraries, and install them under ${DESTDIR}.
907#
908# The list of libraries with dependents (${_prebuild_libs}) and their
909# interdependencies (__L) are built automatically by the
910# ${.CURDIR}/tools/make_libdeps.sh script.
911#
912libraries:
913	cd ${.CURDIR}; \
914	    ${MAKE} -f Makefile.inc1 _startup_libs; \
915	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
916	    ${MAKE} -f Makefile.inc1 _generic_libs;
917
918# These dependencies are not automatically generated:
919#
920# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
921# shared libraries for ELF.
922#
923_startup_libs=	gnu/lib/csu gnu/lib/libgcc
924.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
925_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
926.else
927_startup_libs+=	lib/csu/${MACHINE_ARCH}
928.endif
929
930_prebuild_libs=
931
932_generic_libs=	gnu/lib
933
934.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
935_prebuild_libs+=	kerberos5/lib/libasn1
936_prebuild_libs+=	kerberos5/lib/libgssapi
937_prebuild_libs+=	kerberos5/lib/libkrb5
938_prebuild_libs+=	kerberos5/lib/libroken
939_generic_libs+=	kerberos5/lib
940.endif
941
942_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
943		lib/libkvm lib/libmd \
944		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
945		lib/libradius \
946		lib/libsbuf lib/libtacplus lib/libutil \
947		lib/libz lib/msun
948
949lib/libopie__L lib/libtacplus__L: lib/libmd__L
950
951.if !defined(NO_BIND)
952.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
953_prebuild_libs+= lib/libc_r
954.else
955_prebuild_libs+= lib/libpthread
956.endif
957.endif
958
959_generic_libs+=	lib
960
961.if !defined(NO_CRYPT)
962.if !defined(NO_OPENSSL)
963_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
964lib/libradius__L: secure/lib/libssl__L
965secure/lib/libssl__L: secure/lib/libcrypto__L
966.if !defined(NO_OPENSSH)
967_prebuild_libs+=	secure/lib/libssh
968secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
969.if !defined(NO_KERBEROS)
970secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
971    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
972    kerberos5/lib/libroken__L
973.endif
974.endif
975.endif
976_generic_libs+=	secure/lib
977.endif
978
979.if defined(NO_CRYPT) || defined(NO_OPENSSL)
980lib/libradius__L: lib/libmd__L
981.endif
982
983.if !defined(NO_NIS)
984_prebuild_libs+=	lib/libypclnt
985.endif
986
987_generic_libs+=	usr.bin/lex/lib
988
989.if ${MACHINE_ARCH} == "i386"
990_generic_libs+=	usr.sbin/pcvt/keycap
991.endif
992
993.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
994${_lib}__L: .PHONY
995.if exists(${.CURDIR}/${_lib})
996	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
997		cd ${.CURDIR}/${_lib}; \
998		${MAKE} DIRPRFX=${_lib}/ depend; \
999		${MAKE} DIRPRFX=${_lib}/ all; \
1000		${MAKE} DIRPRFX=${_lib}/ install
1001.endif
1002.endfor
1003
1004# libpam is special: we need to build static PAM modules before
1005# static PAM library, and dynamic PAM library before dynamic PAM
1006# modules.
1007lib/libpam__L: .PHONY
1008	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1009		cd ${.CURDIR}/lib/libpam; \
1010		${MAKE} DIRPRFX=lib/libpam/ depend; \
1011		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1012		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1013
1014_startup_libs: ${_startup_libs:S/$/__L/}
1015_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1016_generic_libs: ${_generic_libs:S/$/__L/}
1017
1018.for __target in all clean cleandepend cleandir depend includes obj
1019.for entry in ${SUBDIR}
1020${entry}.${__target}__D: .PHONY
1021	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1022		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1023		edir=${entry}.${MACHINE_ARCH}; \
1024		cd ${.CURDIR}/$${edir}; \
1025	else \
1026		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1027		edir=${entry}; \
1028		cd ${.CURDIR}/$${edir}; \
1029	fi; \
1030	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1031.endfor
1032par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1033.endfor
1034
1035.include <bsd.subdir.mk>
1036