Makefile.inc1 revision 139112
1290650Shselasky#
2347819Shselasky# $FreeBSD: head/Makefile.inc1 139112 2004-12-21 09:59:45Z ru $
3290650Shselasky#
4290650Shselasky# Make command line options:
5290650Shselasky#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6290650Shselasky#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7290650Shselasky#	-DNO_RESCUE do not build rescue binaries
8290650Shselasky#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9290650Shselasky#	-DNOCLEAN do not clean at all
10290650Shselasky#	-DNOCRYPT will prevent building of crypt versions
11290650Shselasky#	-DNO_MAN do not build the manual pages
12290650Shselasky#	-DNO_PROFILE do not build profiled libraries
13290650Shselasky#	-DNOGAMES do not go into games subdir
14290650Shselasky#	-DNOSHARE do not go into share subdir
15290650Shselasky#	-DNO_INFO do not make or install info files
16290650Shselasky#	-DNO_LIBC_R do not build libc_r.
17290650Shselasky#	-DNO_FORTRAN do not build g77 and related libraries.
18290650Shselasky#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
19290650Shselasky#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
20290650Shselasky#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
21290650Shselasky#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
22290650Shselasky#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
23290650Shselasky#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24290650Shselasky#	TARGET_ARCH="arch" to crossbuild world to a different arch
25290650Shselasky
26290650Shselasky#
27290650Shselasky# The intended user-driven targets are:
28290650Shselasky# buildworld  - rebuild *everything*, including glue to help do upgrades
29290650Shselasky# installworld- install everything built by "buildworld"
30290650Shselasky# update      - convenient way to update your source tree (eg: cvsup/cvs)
31290650Shselasky#
32290650Shselasky# Standard targets (not defined here) are documented in the makefiles in
33290650Shselasky# /usr/share/mk.  These include:
34290650Shselasky#		obj depend all install clean cleandepend cleanobj
35290650Shselasky
36347802Shselasky# We must do share/info early so that installation of info `dir'
37290650Shselasky# entries works correctly.  Do it first since it is less likely to
38290650Shselasky# grow dependencies on include and lib than vice versa.
39290650Shselasky#
40290650Shselasky# We must do lib and libexec before bin, because if installworld
41290650Shselasky# installs a new /bin/sh, the 'make' command will *immediately*
42290650Shselasky# use that new version.  And the new (dynamically-linked) /bin/sh
43341958Shselasky# will expect to find appropriate libraries in /lib and /libexec.
44341958Shselasky#
45290650Shselasky# We must do etc last for install/distribute to work.
46329200Shselasky#
47290650ShselaskySUBDIR=	share/info include lib libexec bin
48341948Shselasky.if !defined(NOGAMES)
49341948ShselaskySUBDIR+=games
50290650Shselasky.endif
51290650ShselaskySUBDIR+=gnu
52290650Shselasky.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
53290650ShselaskySUBDIR+=kerberos5
54347839Shselasky.endif
55347847Shselasky.if !defined(NO_RESCUE)
56290650ShselaskySUBDIR+=rescue
57290650Shselasky.endif
58347835ShselaskySUBDIR+=sbin
59347835Shselasky.if !defined(NOCRYPT)
60290650ShselaskySUBDIR+=secure
61347835Shselasky.endif
62347835Shselasky.if !defined(NOSHARE)
63347835ShselaskySUBDIR+=share
64290650Shselasky.endif
65290650ShselaskySUBDIR+=sys usr.bin usr.sbin etc
66347835Shselasky
67347835Shselasky# These are last, since it is nice to at least get the base system
68347835Shselasky# rebuilt before you do them.
69347835Shselasky.for _DIR in ${LOCAL_DIRS}
70290650Shselasky.if exists(${.CURDIR}/${_DIR}/Makefile)
71347819ShselaskySUBDIR+= ${_DIR}
72347819Shselasky.endif
73347819Shselasky.endfor
74347819Shselasky
75347819Shselasky.if defined(SUBDIR_OVERRIDE)
76290650ShselaskySUBDIR=		${SUBDIR_OVERRIDE}
77290650Shselasky.endif
78290650Shselasky
79290650Shselasky.if defined(NOCLEANDIR)
80290650ShselaskyCLEANDIR=	clean cleandepend
81290650Shselasky.else
82290650ShselaskyCLEANDIR=	cleandir
83290650Shselasky.endif
84290650Shselasky
85290650ShselaskyCVS?=		cvs
86290650ShselaskyCVSFLAGS?=	-A -P -d -I!
87290650ShselaskySUP?=		/usr/local/bin/cvsup
88329209ShselaskySUPFLAGS?=	-g -L 2 -P -
89329209Shselasky.if defined(SUPHOST)
90329209ShselaskySUPFLAGS+=	-h ${SUPHOST}
91329209Shselasky.endif
92329209Shselasky
93290650ShselaskyMAKEOBJDIRPREFIX?=	/usr/obj
94290650Shselasky.if !defined(OSRELDATE)
95290650Shselasky.if exists(/usr/include/osreldate.h)
96290650ShselaskyOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
97290650Shselasky		/usr/include/osreldate.h
98290650Shselasky.else
99290650ShselaskyOSRELDATE=	0
100290650Shselasky.endif
101290650Shselasky.endif
102290650ShselaskyTARGET_ARCH?=	${MACHINE_ARCH}
103290650Shselasky.if ${TARGET_ARCH} == ${MACHINE_ARCH}
104290650ShselaskyTARGET?=	${MACHINE}
105290650ShselaskyTARGET_CPUTYPE?=${CPUTYPE}
106290650Shselasky.else
107290650ShselaskyTARGET?=	${TARGET_ARCH}
108290650ShselaskyTARGET_CPUTYPE?=
109290650Shselasky.endif
110290650Shselasky.if !empty(TARGET_CPUTYPE)
111290650Shselasky_TARGET_CPUTYPE=${TARGET_CPUTYPE}
112290650Shselasky.else
113290650Shselasky_TARGET_CPUTYPE=dummy
114290650Shselasky.endif
115290650Shselasky_CPUTYPE!=	MAKEFLAGS= ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
116290650Shselasky		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
117290650Shselasky.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
118290650Shselasky.error CPUTYPE global should be set with ?=.
119290650Shselasky.endif
120290650Shselasky.if make(buildworld)
121290650ShselaskyBUILD_ARCH!=	sysctl -n hw.machine_arch
122290650Shselasky.if ${MACHINE_ARCH} != ${BUILD_ARCH}
123290650Shselasky.error To cross-build, set TARGET_ARCH.
124290650Shselasky.endif
125290650Shselasky.endif
126290650Shselasky.if ${MACHINE} == ${TARGET}
127290650ShselaskyOBJTREE=	${MAKEOBJDIRPREFIX}
128290650Shselasky.else
129290650ShselaskyOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
130290650Shselasky.endif
131290650ShselaskyWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
132290650Shselasky# /usr/games added for fortune which depend on strfile
133290650ShselaskyBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
134290650ShselaskyXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
135290650ShselaskySTRICTTMPPATH=	${BPATH}:${XPATH}
136290650ShselaskyTMPPATH=	${STRICTTMPPATH}:${PATH}
137290650Shselasky
138290650ShselaskyINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
139290650Shselasky
140290650Shselasky#
141290650Shselasky# Building a world goes through the following stages
142290650Shselasky#
143290650Shselasky# 1. legacy stage [BMAKE]
144290650Shselasky#	This stage is responsible for creating compatibility
145290650Shselasky#	shims that are needed by the bootstrap-tools,
146290650Shselasky#	build-tools and cross-tools stages.
147290650Shselasky# 1. bootstrap-tools stage [BMAKE]
148290650Shselasky#	This stage is responsible for creating programs that
149290650Shselasky#	are needed for backward compatibility reasons. They
150290650Shselasky#	are not built as cross-tools.
151290650Shselasky# 2. build-tools stage [TMAKE]
152290650Shselasky#	This stage is responsible for creating the object
153290650Shselasky#	tree and building any tools that are needed during
154290650Shselasky#	the build process.
155290650Shselasky# 3. cross-tools stage [XMAKE]
156290650Shselasky#	This stage is responsible for creating any tools that
157290650Shselasky#	are needed for cross-builds. A cross-compiler is one
158290650Shselasky#	of them.
159290650Shselasky# 4. world stage [WMAKE]
160290650Shselasky#	This stage actually builds the world.
161290650Shselasky# 5. install stage (optional) [IMAKE]
162290650Shselasky#	This stage installs a previously built world.
163290650Shselasky#
164290650Shselasky
165290650ShselaskyBOOTSTRAPPING?=	0
166290650Shselasky
167290650Shselasky# Common environment for world related stages
168290650ShselaskyCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
169290650Shselasky		MACHINE_ARCH=${TARGET_ARCH} \
170290650Shselasky		MACHINE=${TARGET} \
171290650Shselasky		CPUTYPE=${TARGET_CPUTYPE} \
172290650Shselasky		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
173290650Shselasky		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
174290650Shselasky		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
175290650Shselasky
176290650Shselasky# bootstrap-tools stage
177290650ShselaskyBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
178290650Shselasky		PATH=${BPATH}:${PATH} \
179290650Shselasky		WORLDTMP=${WORLDTMP} \
180290650Shselasky		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
181290650ShselaskyBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
182290650Shselasky		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
183290650Shselasky		DESTDIR= \
184290650Shselasky		BOOTSTRAPPING=${OSRELDATE} \
185290650Shselasky		-DNOHTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PIC -DNO_PROFILE \
186290650Shselasky		-DNO_SHARED -DNO_CPU_CFLAGS -DNO_WARNS
187290650Shselasky
188290650Shselasky# build-tools stage
189290650ShselaskyTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
190290650Shselasky		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
191290650Shselasky		DESTDIR= \
192290650Shselasky		BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
193290650Shselasky
194290650Shselasky# cross-tools stage
195290650ShselaskyXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
196290650Shselasky
197290650Shselasky# world stage
198290650ShselaskyWMAKEENV=	${CROSSENV} \
199290650Shselasky		_SHLIBDIRPREFIX=${WORLDTMP} \
200347862Shselasky		INSTALL="sh ${.CURDIR}/tools/install.sh" \
201347862Shselasky		PATH=${TMPPATH}
202347862ShselaskyWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
203347862Shselasky
204347862Shselasky.if ${MACHINE_ARCH} == "amd64"
205347862Shselasky# 32 bit world
206347862ShselaskyLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
207347862Shselasky
208347862ShselaskyLIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
209347862ShselaskyLIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
210347862Shselasky		-L${LIB32TMP}/usr/lib32 \
211347862Shselasky		-B${LIB32TMP}/usr/lib32
212347862ShselaskyLIB32CC=	${LIB32PREFLAGS} \
213347862Shselasky		${LIB32POSTFLAGS}
214347862ShselaskyLIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
215331580Shselasky		${LIB32POSTFLAGS}
216331580ShselaskyLIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
217331580Shselasky		${LIB32POSTFLAGS}
218331580Shselasky
219331580Shselasky# Yes, the flags are redundant.
220331580ShselaskyLIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
221331580Shselasky		_SHLIBDIRPREFIX=${LIB32TMP} \
222331580Shselasky		MACHINE_ARCH=i386 \
223331580Shselasky		INSTALL="sh ${.CURDIR}/tools/install.sh" \
224331580Shselasky		PATH=${TMPPATH} \
225331580Shselasky		CC="cc ${LIB32CC}" \
226331580Shselasky		CXX="c++ ${LIB32CXX}" \
227331580Shselasky		OBJC="cc ${LIB32OBJC}" \
228331580Shselasky		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
229331580Shselasky		AS="as --32" \
230331580Shselasky		LIBDIR=/usr/lib32 \
231331580Shselasky		SHLIBDIR=/usr/lib32
232331580Shselasky
233331580ShselaskyLIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
234331580Shselasky		-DNO_BIND -DNO_MAN -DNO_INFO -DNOHTML \
235331580Shselasky		CC="cc ${LIB32CC}" \
236331580Shselasky		CXX="c++ ${LIB32CXX}" \
237331580Shselasky		OBJC="cc ${LIB32OBJC}" \
238331580Shselasky		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
239331580Shselasky		AS="as --32" \
240331580Shselasky		LIBDIR=/usr/lib32 \
241331580Shselasky		SHLIBDIR=/usr/lib32
242331580Shselasky.endif
243290650Shselasky
244290650Shselasky# install stage
245290650Shselasky.if empty(.MAKEFLAGS:M-n)
246290650ShselaskyIMAKEENV=	${CROSSENV} \
247290650Shselasky		PATH=${STRICTTMPPATH}:${INSTALLTMP}
248290650Shselasky.else
249290650ShselaskyIMAKEENV=	${CROSSENV} \
250290650Shselasky		PATH=${TMPPATH}:${INSTALLTMP}
251290650Shselasky.endif
252290650ShselaskyIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
253290650Shselasky
254290650Shselasky# kernel stage
255290650ShselaskyKMAKEENV=	${WMAKEENV}
256290650Shselasky
257290650Shselasky#
258290650Shselasky# buildworld
259290650Shselasky#
260290650Shselasky# Attempt to rebuild the entire system, with reasonable chance of
261290650Shselasky# success, regardless of how old your existing system is.
262290650Shselasky#
263290650Shselasky_worldtmp:
264290650Shselasky.if ${.CURDIR:C/[^,]//g} != ""
265290650Shselasky#	The m4 build of sendmail files doesn't like it if ',' is used
266290650Shselasky#	anywhere in the path of it's files.
267290650Shselasky	@echo
268290650Shselasky	@echo "*** Error: path to source tree contains a comma ','"
269338554Shselasky	@echo
270337112Shselasky	false
271290650Shselasky.endif
272290650Shselasky	@echo
273337112Shselasky	@echo "--------------------------------------------------------------"
274337112Shselasky	@echo ">>> Rebuilding the temporary build tree"
275337112Shselasky	@echo "--------------------------------------------------------------"
276337112Shselasky.if !defined(NOCLEAN)
277337112Shselasky	rm -rf ${WORLDTMP}
278353189Shselasky.else
279353189Shselasky	rm -rf ${WORLDTMP}/legacy/usr/include
280353189Shselasky	# XXX - These two can depend on any header file.
281353189Shselasky	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
282290650Shselasky	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
283290650Shselasky.endif
284290650Shselasky.for _dir in \
285290650Shselasky    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
286290650Shselasky    usr/libexec usr/sbin usr/share/dict \
287290650Shselasky    usr/share/groff_font/devX100 \
288290650Shselasky    usr/share/groff_font/devX100-12 \
289290650Shselasky    usr/share/groff_font/devX75 \
290290650Shselasky    usr/share/groff_font/devX75-12 \
291290650Shselasky    usr/share/groff_font/devascii \
292290650Shselasky    usr/share/groff_font/devcp1047 \
293290650Shselasky    usr/share/groff_font/devdvi \
294290650Shselasky    usr/share/groff_font/devhtml \
295290650Shselasky    usr/share/groff_font/devkoi8-r \
296290650Shselasky    usr/share/groff_font/devlatin1 \
297290650Shselasky    usr/share/groff_font/devlbp \
298290650Shselasky    usr/share/groff_font/devlj4 \
299290650Shselasky    usr/share/groff_font/devps \
300290650Shselasky    usr/share/groff_font/devutf8 \
301290650Shselasky    usr/share/tmac/mdoc usr/share/tmac/mm
302290650Shselasky	mkdir -p ${WORLDTMP}/legacy/${_dir}
303290650Shselasky.endfor
304290650Shselasky.for _dir in \
305290650Shselasky    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
306290650Shselasky    usr/libexec usr/sbin usr/share/misc \
307290650Shselasky    usr/share/snmp/defs usr/share/snmp/mibs
308290650Shselasky	mkdir -p ${WORLDTMP}/${_dir}
309290650Shselasky.endfor
310290650Shselasky	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
311290650Shselasky	    -p ${WORLDTMP}/usr/include >/dev/null
312290650Shselasky	ln -sf ${.CURDIR}/sys ${WORLDTMP}
313290650Shselasky.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
314290650Shselasky	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
315290650Shselasky	    -p ${WORLDTMP}/usr/include >/dev/null
316290650Shselasky.endif
317290650Shselasky_legacy:
318290650Shselasky	@echo
319290650Shselasky	@echo "--------------------------------------------------------------"
320290650Shselasky	@echo ">>> stage 1.1: legacy release compatibility shims"
321290650Shselasky	@echo "--------------------------------------------------------------"
322306233Shselasky	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
323306233Shselasky_bootstrap-tools:
324290650Shselasky	@echo
325290650Shselasky	@echo "--------------------------------------------------------------"
326290650Shselasky	@echo ">>> stage 1.2: bootstrap tools"
327290650Shselasky	@echo "--------------------------------------------------------------"
328290650Shselasky	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
329290650Shselasky_cleanobj:
330290650Shselasky.if !defined(NOCLEAN)
331290650Shselasky	@echo
332290650Shselasky	@echo "--------------------------------------------------------------"
333290650Shselasky	@echo ">>> stage 2.1: cleaning up the object tree"
334290650Shselasky	@echo "--------------------------------------------------------------"
335290650Shselasky	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
336290650Shselasky.endif
337290650Shselasky_obj:
338290650Shselasky	@echo
339290650Shselasky	@echo "--------------------------------------------------------------"
340290650Shselasky	@echo ">>> stage 2.2: rebuilding the object tree"
341290650Shselasky	@echo "--------------------------------------------------------------"
342290650Shselasky	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
343290650Shselasky_build-tools:
344290650Shselasky	@echo
345290650Shselasky	@echo "--------------------------------------------------------------"
346290650Shselasky	@echo ">>> stage 2.3: build tools"
347331807Shselasky	@echo "--------------------------------------------------------------"
348331807Shselasky	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
349331807Shselasky_cross-tools:
350290650Shselasky	@echo
351290650Shselasky	@echo "--------------------------------------------------------------"
352290650Shselasky	@echo ">>> stage 3: cross tools"
353290650Shselasky	@echo "--------------------------------------------------------------"
354290650Shselasky	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
355290650Shselasky_includes:
356290650Shselasky	@echo
357290650Shselasky	@echo "--------------------------------------------------------------"
358290650Shselasky	@echo ">>> stage 4.1: building includes"
359290650Shselasky	@echo "--------------------------------------------------------------"
360290650Shselasky	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
361290650Shselasky_libraries:
362290650Shselasky	@echo
363290650Shselasky	@echo "--------------------------------------------------------------"
364290650Shselasky	@echo ">>> stage 4.2: building libraries"
365290650Shselasky	@echo "--------------------------------------------------------------"
366290650Shselasky	${_+_}cd ${.CURDIR}; \
367290650Shselasky	    ${WMAKE} -DNO_FSCHG -DNOHTML -DNO_INFO -DNO_LINT -DNO_MAN -DNO_PROFILE \
368290650Shselasky	    libraries
369290650Shselasky_depend:
370290650Shselasky	@echo
371290650Shselasky	@echo "--------------------------------------------------------------"
372290650Shselasky	@echo ">>> stage 4.3: make dependencies"
373290650Shselasky	@echo "--------------------------------------------------------------"
374290650Shselasky	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
375290650Shselaskyeverything:
376290650Shselasky	@echo
377290650Shselasky	@echo "--------------------------------------------------------------"
378290650Shselasky	@echo ">>> stage 4.4: building everything"
379290650Shselasky	@echo "--------------------------------------------------------------"
380290650Shselasky	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
381290650Shselasky.if ${MACHINE_ARCH} == "amd64"
382290650Shselaskybuild32:
383290650Shselasky	@echo
384290650Shselasky	@echo "--------------------------------------------------------------"
385290650Shselasky	@echo ">>> stage 5.1: building 32 bit shim libraries"
386290650Shselasky	@echo "--------------------------------------------------------------"
387290650Shselasky.for _dir in \
388290650Shselasky    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
389290650Shselasky    usr/libexec usr/sbin usr/share/misc \
390290650Shselasky    usr/share/snmp/defs usr/share/snmp/mibs
391290650Shselasky	mkdir -p ${LIB32TMP}/${_dir}
392290650Shselasky.endfor
393331807Shselasky	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
394331807Shselasky	    -p ${LIB32TMP}/usr/include >/dev/null
395331807Shselasky	ln -sf ${.CURDIR}/sys ${WORLDTMP}
396331807Shselasky.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
397331807Shselasky.for _t in obj depend all
398331807Shselasky	cd ${.CURDIR}/kerberos5/tools; \
399331807Shselasky	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
400331807Shselasky.endfor
401331807Shselasky.endif
402331807Shselasky.for _t in obj includes
403331807Shselasky	cd ${.CURDIR}/include; \
404290650Shselasky	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
405290650Shselasky	cd ${.CURDIR}/lib; \
406331807Shselasky	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
407290650Shselasky	cd ${.CURDIR}/gnu/lib; \
408290650Shselasky	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
409290650Shselasky.if !defined(NOCRYPT)
410331807Shselasky	cd ${.CURDIR}/secure/lib; \
411290650Shselasky	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412290650Shselasky.endif
413290650Shselasky.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
414290650Shselasky	cd ${.CURDIR}/kerberos5/lib; \
415290650Shselasky	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416290650Shselasky.endif
417290650Shselasky.endfor
418290650Shselasky.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
419290650Shselasky	cd ${.CURDIR}/${_dir}; \
420290650Shselasky	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
421290650Shselasky.endfor
422290650Shselasky.for _dir in lib/libncurses lib/libmagic
423331807Shselasky	cd ${.CURDIR}/${_dir}; \
424290650Shselasky	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
425290650Shselasky.endfor
426290650Shselasky	cd ${.CURDIR}; \
427290650Shselasky	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
428290650Shselasky.for _t in obj depend all
429290650Shselasky	cd ${.CURDIR}/libexec/rtld-elf; \
430290650Shselasky	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
431290650Shselasky.endfor
432290650Shselasky
433290650Shselaskyinstall32:
434290650Shselasky	mkdir -p ${DESTDIR}/usr/lib32	# XXX add to mtree
435290650Shselasky	cd ${.CURDIR}/lib; ${LIB32MAKE} install
436290650Shselasky	cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
437290650Shselasky.if !defined(NOCRYPT)
438290650Shselasky	cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
439290650Shselasky.endif
440290650Shselasky	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
441290650Shselasky.endif
442290650Shselasky
443290650Shselasky
444290650ShselaskyWMAKE_TGTS=
445290650Shselasky.if !defined(SUBDIR_OVERRIDE)
446306233ShselaskyWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
447306233Shselasky.endif
448306233ShselaskyWMAKE_TGTS+=	_cleanobj _obj _build-tools
449290650Shselasky.if !defined(SUBDIR_OVERRIDE)
450290650ShselaskyWMAKE_TGTS+=	_cross-tools
451290650Shselasky.endif
452290650ShselaskyWMAKE_TGTS+=	_includes _libraries _depend everything
453290650Shselasky.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
454290650ShselaskyWMAKE_TGTS+=	build32
455290650Shselasky.endif
456290650Shselasky
457290650Shselaskybuildworld: ${WMAKE_TGTS}
458329209Shselasky.ORDER: ${WMAKE_TGTS}
459329209Shselasky
460329209ShselaskyTOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
461329209Shselaskytoolchain: ${TOOLCHAIN_TGTS}
462329209Shselaskykernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
463329209Shselasky
464329209Shselasky#
465329209Shselasky# Use this to add checks to installworld/installkernel targets.
466329209Shselasky#
467331807ShselaskySPECIAL_INSTALLCHECKS=
468329209Shselasky
469329209Shselasky#
470329209Shselasky# The following install-time check will see if the installation will
471329209Shselasky# change the type used for time_t, and if it will, the target makes
472329209Shselasky# sure that the user is expecting to make that change.
473329209Shselasky#
474329209Shselasky.if ${TARGET_ARCH} == "sparc64"
475329209ShselaskySPECIAL_INSTALLCHECKS+=sparc64_installcheck
476329209Shselasky
477329209ShselaskyCUR_TIMET!=	grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
478329209ShselaskySRC_TIMET!=	grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
479329209Shselasky		awk '{print $$2}'
480329209ShselaskyNEWSPARC_TIMETYPE?=${CUR_TIMET}
481329209Shselasky
482329209Shselaskysparc64_installcheck:
483329209Shselasky.if ${CUR_TIMET} != ${SRC_TIMET}
484329209Shselasky	@echo
485329209Shselasky.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
486329209Shselasky	@echo "***  ERROR: This target would change the type used for time_t!"
487329209Shselasky.else
488329209Shselasky	@echo "* Note: This installation changes the type used for time_t."
489329209Shselasky.endif
490329209Shselasky	@echo "* "
491329209Shselasky	@echo "* This host has time_t defined as ${CUR_TIMET},"
492329209Shselasky	@echo "* and this installation would change that to type ${SRC_TIMET}."
493329209Shselasky.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
494329209Shselasky	@echo "* "
495329209Shselasky	@echo "* If that is *NOT* what you wanted, then you need to change the"
496329209Shselasky	@echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
497329209Shselasky	@echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'.  After that you *MUST*"
498329209Shselasky	@echo "* do a complete cleanworld, buildworld, buildkernel before you"
499290650Shselasky	@echo "* retry the 'make' command.  Also read /usr/src/UPDATING.64BTT."
500290650Shselasky	@echo "* "
501290650Shselasky	@echo "* If that *is* what you want, then enter the commands:"
502290650Shselasky	@echo "      NEWSPARC_TIMETYPE=${SRC_TIMET}"
503290650Shselasky	@echo "      export NEWSPARC_TIMETYPE"
504290650Shselasky	@echo "* and repeat your 'make' command."
505306233Shselasky	@echo
506306233Shselasky	false
507306233Shselasky.endif
508306233Shselasky	@echo
509290650Shselasky.elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
510290650Shselasky	@echo
511290650Shselasky	@echo "***  ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
512290650Shselasky	@echo "***         but ${.CURDIR}/sys/sparc64/include/_types.h"
513290650Shselasky	@echo "***         has __time_t defined as '${SRC_TIMET}'."
514290650Shselasky	false
515290650Shselasky.else
516290650Shselasky	@# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
517290650Shselasky.endif
518290650Shselasky.endif
519331807Shselasky
520331807Shselasky#
521290650Shselasky# installcheck
522290650Shselasky#
523331807Shselasky# Checks to be sure system is ready for installworld
524290650Shselasky#
525290650ShselaskyCHECK_UIDS=
526290650ShselaskyCHECK_GIDS=
527290650Shselasky.if !defined(NO_SENDMAIL)
528331807ShselaskyCHECK_UIDS+=	smmsp
529331807ShselaskyCHECK_GIDS+=	smmsp
530290650Shselasky.endif
531290650Shselasky.if !defined(NO_PF)
532331807ShselaskyCHECK_UIDS+=	proxy
533290650ShselaskyCHECK_GIDS+=	proxy authpf
534290650Shselasky.endif
535290650Shselaskyinstallcheck: ${SPECIAL_INSTALLCHECKS}
536290650Shselasky.for uid in ${CHECK_UIDS}
537331807Shselasky	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
538331807Shselasky		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
539331807Shselasky		false; \
540290650Shselasky	fi
541290650Shselasky.endfor
542290650Shselasky.for gid in ${CHECK_GIDS}
543290650Shselasky	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
544331807Shselasky		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
545290650Shselasky		false; \
546331807Shselasky	fi
547331807Shselasky.endfor
548331807Shselasky
549331807Shselasky#
550331807Shselasky# distributeworld
551290650Shselasky#
552290650Shselasky# Distributes everything compiled by a `buildworld'.
553290650Shselasky#
554290650Shselasky# installworld
555290650Shselasky#
556290650Shselasky# Installs everything compiled by a 'buildworld'.
557290650Shselasky#
558290650Shselaskydistributeworld installworld: installcheck
559290650Shselasky	mkdir -p ${INSTALLTMP}
560290650Shselasky	for prog in [ awk cap_mkdb cat chflags chmod chown \
561290650Shselasky	    date echo egrep find grep \
562331807Shselasky	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
563331807Shselasky	    test true uname wc zic; do \
564290650Shselasky		cp `which $$prog` ${INSTALLTMP}; \
565290650Shselasky	done
566290650Shselasky	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
567290650Shselasky	rm -rf ${INSTALLTMP}
568331807Shselasky
569290650Shselasky#
570331807Shselasky# reinstall
571290650Shselasky#
572290650Shselasky# If you have a build server, you can NFS mount the source and obj directories
573290650Shselasky# and do a 'make reinstall' on the *client* to install new binaries from the
574290650Shselasky# most recent server build.
575290650Shselasky#
576290650Shselaskyreinstall: ${SPECIAL_INSTALLCHECKS}
577290650Shselasky	@echo "--------------------------------------------------------------"
578290650Shselasky	@echo ">>> Making hierarchy"
579290650Shselasky	@echo "--------------------------------------------------------------"
580290650Shselasky	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
581290650Shselasky	@echo
582290650Shselasky	@echo "--------------------------------------------------------------"
583290650Shselasky	@echo ">>> Installing everything"
584290650Shselasky	@echo "--------------------------------------------------------------"
585290650Shselasky	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
586290650Shselasky.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
587290650Shselasky	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
588290650Shselasky.endif
589290650Shselasky
590290650Shselaskyredistribute:
591290650Shselasky	@echo "--------------------------------------------------------------"
592290650Shselasky	@echo ">>> Distributing everything"
593290650Shselasky	@echo "--------------------------------------------------------------"
594290650Shselasky	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
595290650Shselasky
596290650Shselasky#
597290650Shselasky# buildkernel and installkernel
598290650Shselasky#
599290650Shselasky# Which kernels to build and/or install is specified by setting
600290650Shselasky# KERNCONF. If not defined a GENERIC kernel is built/installed.
601290650Shselasky# Only the existing (depending TARGET) config files are used
602290650Shselasky# for building kernels and only the first of these is designated
603290650Shselasky# as the one being installed.
604290650Shselasky#
605290650Shselasky# Note that we have to use TARGET instead of TARGET_ARCH when
606290650Shselasky# we're in kernel-land. Since only TARGET_ARCH is (expected) to
607290650Shselasky# be set to cross-build, we have to make sure TARGET is set
608290650Shselasky# properly.
609290650Shselasky
610290650Shselasky.if !defined(KERNCONF) && defined(KERNEL)
611290650ShselaskyKERNCONF=	${KERNEL}
612290650ShselaskyKERNWARN=
613290650Shselasky.else
614290650ShselaskyKERNCONF?=	GENERIC
615290650Shselasky.endif
616290650ShselaskyINSTKERNNAME?=	kernel
617290650Shselasky
618290650ShselaskyKERNSRCDIR?=	${.CURDIR}/sys
619290650ShselaskyKRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
620290650ShselaskyKRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
621290650ShselaskyKERNCONFDIR?=	${KRNLCONFDIR}
622290650Shselasky
623290650ShselaskyBUILDKERNELS=
624290650ShselaskyINSTALLKERNEL=
625290650Shselasky.for _kernel in ${KERNCONF}
626290650Shselasky.if exists(${KERNCONFDIR}/${_kernel})
627290650ShselaskyBUILDKERNELS+=	${_kernel}
628290650Shselasky.if empty(INSTALLKERNEL)
629290650ShselaskyINSTALLKERNEL= ${_kernel}
630290650Shselasky.endif
631290650Shselasky.endif
632290650Shselasky.endfor
633290650Shselasky
634290650Shselasky#
635290650Shselasky# buildkernel
636290650Shselasky#
637290650Shselasky# Builds all kernels defined by BUILDKERNELS.
638290650Shselasky#
639290650Shselaskybuildkernel:
640290650Shselasky.if empty(BUILDKERNELS)
641290650Shselasky	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
642290650Shselasky	false
643290650Shselasky.endif
644290650Shselasky.if defined(KERNWARN)
645290650Shselasky	@echo "--------------------------------------------------------------"
646290650Shselasky	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
647290650Shselasky	@echo "--------------------------------------------------------------"
648290650Shselasky	@sleep 3
649290650Shselasky.endif
650290650Shselasky	@echo
651290650Shselasky.for _kernel in ${BUILDKERNELS}
652290650Shselasky	@echo "--------------------------------------------------------------"
653290650Shselasky	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
654290650Shselasky	@echo "--------------------------------------------------------------"
655290650Shselasky	@echo "===> ${_kernel}"
656290650Shselasky	mkdir -p ${KRNLOBJDIR}
657290650Shselasky.if !defined(NO_KERNELCONFIG)
658290650Shselasky	@echo
659290650Shselasky	@echo "--------------------------------------------------------------"
660290650Shselasky	@echo ">>> stage 1: configuring the kernel"
661290650Shselasky	@echo "--------------------------------------------------------------"
662290650Shselasky	cd ${KRNLCONFDIR}; \
663290650Shselasky		PATH=${TMPPATH} \
664290650Shselasky		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
665290650Shselasky			${KERNCONFDIR}/${_kernel}
666290650Shselasky.endif
667290650Shselasky.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
668290650Shselasky	@echo
669290650Shselasky	@echo "--------------------------------------------------------------"
670290650Shselasky	@echo ">>> stage 2.1: cleaning up the object tree"
671290650Shselasky	@echo "--------------------------------------------------------------"
672290650Shselasky	cd ${KRNLOBJDIR}/${_kernel}; \
673290650Shselasky	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
674290650Shselasky.endif
675290650Shselasky	@echo
676290650Shselasky	@echo "--------------------------------------------------------------"
677290650Shselasky	@echo ">>> stage 2.2: rebuilding the object tree"
678290650Shselasky	@echo "--------------------------------------------------------------"
679290650Shselasky	cd ${KRNLOBJDIR}/${_kernel}; \
680290650Shselasky	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
681290650Shselasky	@echo
682290650Shselasky	@echo "--------------------------------------------------------------"
683290650Shselasky	@echo ">>> stage 2.3: build tools"
684290650Shselasky	@echo "--------------------------------------------------------------"
685290650Shselasky	cd ${KRNLOBJDIR}/${_kernel}; \
686290650Shselasky	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
687290650Shselasky	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
688290650Shselasky# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
689290650Shselasky.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
690290650Shselasky.for target in obj depend all
691290650Shselasky	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
692290650Shselasky	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
693290650Shselasky	    ${MAKE} -DNO_CPU_CFLAGS ${target}
694290650Shselasky.endfor
695290650Shselasky.endif
696290650Shselasky.if !defined(NO_KERNELDEPEND)
697290650Shselasky	@echo
698290650Shselasky	@echo "--------------------------------------------------------------"
699290650Shselasky	@echo ">>> stage 3.1: making dependencies"
700290650Shselasky	@echo "--------------------------------------------------------------"
701290650Shselasky	cd ${KRNLOBJDIR}/${_kernel}; \
702290650Shselasky	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
703290650Shselasky.endif
704290650Shselasky	@echo
705290650Shselasky	@echo "--------------------------------------------------------------"
706290650Shselasky	@echo ">>> stage 3.2: building everything"
707290650Shselasky	@echo "--------------------------------------------------------------"
708290650Shselasky	cd ${KRNLOBJDIR}/${_kernel}; \
709290650Shselasky	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
710290650Shselasky	@echo "--------------------------------------------------------------"
711290650Shselasky	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
712290650Shselasky	@echo "--------------------------------------------------------------"
713290650Shselasky.endfor
714290650Shselasky
715290650Shselasky#
716290650Shselasky# installkernel, etc.
717290650Shselasky#
718290650Shselasky# Install the kernel defined by INSTALLKERNEL
719290650Shselasky#
720290650Shselaskyinstallkernel installkernel.debug \
721290650Shselaskyreinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
722290650Shselasky.if empty(INSTALLKERNEL)
723331580Shselasky	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
724290650Shselasky	false
725331580Shselasky.endif
726331580Shselasky	@echo "--------------------------------------------------------------"
727331580Shselasky	@echo ">>> Making hierarchy"
728331580Shselasky	@echo "--------------------------------------------------------------"
729331580Shselasky	cd ${.CURDIR}; \
730331580Shselasky	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
731331580Shselasky	@echo
732331580Shselasky	@echo "--------------------------------------------------------------"
733331580Shselasky	@echo ">>> Installing kernel"
734331580Shselasky	@echo "--------------------------------------------------------------"
735331580Shselasky	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
736331580Shselasky	    ${CROSSENV} PATH=${TMPPATH} \
737331580Shselasky	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
738331580Shselasky
739331580Shselasky#
740331580Shselasky# update
741331580Shselasky#
742331580Shselasky# Update the source tree, by running cvsup and/or running cvs to update to the
743331580Shselasky# latest copy.
744331580Shselasky#
745331580Shselaskyupdate:
746331580Shselasky.if defined(SUP_UPDATE)
747331580Shselasky	@echo "--------------------------------------------------------------"
748331580Shselasky	@echo ">>> Running ${SUP}"
749331580Shselasky	@echo "--------------------------------------------------------------"
750331580Shselasky.if defined(SUPFILE)
751331580Shselasky	@${SUP} ${SUPFLAGS} ${SUPFILE}
752331580Shselasky.endif
753331580Shselasky.if defined(SUPFILE1)
754331580Shselasky	@${SUP} ${SUPFLAGS} ${SUPFILE1}
755331580Shselasky.endif
756331580Shselasky.if defined(SUPFILE2)
757331580Shselasky	@${SUP} ${SUPFLAGS} ${SUPFILE2}
758331580Shselasky.endif
759331580Shselasky.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
760331580Shselasky	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
761331580Shselasky.endif
762331580Shselasky.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
763341958Shselasky	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
764341958Shselasky.endif
765331580Shselasky.endif
766290650Shselasky.if defined(CVS_UPDATE)
767331580Shselasky	@echo "--------------------------------------------------------------"
768290650Shselasky	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
769331580Shselasky	@echo "--------------------------------------------------------------"
770331580Shselasky	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
771331580Shselasky.endif
772331580Shselasky
773331580Shselasky#
774331580Shselasky# ------------------------------------------------------------------------
775331580Shselasky#
776331580Shselasky# From here onwards are utility targets used by the 'make world' and
777331580Shselasky# related targets.  If your 'world' breaks, you may like to try to fix
778341958Shselasky# the problem and manually run the following targets to attempt to
779341958Shselasky# complete the build.  Beware, this is *not* guaranteed to work, you
780331580Shselasky# need to have a pretty good grip on the current state of the system
781331580Shselasky# to attempt to manually finish it.  If in doubt, 'make world' again.
782331580Shselasky#
783331580Shselasky
784331580Shselasky#
785331580Shselasky# legacy: Build compatibility shims for the next three targets
786331580Shselasky#
787331580Shselaskylegacy:
788331580Shselasky.for _tool in tools/build
789331580Shselasky	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
790331580Shselasky	    cd ${.CURDIR}/${_tool}; \
791331580Shselasky	    ${MAKE} DIRPRFX=${_tool}/ obj; \
792331580Shselasky	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
793331580Shselasky	    ${MAKE} DIRPRFX=${_tool}/ depend; \
794331580Shselasky	    ${MAKE} DIRPRFX=${_tool}/ all; \
795331580Shselasky	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
796331580Shselasky.endfor
797331580Shselasky
798331580Shselasky#
799331580Shselasky# bootstrap-tools: Build tools needed for compatibility
800331580Shselasky#
801331580Shselasky.if !defined(NOGAMES)
802331580Shselasky_strfile=	games/fortune/strfile
803331580Shselasky.endif
804331580Shselasky
805331580Shselasky.if !defined(NO_CXX)
806331580Shselasky_gperf=	gnu/usr.bin/gperf
807331580Shselasky.if ${BOOTSTRAPPING} < 500113
808331580Shselasky_groff=		gnu/usr.bin/groff
809331580Shselasky.else
810331580Shselasky_groff=		gnu/usr.bin/groff/tmac
811331580Shselasky.endif
812331580Shselasky.endif
813331580Shselasky
814331580Shselasky.if ${BOOTSTRAPPING} < 502102
815331580Shselasky_lex=		usr.bin/lex
816331580Shselasky.endif
817331580Shselasky
818331580Shselasky.if ${BOOTSTRAPPING} < 450005 || \
819331580Shselasky    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
820331580Shselasky_uudecode=	usr.bin/uudecode
821331580Shselasky.endif
822331580Shselasky
823331580Shselasky.if ${BOOTSTRAPPING} < 430002 || \
824331580Shselasky    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
825331580Shselasky_xargs=		usr.bin/xargs
826331580Shselasky.endif
827331580Shselasky
828331580Shselasky.if ${BOOTSTRAPPING} < 430002 || \
829331580Shselasky    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
830331580Shselasky_yacc=		usr.bin/yacc
831331580Shselasky.endif
832331580Shselasky
833331580Shselasky.if !defined(NO_RESCUE) && \
834331580Shselasky    ${BOOTSTRAPPING} < 502128
835331580Shselasky_crunchgen=	usr.sbin/crunch/crunchgen
836331580Shselasky.endif
837331580Shselasky
838331580Shselasky.if ${BOOTSTRAPPING} < 502128
839331580Shselasky_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
840331580Shselasky.endif
841331580Shselasky
842347853Shselasky.if ${BOOTSTRAPPING} < 500019
843347853Shselasky_kbdcontrol=	usr.sbin/kbdcontrol
844347853Shselasky.endif
845347853Shselasky
846347847Shselaskybootstrap-tools:
847347847Shselasky.for _tool in \
848347847Shselasky    ${_strfile} \
849347847Shselasky    ${_gperf} \
850347847Shselasky    ${_groff} \
851347847Shselasky    gnu/usr.bin/texinfo \
852347853Shselasky    usr.bin/colldef \
853347853Shselasky    ${_lex} \
854347853Shselasky    usr.bin/makewhatis \
855347847Shselasky    usr.bin/rpcgen \
856347847Shselasky    ${_uudecode} \
857347847Shselasky    ${_xargs} \
858347847Shselasky    usr.bin/xinstall \
859347847Shselasky    ${_yacc} \
860347847Shselasky    usr.sbin/config \
861347847Shselasky    ${_crunchgen} \
862347847Shselasky    ${_gensnmptree} \
863347847Shselasky    ${_kbdcontrol}
864347847Shselasky	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
865347847Shselasky		cd ${.CURDIR}/${_tool}; \
866331580Shselasky		${MAKE} DIRPRFX=${_tool}/ obj; \
867331580Shselasky		${MAKE} DIRPRFX=${_tool}/ depend; \
868331580Shselasky		${MAKE} DIRPRFX=${_tool}/ all; \
869331580Shselasky		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
870331580Shselasky.endfor
871290650Shselasky
872290650Shselasky#
873290650Shselasky# build-tools: Build special purpose build tools
874290650Shselasky#
875290650Shselasky.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
876290650Shselasky_aicasm= sys/modules/aic7xxx/aicasm
877290650Shselasky.endif
878290650Shselasky
879290650Shselasky.if !defined(NOSHARE)
880290650Shselasky_share=	share/syscons/scrnmaps
881331580Shselasky.endif
882290650Shselasky
883290650Shselasky.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
884290650Shselasky_kerberos5_tools= kerberos5/tools
885290650Shselasky.endif
886290650Shselasky
887290650Shselasky.if !defined(NO_RESCUE)
888290650Shselasky_rescue= rescue/rescue
889290650Shselasky.endif
890290650Shselasky
891290650Shselaskybuild-tools:
892290650Shselasky.for _tool in \
893290650Shselasky    bin/csh \
894290650Shselasky    bin/sh \
895290650Shselasky    ${_rescue} \
896290650Shselasky    lib/libncurses \
897290650Shselasky    ${_share} \
898290650Shselasky    ${_aicasm} \
899290650Shselasky    usr.bin/awk \
900290650Shselasky    lib/libmagic \
901329212Shselasky    usr.sbin/sysinstall
902329212Shselasky	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
903290650Shselasky		cd ${.CURDIR}/${_tool}; \
904290650Shselasky		${MAKE} DIRPRFX=${_tool}/ obj; \
905290650Shselasky		${MAKE} DIRPRFX=${_tool}/ build-tools
906290650Shselasky.endfor
907290650Shselasky.for _tool in \
908331580Shselasky    gnu/usr.bin/cc/cc_tools \
909337105Shselasky    ${_kerberos5_tools}
910331585Shselasky	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
911331580Shselasky		cd ${.CURDIR}/${_tool}; \
912331580Shselasky		${MAKE} DIRPRFX=${_tool}/ obj; \
913331580Shselasky		${MAKE} DIRPRFX=${_tool}/ depend; \
914331580Shselasky		${MAKE} DIRPRFX=${_tool}/ all
915331580Shselasky.endfor
916331580Shselasky
917331580Shselasky#
918331580Shselasky# cross-tools: Build cross-building tools
919331580Shselasky#
920331580Shselasky.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
921331580Shselasky    ${BOOTSTRAPPING} < 500037
922331580Shselasky_elf2aout=	usr.bin/elf2aout
923331580Shselasky.endif
924331580Shselasky
925331580Shselasky.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
926331810Shselasky_btxld=		usr.sbin/btxld
927331580Shselasky.endif
928331580Shselasky
929331580Shselasky.if (!defined(NO_RESCUE) || \
930331580Shselasky    defined(RELEASEDIR)) && \
931337103Shselasky    (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
932337103Shselasky_crunchide=	usr.sbin/crunch/crunchide
933337103Shselasky.endif
934331815Shselasky
935331810Shselasky.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
936331810Shselasky_elf2exe=	usr.sbin/elf2exe
937331810Shselasky.endif
938331810Shselasky
939331810Shselasky.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
940331810Shselasky    defined(RELEASEDIR)
941331810Shselasky_kgzip=		usr.sbin/kgzip
942331810Shselasky.endif
943331810Shselasky
944331810Shselaskycross-tools:
945331810Shselasky.for _tool in \
946331810Shselasky    gnu/usr.bin/binutils \
947331810Shselasky    gnu/usr.bin/cc \
948331810Shselasky    ${_elf2aout} \
949331810Shselasky    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
950331810Shselasky    ${_btxld} \
951331810Shselasky    ${_crunchide} \
952331810Shselasky    ${_elf2exe} \
953331810Shselasky    ${_kgzip}
954331810Shselasky	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
955331810Shselasky		cd ${.CURDIR}/${_tool}; \
956331810Shselasky		${MAKE} DIRPRFX=${_tool}/ obj; \
957331810Shselasky		${MAKE} DIRPRFX=${_tool}/ depend; \
958331810Shselasky		${MAKE} DIRPRFX=${_tool}/ all; \
959331810Shselasky		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
960331810Shselasky.endfor
961331810Shselasky
962331810Shselasky#
963331810Shselasky# hierarchy - ensure that all the needed directories are present
964331810Shselasky#
965341958Shselaskyhierarchy:
966341958Shselasky	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
967341958Shselasky
968331810Shselasky#
969331810Shselasky# libraries - build all libraries, and install them under ${DESTDIR}.
970331810Shselasky#
971331810Shselasky# The list of libraries with dependents (${_prebuild_libs}) and their
972331810Shselasky# interdependencies (__L) are built automatically by the
973331810Shselasky# ${.CURDIR}/tools/make_libdeps.sh script.
974331810Shselasky#
975331810Shselaskylibraries:
976331810Shselasky	cd ${.CURDIR}; \
977331810Shselasky	    ${MAKE} -f Makefile.inc1 _startup_libs; \
978331810Shselasky	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
979341958Shselasky	    ${MAKE} -f Makefile.inc1 _generic_libs;
980341958Shselasky
981331810Shselasky# These dependencies are not automatically generated:
982331810Shselasky#
983331810Shselasky# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
984331810Shselasky# shared libraries for ELF.
985331810Shselasky#
986331810Shselasky_startup_libs=	gnu/lib/csu gnu/lib/libgcc
987331810Shselasky.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
988331810Shselasky_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
989331810Shselasky.else
990331810Shselasky_startup_libs+=	lib/csu/${MACHINE_ARCH}
991331810Shselasky.endif
992331810Shselasky
993331810Shselasky_prebuild_libs=
994331580Shselasky
995331580Shselasky_generic_libs=	gnu/lib
996331580Shselasky
997331580Shselasky.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
998331580Shselasky_prebuild_libs+=	kerberos5/lib/libasn1
999331580Shselasky_prebuild_libs+=	kerberos5/lib/libgssapi
1000331580Shselasky_prebuild_libs+=	kerberos5/lib/libkrb5
1001290650Shselasky_prebuild_libs+=	kerberos5/lib/libroken
1002290650Shselasky_generic_libs+=	kerberos5/lib
1003306233Shselasky.endif
1004306233Shselasky
1005306233Shselasky_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
1006306233Shselasky		lib/libkvm lib/libmd \
1007306233Shselasky		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1008306233Shselasky		lib/libradius \
1009290650Shselasky		lib/libsbuf lib/libtacplus lib/libutil \
1010290650Shselasky		lib/libz lib/msun
1011290650Shselasky
1012331580Shselaskylib/libopie__L lib/libtacplus__L: lib/libmd__L
1013290650Shselasky
1014290650Shselasky.if !defined(NO_BIND)
1015290650Shselasky.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
1016290650Shselasky_prebuild_libs+= lib/libc_r
1017290650Shselasky.else
1018290650Shselasky_prebuild_libs+= lib/libpthread
1019290650Shselasky.endif
1020290650Shselasky.endif
1021290650Shselasky
1022290650Shselasky_generic_libs+=	lib
1023290650Shselasky
1024331810Shselasky.if !defined(NOCRYPT)
1025290650Shselasky.if !defined(NO_OPENSSL)
1026290650Shselasky_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
1027290650Shselaskylib/libradius__L: secure/lib/libssl__L
1028290650Shselaskysecure/lib/libssl__L: secure/lib/libcrypto__L
1029290650Shselasky.if !defined(NO_OPENSSH)
1030290650Shselasky_prebuild_libs+=	secure/lib/libssh
1031290650Shselaskysecure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1032290650Shselasky.if !defined(NO_KERBEROS)
1033290650Shselaskysecure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1034290650Shselasky    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1035290650Shselasky    kerberos5/lib/libroken__L
1036290650Shselasky.endif
1037290650Shselasky.endif
1038290650Shselasky.endif
1039290650Shselasky_generic_libs+=	secure/lib
1040290650Shselasky.endif
1041290650Shselasky
1042290650Shselasky.if defined(NOCRYPT) || defined(NO_OPENSSL)
1043290650Shselaskylib/libradius__L: lib/libmd__L
1044290650Shselasky.endif
1045329209Shselasky
1046329209Shselasky.if !defined(NO_NIS)
1047329209Shselasky_prebuild_libs+=	lib/libypclnt
1048329209Shselasky.endif
1049329209Shselasky
1050329209Shselasky_generic_libs+=	usr.bin/lex/lib
1051306233Shselasky
1052290650Shselasky.if ${MACHINE_ARCH} == "i386"
1053306233Shselasky_generic_libs+=	usr.sbin/pcvt/keycap
1054290650Shselasky.endif
1055290650Shselasky
1056290650Shselasky.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1057329209Shselasky${_lib}__L: .PHONY
1058290650Shselasky.if exists(${.CURDIR}/${_lib})
1059329209Shselasky	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1060290650Shselasky		cd ${.CURDIR}/${_lib}; \
1061290650Shselasky		${MAKE} DIRPRFX=${_lib}/ depend; \
1062290650Shselasky		${MAKE} DIRPRFX=${_lib}/ all; \
1063290650Shselasky		${MAKE} DIRPRFX=${_lib}/ install
1064290650Shselasky.endif
1065290650Shselasky.endfor
1066290650Shselasky
1067290650Shselasky# libpam is special: we need to build static PAM modules before
1068290650Shselasky# static PAM library, and dynamic PAM library before dynamic PAM
1069290650Shselasky# modules.
1070290650Shselaskylib/libpam__L: .PHONY
1071290650Shselasky	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1072290650Shselasky		cd ${.CURDIR}/lib/libpam; \
1073290650Shselasky		${MAKE} DIRPRFX=lib/libpam/ depend; \
1074290650Shselasky		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1075290650Shselasky		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1076290650Shselasky
1077331810Shselasky_startup_libs: ${_startup_libs:S/$/__L/}
1078331810Shselasky_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1079290650Shselasky_generic_libs: ${_generic_libs:S/$/__L/}
1080290650Shselasky
1081290650Shselasky.for __target in all clean cleandepend cleandir depend includes obj
1082290650Shselasky.for entry in ${SUBDIR}
1083290650Shselasky${entry}.${__target}__D: .PHONY
1084290650Shselasky	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1085331810Shselasky		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1086290650Shselasky		edir=${entry}.${MACHINE_ARCH}; \
1087290650Shselasky		cd ${.CURDIR}/$${edir}; \
1088290650Shselasky	else \
1089290650Shselasky		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1090290650Shselasky		edir=${entry}; \
1091331810Shselasky		cd ${.CURDIR}/$${edir}; \
1092290650Shselasky	fi; \
1093290650Shselasky	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1094290650Shselasky.endfor
1095290650Shselaskypar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1096290650Shselasky.endfor
1097290650Shselasky
1098290650Shselasky.include <bsd.subdir.mk>
1099290650Shselasky