Makefile.inc1 revision 139212
1139804Simp#
276440Sjhb# $FreeBSD: head/Makefile.inc1 139212 2004-12-22 22:00:01Z ru $
376440Sjhb#
476440Sjhb# Make command line options:
576440Sjhb#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6194784Sjeff#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7194784Sjeff#	-DNO_RESCUE do not build rescue binaries
8194784Sjeff#	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
976440Sjhb#	-DNO_CLEAN do not clean at all
1076440Sjhb#	-DNO_CRYPT will prevent building of crypt versions
1176440Sjhb#	-DNO_MAN do not build the manual pages
1276440Sjhb#	-DNO_PROFILE do not build profiled libraries
1376440Sjhb#	-DNO_GAMES do not go into games subdir
1476440Sjhb#	-DNO_SHARE do not go into share subdir
1576440Sjhb#	-DNO_INFO do not make or install info files
1676440Sjhb#	-DNO_LIBC_R do not build libc_r.
1776440Sjhb#	-DNO_FORTRAN do not build g77 and related libraries.
1876440Sjhb#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1976440Sjhb#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
2076440Sjhb#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
2176440Sjhb#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
2276440Sjhb#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2376440Sjhb#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2476440Sjhb#	TARGET_ARCH="arch" to crossbuild world to a different arch
2576440Sjhb
2676440Sjhb#
2776440Sjhb# The intended user-driven targets are:
2876440Sjhb# buildworld  - rebuild *everything*, including glue to help do upgrades
2976440Sjhb# installworld- install everything built by "buildworld"
3076440Sjhb# update      - convenient way to update your source tree (eg: cvsup/cvs)
3176440Sjhb#
3276440Sjhb# Standard targets (not defined here) are documented in the makefiles in
3376440Sjhb# /usr/share/mk.  These include:
3476440Sjhb#		obj depend all install clean cleandepend cleanobj
3576440Sjhb
3685444Sjhb# We must do share/info early so that installation of info `dir'
3785444Sjhb# entries works correctly.  Do it first since it is less likely to
3885444Sjhb# grow dependencies on include and lib than vice versa.
3985444Sjhb#
4085444Sjhb# We must do lib and libexec before bin, because if installworld
4185444Sjhb# installs a new /bin/sh, the 'make' command will *immediately*
4285444Sjhb# use that new version.  And the new (dynamically-linked) /bin/sh
4385444Sjhb# will expect to find appropriate libraries in /lib and /libexec.
4485444Sjhb#
4585444Sjhb# We must do etc last for install/distribute to work.
4676440Sjhb#
4776440SjhbSUBDIR=	share/info include lib libexec bin
48116182Sobrien.if !defined(NO_GAMES)
49116182SobrienSUBDIR+=games
50116182Sobrien.endif
5187702SjhbSUBDIR+=gnu
5287702Sjhb.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
5376440SjhbSUBDIR+=kerberos5
5476440Sjhb.endif
55194784Sjeff.if !defined(NO_RESCUE)
5687702SjhbSUBDIR+=rescue
57194784Sjeff.endif
5876440SjhbSUBDIR+=sbin
5987702Sjhb.if !defined(NO_CRYPT)
60150576SrwatsonSUBDIR+=secure
61194784Sjeff.endif
6287702Sjhb.if !defined(NO_SHARE)
6376440SjhbSUBDIR+=share
64249132Smav.endif
65194784SjeffSUBDIR+=sys usr.bin usr.sbin etc
66194784Sjeff
67194784Sjeff# These are last, since it is nice to at least get the base system
68194784Sjeff# rebuilt before you do them.
69194784Sjeff.for _DIR in ${LOCAL_DIRS}
70194784Sjeff.if exists(${.CURDIR}/${_DIR}/Makefile)
71194784SjeffSUBDIR+= ${_DIR}
72215701Sdim.endif
73194784Sjeff.endfor
74194784Sjeff
75194784Sjeff.if defined(SUBDIR_OVERRIDE)
76173444SupsSUBDIR=		${SUBDIR_OVERRIDE}
77222531Snwhitehorn.endif
7876440Sjhb
7976440Sjhb.if defined(NO_CLEANDIR)
8087702SjhbCLEANDIR=	clean cleandepend
8176440Sjhb.else
8276440SjhbCLEANDIR=	cleandir
8387702Sjhb.endif
8476440Sjhb
8576440SjhbCVS?=		cvs
8687702SjhbCVSFLAGS?=	-A -P -d -I!
8787702SjhbSUP?=		/usr/local/bin/cvsup
8887702SjhbSUPFLAGS?=	-g -L 2 -P -
8987702Sjhb.if defined(SUPHOST)
9087702SjhbSUPFLAGS+=	-h ${SUPHOST}
91222531Snwhitehorn.endif
9287702Sjhb
93173444SupsMAKEOBJDIRPREFIX?=	/usr/obj
94173444Sups.if !defined(OSRELDATE)
95194784Sjeff.if exists(/usr/include/osreldate.h)
96173444SupsOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
97194784Sjeff		/usr/include/osreldate.h
98194784Sjeff.else
99194784SjeffOSRELDATE=	0
100194784Sjeff.endif
101194784Sjeff.endif
102194784SjeffTARGET_ARCH?=	${MACHINE_ARCH}
103194784Sjeff.if ${TARGET_ARCH} == ${MACHINE_ARCH}
104194784SjeffTARGET?=	${MACHINE}
105194784SjeffTARGET_CPUTYPE?=${CPUTYPE}
106194784Sjeff.else
107194784SjeffTARGET?=	${TARGET_ARCH}
108194784SjeffTARGET_CPUTYPE?=
109194784Sjeff.endif
110194784Sjeff.if !empty(TARGET_CPUTYPE)
111194784Sjeff_TARGET_CPUTYPE=${TARGET_CPUTYPE}
112194784Sjeff.else
113194784Sjeff_TARGET_CPUTYPE=dummy
11476440Sjhb.endif
11576440Sjhb_CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
116194784Sjeff		-f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
117194784Sjeff.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
118194784Sjeff.error CPUTYPE global should be set with ?=.
119194784Sjeff.endif
120194784Sjeff.if make(buildworld)
121194784SjeffBUILD_ARCH!=	sysctl -n hw.machine_arch
122194784Sjeff.if ${MACHINE_ARCH} != ${BUILD_ARCH}
123208100Sbz.error To cross-build, set TARGET_ARCH.
124194784Sjeff.endif
125194784Sjeff.endif
126194784Sjeff.if ${MACHINE} == ${TARGET}
127194784SjeffOBJTREE=	${MAKEOBJDIRPREFIX}
128194784Sjeff.else
12976440SjhbOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
130194784Sjeff.endif
131194784SjeffWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
132194784Sjeff# /usr/games added for fortune which depend on strfile
133194784SjeffBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
134194784SjeffXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
135194784SjeffSTRICTTMPPATH=	${BPATH}:${XPATH}
136194784SjeffTMPPATH=	${STRICTTMPPATH}:${PATH}
137194784Sjeff
138194784SjeffINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
139194784Sjeff
140194784Sjeff#
141194784Sjeff# Building a world goes through the following stages
142194784Sjeff#
143194784Sjeff# 1. legacy stage [BMAKE]
144194784Sjeff#	This stage is responsible for creating compatibility
145194784Sjeff#	shims that are needed by the bootstrap-tools,
146194784Sjeff#	build-tools and cross-tools stages.
147194784Sjeff# 1. bootstrap-tools stage [BMAKE]
148194784Sjeff#	This stage is responsible for creating programs that
149194784Sjeff#	are needed for backward compatibility reasons. They
150194784Sjeff#	are not built as cross-tools.
151194784Sjeff# 2. build-tools stage [TMAKE]
152194784Sjeff#	This stage is responsible for creating the object
153194784Sjeff#	tree and building any tools that are needed during
154194784Sjeff#	the build process.
155194784Sjeff# 3. cross-tools stage [XMAKE]
156194784Sjeff#	This stage is responsible for creating any tools that
157194784Sjeff#	are needed for cross-builds. A cross-compiler is one
158194784Sjeff#	of them.
159194784Sjeff# 4. world stage [WMAKE]
160194784Sjeff#	This stage actually builds the world.
161194784Sjeff# 5. install stage (optional) [IMAKE]
162194784Sjeff#	This stage installs a previously built world.
163194784Sjeff#
164194784Sjeff
165194784SjeffBOOTSTRAPPING?=	0
166194784Sjeff
167194784Sjeff# Common environment for world related stages
168194784SjeffCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
169194784Sjeff		MACHINE_ARCH=${TARGET_ARCH} \
170194784Sjeff		MACHINE=${TARGET} \
171194784Sjeff		CPUTYPE=${TARGET_CPUTYPE} \
172194784Sjeff		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
173194784Sjeff		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
174194784Sjeff		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
175194784Sjeff
176194784Sjeff# bootstrap-tools stage
177194784SjeffBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
178194784Sjeff		PATH=${BPATH}:${PATH} \
179194784Sjeff		WORLDTMP=${WORLDTMP} \
180194784Sjeff		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
181194784SjeffBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
182194784Sjeff		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
183194784Sjeff		DESTDIR= \
184194784Sjeff		BOOTSTRAPPING=${OSRELDATE} \
185194784Sjeff		-DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PIC -DNO_PROFILE \
186194784Sjeff		-DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
187194784Sjeff
188194784Sjeff# build-tools stage
189194784SjeffTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
190194784Sjeff		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
191194784Sjeff		DESTDIR= \
192194784Sjeff		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
193194784Sjeff
194194784Sjeff# cross-tools stage
195194784SjeffXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
196194784Sjeff
197194784Sjeff# world stage
198194784SjeffWMAKEENV=	${CROSSENV} \
199194784Sjeff		_SHLIBDIRPREFIX=${WORLDTMP} \
200194784Sjeff		INSTALL="sh ${.CURDIR}/tools/install.sh" \
201194784Sjeff		PATH=${TMPPATH}
202194784SjeffWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
203194784Sjeff
204194784Sjeff.if ${MACHINE_ARCH} == "amd64"
205194784Sjeff# 32 bit world
206194784SjeffLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
207194784Sjeff
208194784SjeffLIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
209194784SjeffLIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
210194784Sjeff		-L${LIB32TMP}/usr/lib32 \
211194784Sjeff		-B${LIB32TMP}/usr/lib32
212194784SjeffLIB32CC=	${LIB32PREFLAGS} \
213194784Sjeff		${LIB32POSTFLAGS}
214194784SjeffLIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
215194784Sjeff		${LIB32POSTFLAGS}
216194784SjeffLIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
217194784Sjeff		${LIB32POSTFLAGS}
218194784Sjeff
219194784Sjeff# Yes, the flags are redundant.
220194784SjeffLIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
221194784Sjeff		_SHLIBDIRPREFIX=${LIB32TMP} \
222194784Sjeff		MACHINE_ARCH=i386 \
223194784Sjeff		INSTALL="sh ${.CURDIR}/tools/install.sh" \
224194784Sjeff		PATH=${TMPPATH} \
225194784Sjeff		CC="cc ${LIB32CC}" \
226194784Sjeff		CXX="c++ ${LIB32CXX}" \
227194784Sjeff		OBJC="cc ${LIB32OBJC}" \
228194784Sjeff		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
229194784Sjeff		AS="as --32" \
230194784Sjeff		LIBDIR=/usr/lib32 \
231194784Sjeff		SHLIBDIR=/usr/lib32
232194784Sjeff
233194784SjeffLIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
234194784Sjeff		-DNO_BIND -DNO_MAN -DNO_INFO -DNO_HTML \
235194784Sjeff		CC="cc ${LIB32CC}" \
236194784Sjeff		CXX="c++ ${LIB32CXX}" \
237194784Sjeff		OBJC="cc ${LIB32OBJC}" \
23887702Sjhb		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
23976440Sjhb		AS="as --32" \
24087702Sjhb		LIBDIR=/usr/lib32 \
24187702Sjhb		SHLIBDIR=/usr/lib32
24276440Sjhb.endif
24376440Sjhb
244222531Snwhitehorn# install stage
24587702Sjhb.if empty(.MAKEFLAGS:M-n)
246194784SjeffIMAKEENV=	${CROSSENV} \
24776440Sjhb		PATH=${STRICTTMPPATH}:${INSTALLTMP}
24887702Sjhb.else
24987702SjhbIMAKEENV=	${CROSSENV} \
25087702Sjhb		PATH=${TMPPATH}:${INSTALLTMP}
25187702Sjhb.endif
25287702SjhbIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
25387702Sjhb
25487702Sjhb# kernel stage
25587702SjhbKMAKEENV=	${WMAKEENV}
25687702Sjhb
25787702Sjhb#
25887702Sjhb# buildworld
259194784Sjeff#
260194784Sjeff# Attempt to rebuild the entire system, with reasonable chance of
261194784Sjeff# success, regardless of how old your existing system is.
262194935Sjeff#
263194784Sjeff_worldtmp:
264194784Sjeff.if ${.CURDIR:C/[^,]//g} != ""
265194784Sjeff#	The m4 build of sendmail files doesn't like it if ',' is used
266194784Sjeff#	anywhere in the path of it's files.
267194784Sjeff	@echo
268194784Sjeff	@echo "*** Error: path to source tree contains a comma ','"
269194784Sjeff	@echo
270194784Sjeff	false
271194784Sjeff.endif
272194784Sjeff	@echo
273194784Sjeff	@echo "--------------------------------------------------------------"
274194784Sjeff	@echo ">>> Rebuilding the temporary build tree"
275194784Sjeff	@echo "--------------------------------------------------------------"
276194784Sjeff.if !defined(NO_CLEAN)
277194935Sjeff	rm -rf ${WORLDTMP}
278194935Sjeff.else
279194935Sjeff	rm -rf ${WORLDTMP}/legacy/usr/include
280194935Sjeff	# XXX - These two can depend on any header file.
281194935Sjeff	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
282194935Sjeff	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
283194935Sjeff.endif
284194935Sjeff.for _dir in \
285194935Sjeff    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
286194935Sjeff    usr/libexec usr/sbin usr/share/dict \
287194935Sjeff    usr/share/groff_font/devX100 \
288194935Sjeff    usr/share/groff_font/devX100-12 \
289194935Sjeff    usr/share/groff_font/devX75 \
290194935Sjeff    usr/share/groff_font/devX75-12 \
291194935Sjeff    usr/share/groff_font/devascii \
292194935Sjeff    usr/share/groff_font/devcp1047 \
293194935Sjeff    usr/share/groff_font/devdvi \
294194784Sjeff    usr/share/groff_font/devhtml \
295194784Sjeff    usr/share/groff_font/devkoi8-r \
296194935Sjeff    usr/share/groff_font/devlatin1 \
297194784Sjeff    usr/share/groff_font/devlbp \
298194784Sjeff    usr/share/groff_font/devlj4 \
299194784Sjeff    usr/share/groff_font/devps \
300194784Sjeff    usr/share/groff_font/devutf8 \
301194784Sjeff    usr/share/tmac/mdoc usr/share/tmac/mm
302194784Sjeff	mkdir -p ${WORLDTMP}/legacy/${_dir}
303194784Sjeff.endfor
304194784Sjeff.for _dir in \
305194784Sjeff    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
306194784Sjeff    usr/libexec usr/sbin usr/share/misc \
307194784Sjeff    usr/share/snmp/defs usr/share/snmp/mibs
308194784Sjeff	mkdir -p ${WORLDTMP}/${_dir}
309194784Sjeff.endfor
31087702Sjhb	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
311196132Sbz	    -p ${WORLDTMP}/usr/include >/dev/null
312196132Sbz	ln -sf ${.CURDIR}/sys ${WORLDTMP}
313196132Sbz.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
314150576Srwatson	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
315209059Sjhb	    -p ${WORLDTMP}/usr/include >/dev/null
316196132Sbz.endif
317196132Sbz_legacy:
318196132Sbz	@echo
319196132Sbz	@echo "--------------------------------------------------------------"
320196132Sbz	@echo ">>> stage 1.1: legacy release compatibility shims"
321196132Sbz	@echo "--------------------------------------------------------------"
322150576Srwatson	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
323150576Srwatson_bootstrap-tools:
32487702Sjhb	@echo
32587702Sjhb	@echo "--------------------------------------------------------------"
32687702Sjhb	@echo ">>> stage 1.2: bootstrap tools"
32787702Sjhb	@echo "--------------------------------------------------------------"
328208392Sjhb	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
32987702Sjhb_cleanobj:
33087702Sjhb.if !defined(NO_CLEAN)
33187702Sjhb	@echo
33287702Sjhb	@echo "--------------------------------------------------------------"
333173600Sjulian	@echo ">>> stage 2.1: cleaning up the object tree"
33487702Sjhb	@echo "--------------------------------------------------------------"
33587702Sjhb	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
33687702Sjhb.endif
33787702Sjhb_obj:
33887702Sjhb	@echo
33987702Sjhb	@echo "--------------------------------------------------------------"
34087702Sjhb	@echo ">>> stage 2.2: rebuilding the object tree"
341173600Sjulian	@echo "--------------------------------------------------------------"
34287702Sjhb	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
34387702Sjhb_build-tools:
34487702Sjhb	@echo
34587702Sjhb	@echo "--------------------------------------------------------------"
34687702Sjhb	@echo ">>> stage 2.3: build tools"
347208392Sjhb	@echo "--------------------------------------------------------------"
34887702Sjhb	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
34987702Sjhb_cross-tools:
35087702Sjhb	@echo
351208392Sjhb	@echo "--------------------------------------------------------------"
352191816Szec	@echo ">>> stage 3: cross tools"
353191816Szec	@echo "--------------------------------------------------------------"
354191816Szec	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
355191816Szec_includes:
35687702Sjhb	@echo
35787702Sjhb	@echo "--------------------------------------------------------------"
358207929Sattilio	@echo ">>> stage 4.1: building includes"
35987702Sjhb	@echo "--------------------------------------------------------------"
36087702Sjhb	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
361150576Srwatson_libraries:
362150576Srwatson	@echo
363150576Srwatson	@echo "--------------------------------------------------------------"
364150576Srwatson	@echo ">>> stage 4.2: building libraries"
365150576Srwatson	@echo "--------------------------------------------------------------"
366150576Srwatson	${_+_}cd ${.CURDIR}; \
367150576Srwatson	    ${WMAKE} -DNO_FSCHG -DNO_HTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PROFILE \
368150576Srwatson	    libraries
369150576Srwatson_depend:
370150576Srwatson	@echo
371150576Srwatson	@echo "--------------------------------------------------------------"
372150576Srwatson	@echo ">>> stage 4.3: make dependencies"
373150576Srwatson	@echo "--------------------------------------------------------------"
374150576Srwatson	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
375150576Srwatsoneverything:
376150576Srwatson	@echo
377150576Srwatson	@echo "--------------------------------------------------------------"
378150576Srwatson	@echo ">>> stage 4.4: building everything"
379183054Ssam	@echo "--------------------------------------------------------------"
380150576Srwatson	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
381150576Srwatson.if ${MACHINE_ARCH} == "amd64"
382150576Srwatsonbuild32:
383150576Srwatson	@echo
384150576Srwatson	@echo "--------------------------------------------------------------"
385152021Sjhb	@echo ">>> stage 5.1: building 32 bit shim libraries"
386150576Srwatson	@echo "--------------------------------------------------------------"
387150576Srwatson.for _dir in \
388150576Srwatson    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
389150576Srwatson    usr/libexec usr/sbin usr/share/misc \
390150576Srwatson    usr/share/snmp/defs usr/share/snmp/mibs
391150576Srwatson	mkdir -p ${LIB32TMP}/${_dir}
392150576Srwatson.endfor
393183054Ssam	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
39487702Sjhb	    -p ${LIB32TMP}/usr/include >/dev/null
395	ln -sf ${.CURDIR}/sys ${WORLDTMP}
396.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
397.for _t in obj depend all
398	cd ${.CURDIR}/kerberos5/tools; \
399	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
400.endfor
401.endif
402.for _t in obj includes
403	cd ${.CURDIR}/include; \
404	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
405	cd ${.CURDIR}/lib; \
406	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
407	cd ${.CURDIR}/gnu/lib; \
408	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
409.if !defined(NO_CRYPT)
410	cd ${.CURDIR}/secure/lib; \
411	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412.endif
413.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
414	cd ${.CURDIR}/kerberos5/lib; \
415	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416.endif
417.endfor
418.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
419	cd ${.CURDIR}/${_dir}; \
420	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
421.endfor
422.for _dir in lib/libncurses lib/libmagic
423	cd ${.CURDIR}/${_dir}; \
424	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
425.endfor
426	cd ${.CURDIR}; \
427	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
428.for _t in obj depend all
429	cd ${.CURDIR}/libexec/rtld-elf; \
430	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
431.endfor
432
433install32:
434	mkdir -p ${DESTDIR}/usr/lib32	# XXX add to mtree
435	cd ${.CURDIR}/lib; ${LIB32MAKE} install
436	cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
437.if !defined(NO_CRYPT)
438	cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
439.endif
440	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
441.endif
442
443
444WMAKE_TGTS=
445.if !defined(SUBDIR_OVERRIDE)
446WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
447.endif
448WMAKE_TGTS+=	_cleanobj _obj _build-tools
449.if !defined(SUBDIR_OVERRIDE)
450WMAKE_TGTS+=	_cross-tools
451.endif
452WMAKE_TGTS+=	_includes _libraries _depend everything
453.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
454WMAKE_TGTS+=	build32
455.endif
456
457buildworld: ${WMAKE_TGTS}
458.ORDER: ${WMAKE_TGTS}
459
460TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
461toolchain: ${TOOLCHAIN_TGTS}
462kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
463
464#
465# Use this to add checks to installworld/installkernel targets.
466#
467SPECIAL_INSTALLCHECKS=
468
469#
470# The following install-time check will see if the installation will
471# change the type used for time_t, and if it will, the target makes
472# sure that the user is expecting to make that change.
473#
474.if ${TARGET_ARCH} == "sparc64"
475SPECIAL_INSTALLCHECKS+=sparc64_installcheck
476
477CUR_TIMET!=	grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
478SRC_TIMET!=	grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
479		awk '{print $$2}'
480NEWSPARC_TIMETYPE?=${CUR_TIMET}
481
482sparc64_installcheck:
483.if ${CUR_TIMET} != ${SRC_TIMET}
484	@echo
485.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
486	@echo "***  ERROR: This target would change the type used for time_t!"
487.else
488	@echo "* Note: This installation changes the type used for time_t."
489.endif
490	@echo "* "
491	@echo "* This host has time_t defined as ${CUR_TIMET},"
492	@echo "* and this installation would change that to type ${SRC_TIMET}."
493.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
494	@echo "* "
495	@echo "* If that is *NOT* what you wanted, then you need to change the"
496	@echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
497	@echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'.  After that you *MUST*"
498	@echo "* do a complete cleanworld, buildworld, buildkernel before you"
499	@echo "* retry the 'make' command.  Also read /usr/src/UPDATING.64BTT."
500	@echo "* "
501	@echo "* If that *is* what you want, then enter the commands:"
502	@echo "      NEWSPARC_TIMETYPE=${SRC_TIMET}"
503	@echo "      export NEWSPARC_TIMETYPE"
504	@echo "* and repeat your 'make' command."
505	@echo
506	false
507.endif
508	@echo
509.elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
510	@echo
511	@echo "***  ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
512	@echo "***         but ${.CURDIR}/sys/sparc64/include/_types.h"
513	@echo "***         has __time_t defined as '${SRC_TIMET}'."
514	false
515.else
516	@# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
517.endif
518.endif
519
520#
521# installcheck
522#
523# Checks to be sure system is ready for installworld
524#
525CHECK_UIDS=
526CHECK_GIDS=
527.if !defined(NO_SENDMAIL)
528CHECK_UIDS+=	smmsp
529CHECK_GIDS+=	smmsp
530.endif
531.if !defined(NO_PF)
532CHECK_UIDS+=	proxy
533CHECK_GIDS+=	proxy authpf
534.endif
535installcheck: ${SPECIAL_INSTALLCHECKS}
536.for uid in ${CHECK_UIDS}
537	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
538		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
539		false; \
540	fi
541.endfor
542.for gid in ${CHECK_GIDS}
543	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
544		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
545		false; \
546	fi
547.endfor
548
549#
550# distributeworld
551#
552# Distributes everything compiled by a `buildworld'.
553#
554# installworld
555#
556# Installs everything compiled by a 'buildworld'.
557#
558distributeworld installworld: installcheck
559	mkdir -p ${INSTALLTMP}
560	for prog in [ awk cap_mkdb cat chflags chmod chown \
561	    date echo egrep find grep \
562	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
563	    test true uname wc zic; do \
564		cp `which $$prog` ${INSTALLTMP}; \
565	done
566	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
567	rm -rf ${INSTALLTMP}
568
569#
570# reinstall
571#
572# If you have a build server, you can NFS mount the source and obj directories
573# and do a 'make reinstall' on the *client* to install new binaries from the
574# most recent server build.
575#
576reinstall: ${SPECIAL_INSTALLCHECKS}
577	@echo "--------------------------------------------------------------"
578	@echo ">>> Making hierarchy"
579	@echo "--------------------------------------------------------------"
580	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
581	@echo
582	@echo "--------------------------------------------------------------"
583	@echo ">>> Installing everything"
584	@echo "--------------------------------------------------------------"
585	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
586.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
587	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
588.endif
589
590redistribute:
591	@echo "--------------------------------------------------------------"
592	@echo ">>> Distributing everything"
593	@echo "--------------------------------------------------------------"
594	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
595
596#
597# buildkernel and installkernel
598#
599# Which kernels to build and/or install is specified by setting
600# KERNCONF. If not defined a GENERIC kernel is built/installed.
601# Only the existing (depending TARGET) config files are used
602# for building kernels and only the first of these is designated
603# as the one being installed.
604#
605# Note that we have to use TARGET instead of TARGET_ARCH when
606# we're in kernel-land. Since only TARGET_ARCH is (expected) to
607# be set to cross-build, we have to make sure TARGET is set
608# properly.
609
610.if !defined(KERNCONF) && defined(KERNEL)
611KERNCONF=	${KERNEL}
612KERNWARN=
613.else
614KERNCONF?=	GENERIC
615.endif
616INSTKERNNAME?=	kernel
617
618KERNSRCDIR?=	${.CURDIR}/sys
619KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
620KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
621KERNCONFDIR?=	${KRNLCONFDIR}
622
623BUILDKERNELS=
624INSTALLKERNEL=
625.for _kernel in ${KERNCONF}
626.if exists(${KERNCONFDIR}/${_kernel})
627BUILDKERNELS+=	${_kernel}
628.if empty(INSTALLKERNEL)
629INSTALLKERNEL= ${_kernel}
630.endif
631.endif
632.endfor
633
634#
635# buildkernel
636#
637# Builds all kernels defined by BUILDKERNELS.
638#
639buildkernel:
640.if empty(BUILDKERNELS)
641	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
642	false
643.endif
644.if defined(KERNWARN)
645	@echo "--------------------------------------------------------------"
646	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
647	@echo "--------------------------------------------------------------"
648	@sleep 3
649.endif
650	@echo
651.for _kernel in ${BUILDKERNELS}
652	@echo "--------------------------------------------------------------"
653	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
654	@echo "--------------------------------------------------------------"
655	@echo "===> ${_kernel}"
656	mkdir -p ${KRNLOBJDIR}
657.if !defined(NO_KERNELCONFIG)
658	@echo
659	@echo "--------------------------------------------------------------"
660	@echo ">>> stage 1: configuring the kernel"
661	@echo "--------------------------------------------------------------"
662	cd ${KRNLCONFDIR}; \
663		PATH=${TMPPATH} \
664		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
665			${KERNCONFDIR}/${_kernel}
666.endif
667.if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
668	@echo
669	@echo "--------------------------------------------------------------"
670	@echo ">>> stage 2.1: cleaning up the object tree"
671	@echo "--------------------------------------------------------------"
672	cd ${KRNLOBJDIR}/${_kernel}; \
673	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
674.endif
675	@echo
676	@echo "--------------------------------------------------------------"
677	@echo ">>> stage 2.2: rebuilding the object tree"
678	@echo "--------------------------------------------------------------"
679	cd ${KRNLOBJDIR}/${_kernel}; \
680	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
681	@echo
682	@echo "--------------------------------------------------------------"
683	@echo ">>> stage 2.3: build tools"
684	@echo "--------------------------------------------------------------"
685	cd ${KRNLOBJDIR}/${_kernel}; \
686	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
687	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
688# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
689.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
690.for target in obj depend all
691	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
692	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
693	    ${MAKE} -DNO_CPU_CFLAGS ${target}
694.endfor
695.endif
696.if !defined(NO_KERNELDEPEND)
697	@echo
698	@echo "--------------------------------------------------------------"
699	@echo ">>> stage 3.1: making dependencies"
700	@echo "--------------------------------------------------------------"
701	cd ${KRNLOBJDIR}/${_kernel}; \
702	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
703.endif
704	@echo
705	@echo "--------------------------------------------------------------"
706	@echo ">>> stage 3.2: building everything"
707	@echo "--------------------------------------------------------------"
708	cd ${KRNLOBJDIR}/${_kernel}; \
709	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
710	@echo "--------------------------------------------------------------"
711	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
712	@echo "--------------------------------------------------------------"
713.endfor
714
715#
716# installkernel, etc.
717#
718# Install the kernel defined by INSTALLKERNEL
719#
720installkernel installkernel.debug \
721reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
722.if empty(INSTALLKERNEL)
723	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
724	false
725.endif
726	@echo "--------------------------------------------------------------"
727	@echo ">>> Making hierarchy"
728	@echo "--------------------------------------------------------------"
729	cd ${.CURDIR}; \
730	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
731	@echo
732	@echo "--------------------------------------------------------------"
733	@echo ">>> Installing kernel"
734	@echo "--------------------------------------------------------------"
735	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
736	    ${CROSSENV} PATH=${TMPPATH} \
737	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
738
739#
740# update
741#
742# Update the source tree, by running cvsup and/or running cvs to update to the
743# latest copy.
744#
745update:
746.if defined(SUP_UPDATE)
747	@echo "--------------------------------------------------------------"
748	@echo ">>> Running ${SUP}"
749	@echo "--------------------------------------------------------------"
750.if defined(SUPFILE)
751	@${SUP} ${SUPFLAGS} ${SUPFILE}
752.endif
753.if defined(SUPFILE1)
754	@${SUP} ${SUPFLAGS} ${SUPFILE1}
755.endif
756.if defined(SUPFILE2)
757	@${SUP} ${SUPFLAGS} ${SUPFILE2}
758.endif
759.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
760	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
761.endif
762.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
763	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
764.endif
765.endif
766.if defined(CVS_UPDATE)
767	@echo "--------------------------------------------------------------"
768	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
769	@echo "--------------------------------------------------------------"
770	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
771.endif
772
773#
774# ------------------------------------------------------------------------
775#
776# From here onwards are utility targets used by the 'make world' and
777# related targets.  If your 'world' breaks, you may like to try to fix
778# the problem and manually run the following targets to attempt to
779# complete the build.  Beware, this is *not* guaranteed to work, you
780# need to have a pretty good grip on the current state of the system
781# to attempt to manually finish it.  If in doubt, 'make world' again.
782#
783
784#
785# legacy: Build compatibility shims for the next three targets
786#
787legacy:
788.for _tool in tools/build
789	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
790	    cd ${.CURDIR}/${_tool}; \
791	    ${MAKE} DIRPRFX=${_tool}/ obj; \
792	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
793	    ${MAKE} DIRPRFX=${_tool}/ depend; \
794	    ${MAKE} DIRPRFX=${_tool}/ all; \
795	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
796.endfor
797
798#
799# bootstrap-tools: Build tools needed for compatibility
800#
801.if !defined(NO_GAMES)
802_strfile=	games/fortune/strfile
803.endif
804
805.if !defined(NO_CXX)
806_gperf=	gnu/usr.bin/gperf
807.if ${BOOTSTRAPPING} < 500113
808_groff=		gnu/usr.bin/groff
809.else
810_groff=		gnu/usr.bin/groff/tmac
811.endif
812.endif
813
814.if ${BOOTSTRAPPING} < 502102
815_lex=		usr.bin/lex
816.endif
817
818.if ${BOOTSTRAPPING} < 450005 || \
819    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
820_uudecode=	usr.bin/uudecode
821.endif
822
823.if ${BOOTSTRAPPING} < 430002 || \
824    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
825_xargs=		usr.bin/xargs
826.endif
827
828.if ${BOOTSTRAPPING} < 430002 || \
829    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
830_yacc=		usr.bin/yacc
831.endif
832
833.if !defined(NO_RESCUE) && \
834    ${BOOTSTRAPPING} < 502128
835_crunchgen=	usr.sbin/crunch/crunchgen
836.endif
837
838.if ${BOOTSTRAPPING} < 502128
839_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
840.endif
841
842.if ${BOOTSTRAPPING} < 500019
843_kbdcontrol=	usr.sbin/kbdcontrol
844.endif
845
846bootstrap-tools:
847.for _tool in \
848    ${_strfile} \
849    ${_gperf} \
850    ${_groff} \
851    gnu/usr.bin/texinfo \
852    usr.bin/colldef \
853    ${_lex} \
854    usr.bin/makewhatis \
855    usr.bin/rpcgen \
856    ${_uudecode} \
857    ${_xargs} \
858    usr.bin/xinstall \
859    ${_yacc} \
860    usr.sbin/config \
861    ${_crunchgen} \
862    ${_gensnmptree} \
863    ${_kbdcontrol}
864	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
865		cd ${.CURDIR}/${_tool}; \
866		${MAKE} DIRPRFX=${_tool}/ obj; \
867		${MAKE} DIRPRFX=${_tool}/ depend; \
868		${MAKE} DIRPRFX=${_tool}/ all; \
869		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
870.endfor
871
872#
873# build-tools: Build special purpose build tools
874#
875.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
876_aicasm= sys/modules/aic7xxx/aicasm
877.endif
878
879.if !defined(NO_SHARE)
880_share=	share/syscons/scrnmaps
881.endif
882
883.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
884_kerberos5_tools= kerberos5/tools
885.endif
886
887.if !defined(NO_RESCUE)
888_rescue= rescue/rescue
889.endif
890
891build-tools:
892.for _tool in \
893    bin/csh \
894    bin/sh \
895    ${_rescue} \
896    lib/libncurses \
897    ${_share} \
898    ${_aicasm} \
899    usr.bin/awk \
900    lib/libmagic \
901    usr.sbin/sysinstall
902	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
903		cd ${.CURDIR}/${_tool}; \
904		${MAKE} DIRPRFX=${_tool}/ obj; \
905		${MAKE} DIRPRFX=${_tool}/ build-tools
906.endfor
907.for _tool in \
908    gnu/usr.bin/cc/cc_tools \
909    ${_kerberos5_tools}
910	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
911		cd ${.CURDIR}/${_tool}; \
912		${MAKE} DIRPRFX=${_tool}/ obj; \
913		${MAKE} DIRPRFX=${_tool}/ depend; \
914		${MAKE} DIRPRFX=${_tool}/ all
915.endfor
916
917#
918# cross-tools: Build cross-building tools
919#
920.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
921    ${BOOTSTRAPPING} < 500037
922_elf2aout=	usr.bin/elf2aout
923.endif
924
925.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
926_btxld=		usr.sbin/btxld
927.endif
928
929.if (!defined(NO_RESCUE) || \
930    defined(RELEASEDIR)) && \
931    (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
932_crunchide=	usr.sbin/crunch/crunchide
933.endif
934
935.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
936_elf2exe=	usr.sbin/elf2exe
937.endif
938
939.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
940    defined(RELEASEDIR)
941_kgzip=		usr.sbin/kgzip
942.endif
943
944cross-tools:
945.for _tool in \
946    gnu/usr.bin/binutils \
947    gnu/usr.bin/cc \
948    ${_elf2aout} \
949    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
950    ${_btxld} \
951    ${_crunchide} \
952    ${_elf2exe} \
953    ${_kgzip}
954	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
955		cd ${.CURDIR}/${_tool}; \
956		${MAKE} DIRPRFX=${_tool}/ obj; \
957		${MAKE} DIRPRFX=${_tool}/ depend; \
958		${MAKE} DIRPRFX=${_tool}/ all; \
959		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
960.endfor
961
962#
963# hierarchy - ensure that all the needed directories are present
964#
965hierarchy:
966	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
967
968#
969# libraries - build all libraries, and install them under ${DESTDIR}.
970#
971# The list of libraries with dependents (${_prebuild_libs}) and their
972# interdependencies (__L) are built automatically by the
973# ${.CURDIR}/tools/make_libdeps.sh script.
974#
975libraries:
976	cd ${.CURDIR}; \
977	    ${MAKE} -f Makefile.inc1 _startup_libs; \
978	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
979	    ${MAKE} -f Makefile.inc1 _generic_libs;
980
981# These dependencies are not automatically generated:
982#
983# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
984# shared libraries for ELF.
985#
986_startup_libs=	gnu/lib/csu gnu/lib/libgcc
987.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
988_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
989.else
990_startup_libs+=	lib/csu/${MACHINE_ARCH}
991.endif
992
993_prebuild_libs=
994
995_generic_libs=	gnu/lib
996
997.if !defined(NO_KERBEROS) && !defined(NO_CRYPT) && !defined(NO_OPENSSL)
998_prebuild_libs+=	kerberos5/lib/libasn1
999_prebuild_libs+=	kerberos5/lib/libgssapi
1000_prebuild_libs+=	kerberos5/lib/libkrb5
1001_prebuild_libs+=	kerberos5/lib/libroken
1002_generic_libs+=	kerberos5/lib
1003.endif
1004
1005_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
1006		lib/libkvm lib/libmd \
1007		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1008		lib/libradius \
1009		lib/libsbuf lib/libtacplus lib/libutil \
1010		lib/libz lib/msun
1011
1012lib/libopie__L lib/libtacplus__L: lib/libmd__L
1013
1014.if !defined(NO_BIND)
1015.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
1016_prebuild_libs+= lib/libc_r
1017.else
1018_prebuild_libs+= lib/libpthread
1019.endif
1020.endif
1021
1022_generic_libs+=	lib
1023
1024.if !defined(NO_CRYPT)
1025.if !defined(NO_OPENSSL)
1026_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
1027lib/libradius__L: secure/lib/libssl__L
1028secure/lib/libssl__L: secure/lib/libcrypto__L
1029.if !defined(NO_OPENSSH)
1030_prebuild_libs+=	secure/lib/libssh
1031secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1032.if !defined(NO_KERBEROS)
1033secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1034    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1035    kerberos5/lib/libroken__L
1036.endif
1037.endif
1038.endif
1039_generic_libs+=	secure/lib
1040.endif
1041
1042.if defined(NO_CRYPT) || defined(NO_OPENSSL)
1043lib/libradius__L: lib/libmd__L
1044.endif
1045
1046.if !defined(NO_NIS)
1047_prebuild_libs+=	lib/libypclnt
1048.endif
1049
1050_generic_libs+=	usr.bin/lex/lib
1051
1052.if ${MACHINE_ARCH} == "i386"
1053_generic_libs+=	usr.sbin/pcvt/keycap
1054.endif
1055
1056.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1057${_lib}__L: .PHONY
1058.if exists(${.CURDIR}/${_lib})
1059	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1060		cd ${.CURDIR}/${_lib}; \
1061		${MAKE} DIRPRFX=${_lib}/ depend; \
1062		${MAKE} DIRPRFX=${_lib}/ all; \
1063		${MAKE} DIRPRFX=${_lib}/ install
1064.endif
1065.endfor
1066
1067# libpam is special: we need to build static PAM modules before
1068# static PAM library, and dynamic PAM library before dynamic PAM
1069# modules.
1070lib/libpam__L: .PHONY
1071	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1072		cd ${.CURDIR}/lib/libpam; \
1073		${MAKE} DIRPRFX=lib/libpam/ depend; \
1074		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1075		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1076
1077_startup_libs: ${_startup_libs:S/$/__L/}
1078_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1079_generic_libs: ${_generic_libs:S/$/__L/}
1080
1081.for __target in all clean cleandepend cleandir depend includes obj
1082.for entry in ${SUBDIR}
1083${entry}.${__target}__D: .PHONY
1084	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1085		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1086		edir=${entry}.${MACHINE_ARCH}; \
1087		cd ${.CURDIR}/$${edir}; \
1088	else \
1089		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1090		edir=${entry}; \
1091		cd ${.CURDIR}/$${edir}; \
1092	fi; \
1093	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1094.endfor
1095par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1096.endfor
1097
1098.include <bsd.subdir.mk>
1099