Makefile.inc1 revision 138291
1145132Sanholt#
2145132Sanholt# $FreeBSD: head/Makefile.inc1 138291 2004-12-01 23:23:14Z peter $
3145132Sanholt#
4145132Sanholt# Make command line options:
5145132Sanholt#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6145132Sanholt#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7145132Sanholt#	-DNO_RESCUE do not build rescue binaries
8145132Sanholt#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9145132Sanholt#	-DNOCLEAN do not clean at all
10145132Sanholt#	-DNOCRYPT will prevent building of crypt versions
11145132Sanholt#	-DNOMAN do not build the manual pages
12145132Sanholt#	-DNOPROFILE do not build profiled libraries
13145132Sanholt#	-DNOGAMES do not go into games subdir
14145132Sanholt#	-DNOSHARE do not go into share subdir
15145132Sanholt#	-DNOINFO do not make or install info files
16145132Sanholt#	-DNOLIBC_R do not build libc_r.
17145132Sanholt#	-DNO_FORTRAN do not build g77 and related libraries.
18145132Sanholt#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
19145132Sanholt#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
20145132Sanholt#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
21145132Sanholt#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
22145132Sanholt#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
23145132Sanholt#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24145132Sanholt#	TARGET_ARCH="arch" to crossbuild world to a different arch
25145132Sanholt
26152909Sanholt#
27152909Sanholt# The intended user-driven targets are:
28152909Sanholt# buildworld  - rebuild *everything*, including glue to help do upgrades
29152909Sanholt# installworld- install everything built by "buildworld"
30152909Sanholt# update      - convenient way to update your source tree (eg: sup/cvs)
31145132Sanholt#
32145132Sanholt# Standard targets (not defined here) are documented in the makefiles in
33145132Sanholt# /usr/share/mk.  These include:
34145132Sanholt#		obj depend all install clean cleandepend cleanobj
35145132Sanholt
36145132Sanholt# We must do share/info early so that installation of info `dir'
37145132Sanholt# entries works correctly.  Do it first since it is less likely to
38182080Srnoland# grow dependencies on include and lib than vice versa.
39182080Srnoland#
40145132Sanholt# We must do lib and libexec before bin, because if installworld
41145132Sanholt# installs a new /bin/sh, the 'make' command will *immediately*
42145132Sanholt# use that new version.  And the new (dynamically-linked) /bin/sh
43145132Sanholt# will expect to find appropriate libraries in /lib and /libexec.
44145132Sanholt#
45145132Sanholt# We must do etc last for install/distribute to work.
46145132Sanholt#
47145132SanholtSUBDIR=	share/info include lib libexec bin
48145132Sanholt.if !defined(NOGAMES)
49145132SanholtSUBDIR+=games
50145132Sanholt.endif
51145132SanholtSUBDIR+=gnu
52145132Sanholt.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
53145132SanholtSUBDIR+=kerberos5
54145132Sanholt.endif
55145132Sanholt.if !defined(NO_RESCUE)
56145132SanholtSUBDIR+=rescue
57145132Sanholt.endif
58145132SanholtSUBDIR+=sbin
59145132Sanholt.if !defined(NOCRYPT)
60145132SanholtSUBDIR+=secure
61145132Sanholt.endif
62145132Sanholt.if !defined(NOSHARE)
63145132SanholtSUBDIR+=share
64145132Sanholt.endif
65145132SanholtSUBDIR+=sys usr.bin usr.sbin etc
66182080Srnoland
67145132Sanholt# These are last, since it is nice to at least get the base system
68145132Sanholt# rebuilt before you do them.
69145132Sanholt.for _DIR in ${LOCAL_DIRS}
70145132Sanholt.if exists(${.CURDIR}/${_DIR}/Makefile)
71145132SanholtSUBDIR+= ${_DIR}
72145132Sanholt.endif
73145132Sanholt.endfor
74145132Sanholt
75145132Sanholt.if defined(SUBDIR_OVERRIDE)
76145132SanholtSUBDIR=		${SUBDIR_OVERRIDE}
77145132Sanholt.endif
78145132Sanholt
79145132Sanholt.if defined(NOCLEANDIR)
80145132SanholtCLEANDIR=	clean cleandepend
81145132Sanholt.else
82145132SanholtCLEANDIR=	cleandir
83145132Sanholt.endif
84145132Sanholt
85145132SanholtCVS?=		cvs
86145132SanholtCVSFLAGS?=	-A -P -d -I!
87182080SrnolandSUP?=		/usr/local/bin/cvsup
88145132SanholtSUPFLAGS?=	-g -L 2 -P -
89145132Sanholt.if defined(SUPHOST)
90145132SanholtSUPFLAGS+=	-h ${SUPHOST}
91145132Sanholt.endif
92145132Sanholt
93145132SanholtMAKEOBJDIRPREFIX?=	/usr/obj
94145132Sanholt.if !defined(OSRELDATE)
95145132Sanholt.if exists(/usr/include/osreldate.h)
96145132SanholtOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
97145132Sanholt		/usr/include/osreldate.h
98145132Sanholt.else
99145132SanholtOSRELDATE=	0
100145132Sanholt.endif
101145132Sanholt.endif
102145132SanholtTARGET_ARCH?=	${MACHINE_ARCH}
103145132Sanholt.if ${TARGET_ARCH} == ${MACHINE_ARCH}
104145132SanholtTARGET?=	${MACHINE}
105145132SanholtTARGET_CPUTYPE?=${CPUTYPE}
106145132Sanholt.else
107145132SanholtTARGET?=	${TARGET_ARCH}
108182080SrnolandTARGET_CPUTYPE?=
109145132Sanholt.endif
110145132Sanholt.if !empty(TARGET_CPUTYPE)
111145132Sanholt_TARGET_CPUTYPE=${TARGET_CPUTYPE}
112145132Sanholt.else
113145132Sanholt_TARGET_CPUTYPE=dummy
114145132Sanholt.endif
115145132Sanholt_CPUTYPE!=	MAKEFLAGS= ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
116145132Sanholt		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
117145132Sanholt.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
118145132Sanholt.error CPUTYPE global should be set with ?=.
119145132Sanholt.endif
120145132Sanholt.if make(buildworld)
121145132SanholtBUILD_ARCH!=	sysctl -n hw.machine_arch
122145132Sanholt.if ${MACHINE_ARCH} != ${BUILD_ARCH}
123145132Sanholt.error To cross-build, set TARGET_ARCH.
124145132Sanholt.endif
125145132Sanholt.endif
126145132Sanholt.if ${MACHINE} == ${TARGET}
127145132SanholtOBJTREE=	${MAKEOBJDIRPREFIX}
128145132Sanholt.else
129145132SanholtOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
130145132Sanholt.endif
131145132SanholtWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
132145132Sanholt# /usr/games added for fortune which depend on strfile
133145132SanholtBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
134145132SanholtXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
135145132SanholtSTRICTTMPPATH=	${BPATH}:${XPATH}
136145132SanholtTMPPATH=	${STRICTTMPPATH}:${PATH}
137145132Sanholt
138145132SanholtINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
139145132Sanholt
140145132Sanholt#
141145132Sanholt# Building a world goes through the following stages
142182080Srnoland#
143145132Sanholt# 1. legacy stage [BMAKE]
144145132Sanholt#	This stage is responsible for creating compatibility
145145132Sanholt#	shims that are needed by the bootstrap-tools,
146145132Sanholt#	build-tools and cross-tools stages.
147145132Sanholt# 1. bootstrap-tools stage [BMAKE]
148145132Sanholt#	This stage is responsible for creating programs that
149145132Sanholt#	are needed for backward compatibility reasons. They
150145132Sanholt#	are not built as cross-tools.
151145132Sanholt# 2. build-tools stage [TMAKE]
152145132Sanholt#	This stage is responsible for creating the object
153145132Sanholt#	tree and building any tools that are needed during
154145132Sanholt#	the build process.
155145132Sanholt# 3. cross-tools stage [XMAKE]
156145132Sanholt#	This stage is responsible for creating any tools that
157145132Sanholt#	are needed for cross-builds. A cross-compiler is one
158145132Sanholt#	of them.
159145132Sanholt# 4. world stage [WMAKE]
160145132Sanholt#	This stage actually builds the world.
161145132Sanholt# 5. install stage (optional) [IMAKE]
162145132Sanholt#	This stage installs a previously built world.
163145132Sanholt#
164182080Srnoland
165145132SanholtBOOTSTRAPPING?=	0
166145132Sanholt
167145132Sanholt# Common environment for world related stages
168145132SanholtCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
169145132Sanholt		MACHINE_ARCH=${TARGET_ARCH} \
170152909Sanholt		MACHINE=${TARGET} \
171145132Sanholt		CPUTYPE=${TARGET_CPUTYPE} \
172145132Sanholt		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
173145132Sanholt		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
174145132Sanholt		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
175145132Sanholt
176145132Sanholt# bootstrap-tools stage
177145132SanholtBMAKEENV=	INSTALL="sh ${.CURDIR}/tools/install.sh" \
178145132Sanholt		PATH=${BPATH}:${PATH} \
179145132Sanholt		WORLDTMP=${WORLDTMP} \
180145132Sanholt		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
181145132SanholtBMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
182145132Sanholt		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
183145132Sanholt		DESTDIR= \
184145132Sanholt		BOOTSTRAPPING=${OSRELDATE} \
185145132Sanholt		-DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
186145132Sanholt		-DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
187145132Sanholt
188145132Sanholt# build-tools stage
189145132SanholtTMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
190145132Sanholt		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
191145132Sanholt		DESTDIR= \
192145132Sanholt		BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
193145132Sanholt
194145132Sanholt# cross-tools stage
195145132SanholtXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
196145132Sanholt
197145132Sanholt# world stage
198145132SanholtWMAKEENV=	${CROSSENV} \
199145132Sanholt		_SHLIBDIRPREFIX=${WORLDTMP} \
200145132Sanholt		INSTALL="sh ${.CURDIR}/tools/install.sh" \
201145132Sanholt		PATH=${TMPPATH}
202145132SanholtWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
203145132Sanholt
204145132Sanholt.if ${MACHINE_ARCH} == "amd64"
205145132Sanholt# 32 bit world
206145132SanholtLIB32TMP=	${OBJTREE}${.CURDIR}/lib32
207145132Sanholt
208145132SanholtLIB32PREFLAGS=	-m32 -march=athlon-xp -msse2 -mfancy-math-387 -DCOMPAT_32BIT
209182080SrnolandLIB32POSTFLAGS=	-I${LIB32TMP}/usr/include \
210145132Sanholt		-L${LIB32TMP}/usr/lib32 \
211145132Sanholt		-B${LIB32TMP}/usr/lib32
212182080SrnolandLIB32CC=	${LIB32PREFLAGS} \
213182080Srnoland		${LIB32POSTFLAGS}
214145132SanholtLIB32CXX=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/c++/3.4 \
215145132Sanholt		${LIB32POSTFLAGS}
216145132SanholtLIB32OBJC=	${LIB32PREFLAGS} -I${LIB32TMP}/usr/include/objc \
217145132Sanholt		${LIB32POSTFLAGS}
218145132Sanholt
219145132Sanholt# Yes, the flags are redundant.
220145132SanholtLIB32MAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
221145132Sanholt		_SHLIBDIRPREFIX=${LIB32TMP} \
222145132Sanholt		MACHINE_ARCH=i386 \
223145132Sanholt		INSTALL="sh ${.CURDIR}/tools/install.sh" \
224145132Sanholt		PATH=${TMPPATH} \
225145132Sanholt		CC="cc ${LIB32CC}" \
226145132Sanholt		CXX="c++ ${LIB32CXX}" \
227145132Sanholt		OBJC="cc ${LIB32OBJC}" \
228145132Sanholt		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
229145132Sanholt		AS="as --32" \
230145132Sanholt		LIBDIR=/usr/lib32 \
231145132Sanholt		SHLIBDIR=/usr/lib32
232145132Sanholt
233145132SanholtLIB32MAKE=	${LIB32MAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
234145132Sanholt		-DNO_BIND -DNOMAN -DNODOC -DNOINFO -DNOHTML \
235145132Sanholt		CC="cc ${LIB32CC}" \
236145132Sanholt		CXX="c++ ${LIB32CXX}" \
237145132Sanholt		OBJC="cc ${LIB32OBJC}" \
238145132Sanholt		LD="ld -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
239145132Sanholt		AS="as --32" \
240145132Sanholt		LIBDIR=/usr/lib32 \
241145132Sanholt		SHLIBDIR=/usr/lib32
242182080Srnoland.endif
243145132Sanholt
244145132Sanholt# install stage
245145132Sanholt.if empty(.MAKEFLAGS:M-n)
246145132SanholtIMAKEENV=	${CROSSENV} \
247145132Sanholt		PATH=${STRICTTMPPATH}:${INSTALLTMP}
248145132Sanholt.else
249145132SanholtIMAKEENV=	${CROSSENV} \
250145132Sanholt		PATH=${TMPPATH}:${INSTALLTMP}
251145132Sanholt.endif
252145132SanholtIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
253145132Sanholt
254145132Sanholt# kernel stage
255145132SanholtKMAKEENV=	${WMAKEENV}
256145132Sanholt
257145132Sanholt#
258145132Sanholt# buildworld
259145132Sanholt#
260145132Sanholt# Attempt to rebuild the entire system, with reasonable chance of
261145132Sanholt# success, regardless of how old your existing system is.
262145132Sanholt#
263145132Sanholt_worldtmp:
264145132Sanholt.if ${.CURDIR:C/[^,]//g} != ""
265145132Sanholt#	The m4 build of sendmail files doesn't like it if ',' is used
266145132Sanholt#	anywhere in the path of it's files.
267145132Sanholt	@echo
268145132Sanholt	@echo "*** Error: path to source tree contains a comma ','"
269145132Sanholt	@echo
270145132Sanholt	false
271145132Sanholt.endif
272145132Sanholt	@echo
273145132Sanholt	@echo "--------------------------------------------------------------"
274145132Sanholt	@echo ">>> Rebuilding the temporary build tree"
275182080Srnoland	@echo "--------------------------------------------------------------"
276145132Sanholt.if !defined(NOCLEAN)
277145132Sanholt	rm -rf ${WORLDTMP}
278145132Sanholt.else
279145132Sanholt	rm -rf ${WORLDTMP}/legacy/usr/include
280145132Sanholt	# XXX - These two can depend on any header file.
281145132Sanholt	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
282145132Sanholt	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
283145132Sanholt.endif
284145132Sanholt.for _dir in \
285145132Sanholt    usr/bin usr/games usr/include/c++/3.4 usr/include/sys usr/lib \
286145132Sanholt    usr/libexec usr/sbin usr/share/dict \
287145132Sanholt    usr/share/groff_font/devX100 \
288145132Sanholt    usr/share/groff_font/devX100-12 \
289145132Sanholt    usr/share/groff_font/devX75 \
290145132Sanholt    usr/share/groff_font/devX75-12 \
291145132Sanholt    usr/share/groff_font/devascii \
292145132Sanholt    usr/share/groff_font/devcp1047 \
293145132Sanholt    usr/share/groff_font/devdvi \
294145132Sanholt    usr/share/groff_font/devhtml \
295145132Sanholt    usr/share/groff_font/devkoi8-r \
296145132Sanholt    usr/share/groff_font/devlatin1 \
297145132Sanholt    usr/share/groff_font/devlbp \
298145132Sanholt    usr/share/groff_font/devlj4 \
299145132Sanholt    usr/share/groff_font/devps \
300145132Sanholt    usr/share/groff_font/devutf8 \
301145132Sanholt    usr/share/tmac/mdoc usr/share/tmac/mm
302145132Sanholt	mkdir -p ${WORLDTMP}/legacy/${_dir}
303145132Sanholt.endfor
304145132Sanholt.for _dir in \
305157617Sanholt    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
306145132Sanholt    usr/libexec usr/sbin usr/share/misc \
307182080Srnoland    usr/share/snmp/defs usr/share/snmp/mibs
308145132Sanholt	mkdir -p ${WORLDTMP}/${_dir}
309145132Sanholt.endfor
310145132Sanholt	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
311145132Sanholt	    -p ${WORLDTMP}/usr/include >/dev/null
312145132Sanholt	ln -sf ${.CURDIR}/sys ${WORLDTMP}
313145132Sanholt.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
314145132Sanholt	mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
315145132Sanholt	    -p ${WORLDTMP}/usr/include >/dev/null
316145132Sanholt.endif
317145132Sanholt_legacy:
318145132Sanholt	@echo
319145132Sanholt	@echo "--------------------------------------------------------------"
320145132Sanholt	@echo ">>> stage 1.1: legacy release compatibility shims"
321145132Sanholt	@echo "--------------------------------------------------------------"
322145132Sanholt	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
323145132Sanholt_bootstrap-tools:
324145132Sanholt	@echo
325145132Sanholt	@echo "--------------------------------------------------------------"
326145132Sanholt	@echo ">>> stage 1.2: bootstrap tools"
327145132Sanholt	@echo "--------------------------------------------------------------"
328145132Sanholt	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
329145132Sanholt_cleanobj:
330145132Sanholt.if !defined(NOCLEAN)
331145132Sanholt	@echo
332145132Sanholt	@echo "--------------------------------------------------------------"
333145132Sanholt	@echo ">>> stage 2.1: cleaning up the object tree"
334145132Sanholt	@echo "--------------------------------------------------------------"
335145132Sanholt	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
336145132Sanholt.endif
337145132Sanholt_obj:
338145132Sanholt	@echo
339145132Sanholt	@echo "--------------------------------------------------------------"
340145132Sanholt	@echo ">>> stage 2.2: rebuilding the object tree"
341145132Sanholt	@echo "--------------------------------------------------------------"
342145132Sanholt	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
343145132Sanholt_build-tools:
344145132Sanholt	@echo
345145132Sanholt	@echo "--------------------------------------------------------------"
346145132Sanholt	@echo ">>> stage 2.3: build tools"
347145132Sanholt	@echo "--------------------------------------------------------------"
348145132Sanholt	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
349145132Sanholt_cross-tools:
350145132Sanholt	@echo
351145132Sanholt	@echo "--------------------------------------------------------------"
352145132Sanholt	@echo ">>> stage 3: cross tools"
353145132Sanholt	@echo "--------------------------------------------------------------"
354145132Sanholt	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
355145132Sanholt_includes:
356145132Sanholt	@echo
357145132Sanholt	@echo "--------------------------------------------------------------"
358145132Sanholt	@echo ">>> stage 4.1: building includes"
359145132Sanholt	@echo "--------------------------------------------------------------"
360145132Sanholt	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
361145132Sanholt_libraries:
362145132Sanholt	@echo
363145132Sanholt	@echo "--------------------------------------------------------------"
364145132Sanholt	@echo ">>> stage 4.2: building libraries"
365145132Sanholt	@echo "--------------------------------------------------------------"
366145132Sanholt	${_+_}cd ${.CURDIR}; \
367145132Sanholt	    ${WMAKE} -DNOFSCHG -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPROFILE \
368145132Sanholt	    libraries
369145132Sanholt_depend:
370182080Srnoland	@echo
371145132Sanholt	@echo "--------------------------------------------------------------"
372145132Sanholt	@echo ">>> stage 4.3: make dependencies"
373145132Sanholt	@echo "--------------------------------------------------------------"
374145132Sanholt	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
375145132Sanholteverything:
376145132Sanholt	@echo
377145132Sanholt	@echo "--------------------------------------------------------------"
378145132Sanholt	@echo ">>> stage 4.4: building everything"
379207066Srnoland	@echo "--------------------------------------------------------------"
380182080Srnoland	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
381145132Sanholt.if ${MACHINE_ARCH} == "amd64"
382145132Sanholtbuild32:
383145132Sanholt	@echo
384145132Sanholt	@echo "--------------------------------------------------------------"
385145132Sanholt	@echo ">>> stage 5.1: building 32 bit shim libraries"
386145132Sanholt	@echo "--------------------------------------------------------------"
387145132Sanholt.for _dir in \
388157617Sanholt    lib lib32 usr/bin usr/include usr/lib32 usr/libdata/ldscripts \
389182080Srnoland    usr/libexec usr/sbin usr/share/misc \
390145132Sanholt    usr/share/snmp/defs usr/share/snmp/mibs
391145132Sanholt	mkdir -p ${LIB32TMP}/${_dir}
392145132Sanholt.endfor
393145132Sanholt	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
394145132Sanholt	    -p ${LIB32TMP}/usr/include >/dev/null
395207066Srnoland	ln -sf ${.CURDIR}/sys ${WORLDTMP}
396145132Sanholt.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
397145132Sanholt.for _t in obj depend all
398145132Sanholt	cd ${.CURDIR}/kerberos5/tools; \
399145132Sanholt	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} ${_t}
400145132Sanholt.endfor
401145132Sanholt.endif
402145132Sanholt.for _t in obj includes
403145132Sanholt	cd ${.CURDIR}/include; \
404145132Sanholt	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
405145132Sanholt	cd ${.CURDIR}/lib; \
406145132Sanholt	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
407145132Sanholt	cd ${.CURDIR}/gnu/lib; \
408145132Sanholt	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
409145132Sanholt.if !defined(NOCRYPT)
410145132Sanholt	cd ${.CURDIR}/secure/lib; \
411145132Sanholt	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
412145132Sanholt.endif
413145132Sanholt.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
414145132Sanholt	cd ${.CURDIR}/kerberos5/lib; \
415145132Sanholt	    ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
416145132Sanholt.endif
417145132Sanholt.endfor
418145132Sanholt.for _dir in usr.sbin/pcvt/keycap usr.bin/lex/lib
419145132Sanholt	cd ${.CURDIR}/${_dir}; \
420145132Sanholt	    ${LIB32MAKE} DESTDIR=${LIB32TMP} obj
421145132Sanholt.endfor
422145132Sanholt.for _dir in lib/libncurses lib/libmagic
423145132Sanholt	cd ${.CURDIR}/${_dir}; \
424145132Sanholt	    MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} build-tools
425145132Sanholt.endfor
426145132Sanholt	cd ${.CURDIR}; \
427145132Sanholt	    ${LIB32MAKE} -f Makefile.inc1 DESTDIR=${LIB32TMP} libraries 
428152909Sanholt.for _t in obj depend all
429145132Sanholt	cd ${.CURDIR}/libexec/rtld-elf; \
430145132Sanholt	    PROG=ld-elf32.so.1 ${LIB32MAKE} DESTDIR=${LIB32TMP} ${_t}
431145132Sanholt.endfor
432145132Sanholt
433145132Sanholtinstall32:
434145132Sanholt	mkdir -p ${DESTDIR}/usr/lib32	# XXX add to mtree
435145132Sanholt	cd ${.CURDIR}/lib; ${LIB32MAKE} install
436145132Sanholt	cd ${.CURDIR}/gnu/lib; ${LIB32MAKE} install
437145132Sanholt.if !defined(NOCRYPT)
438145132Sanholt	cd ${.CURDIR}/secure/lib; ${LIB32MAKE} install
439145132Sanholt.endif
440145132Sanholt	cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32MAKE} install
441145132Sanholt.endif
442145132Sanholt
443145132Sanholt
444145132SanholtWMAKE_TGTS=
445145132Sanholt.if !defined(SUBDIR_OVERRIDE)
446207066SrnolandWMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
447157617Sanholt.endif
448145132SanholtWMAKE_TGTS+=	_cleanobj _obj _build-tools
449182080Srnoland.if !defined(SUBDIR_OVERRIDE)
450145132SanholtWMAKE_TGTS+=	_cross-tools
451145132Sanholt.endif
452145132SanholtWMAKE_TGTS+=	_includes _libraries _depend everything
453145132Sanholt.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
454145132SanholtWMAKE_TGTS+=	build32
455145132Sanholt.endif
456145132Sanholt
457145132Sanholtbuildworld: ${WMAKE_TGTS}
458145132Sanholt.ORDER: ${WMAKE_TGTS}
459145132Sanholt
460145132SanholtTOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
461145132Sanholttoolchain: ${TOOLCHAIN_TGTS}
462157617Sanholtkernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
463145132Sanholt
464145132Sanholt#
465145132Sanholt# Use this to add checks to installworld/installkernel targets.
466145132Sanholt#
467145132SanholtSPECIAL_INSTALLCHECKS=
468145132Sanholt
469145132Sanholt#
470145132Sanholt# The following install-time check will see if the installation will
471145132Sanholt# change the type used for time_t, and if it will, the target makes
472145132Sanholt# sure that the user is expecting to make that change.
473145132Sanholt#
474145132Sanholt.if ${TARGET_ARCH} == "sparc64"
475145132SanholtSPECIAL_INSTALLCHECKS+=sparc64_installcheck
476145132Sanholt
477145132SanholtCUR_TIMET!=	grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
478145132SanholtSRC_TIMET!=	grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
479145132Sanholt		awk '{print $$2}'
480145132SanholtNEWSPARC_TIMETYPE?=${CUR_TIMET}
481145132Sanholt
482145132Sanholtsparc64_installcheck:
483145132Sanholt.if ${CUR_TIMET} != ${SRC_TIMET}
484145132Sanholt	@echo
485145132Sanholt.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
486145132Sanholt	@echo "***  ERROR: This target would change the type used for time_t!"
487145132Sanholt.else
488145132Sanholt	@echo "* Note: This installation changes the type used for time_t."
489145132Sanholt.endif
490145132Sanholt	@echo "* "
491145132Sanholt	@echo "* This host has time_t defined as ${CUR_TIMET},"
492145132Sanholt	@echo "* and this installation would change that to type ${SRC_TIMET}."
493145132Sanholt.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
494145132Sanholt	@echo "* "
495145132Sanholt	@echo "* If that is *NOT* what you wanted, then you need to change the"
496145132Sanholt	@echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
497145132Sanholt	@echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'.  After that you *MUST*"
498145132Sanholt	@echo "* do a complete cleanworld, buildworld, buildkernel before you"
499145132Sanholt	@echo "* retry the 'make' command.  Also read /usr/src/UPDATING.64BTT."
500145132Sanholt	@echo "* "
501145132Sanholt	@echo "* If that *is* what you want, then enter the commands:"
502145132Sanholt	@echo "      NEWSPARC_TIMETYPE=${SRC_TIMET}"
503145132Sanholt	@echo "      export NEWSPARC_TIMETYPE"
504145132Sanholt	@echo "* and repeat your 'make' command."
505145132Sanholt	@echo
506152909Sanholt	false
507145132Sanholt.endif
508152909Sanholt	@echo
509145132Sanholt.elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
510145132Sanholt	@echo
511145132Sanholt	@echo "***  ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
512145132Sanholt	@echo "***         but ${.CURDIR}/sys/sparc64/include/_types.h"
513145132Sanholt	@echo "***         has __time_t defined as '${SRC_TIMET}'."
514145132Sanholt	false
515145132Sanholt.else
516145132Sanholt	@# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
517145132Sanholt.endif
518145132Sanholt.endif
519145132Sanholt
520207066Srnoland#
521145132Sanholt# installcheck
522145132Sanholt#
523145132Sanholt# Checks to be sure system is ready for installworld
524145132Sanholt#
525145132SanholtCHECK_UIDS=
526145132SanholtCHECK_GIDS=
527145132Sanholt.if !defined(NO_SENDMAIL)
528145132SanholtCHECK_UIDS+=	smmsp
529145132SanholtCHECK_GIDS+=	smmsp
530145132Sanholt.endif
531145132Sanholt.if !defined(NO_PF)
532145132SanholtCHECK_UIDS+=	proxy
533145132SanholtCHECK_GIDS+=	proxy authpf
534145132Sanholt.endif
535145132Sanholtinstallcheck: ${SPECIAL_INSTALLCHECKS}
536145132Sanholt.for uid in ${CHECK_UIDS}
537145132Sanholt	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
538145132Sanholt		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
539145132Sanholt		false; \
540145132Sanholt	fi
541182080Srnoland.endfor
542145132Sanholt.for gid in ${CHECK_GIDS}
543145132Sanholt	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
544145132Sanholt		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
545145132Sanholt		false; \
546145132Sanholt	fi
547182080Srnoland.endfor
548145132Sanholt
549145132Sanholt#
550145132Sanholt# distributeworld
551152909Sanholt#
552145132Sanholt# Distributes everything compiled by a `buildworld'.
553145132Sanholt#
554152909Sanholt# installworld
555152909Sanholt#
556152909Sanholt# Installs everything compiled by a 'buildworld'.
557152909Sanholt#
558152909Sanholtdistributeworld installworld: installcheck
559152909Sanholt	mkdir -p ${INSTALLTMP}
560152909Sanholt	for prog in [ awk cap_mkdb cat chflags chmod chown \
561152909Sanholt	    date echo egrep find grep \
562152909Sanholt	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
563182080Srnoland	    test true uname wc zic; do \
564152909Sanholt		cp `which $$prog` ${INSTALLTMP}; \
565152909Sanholt	done
566152909Sanholt	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
567152909Sanholt	rm -rf ${INSTALLTMP}
568152909Sanholt
569152909Sanholt#
570152909Sanholt# reinstall
571152909Sanholt#
572152909Sanholt# If you have a build server, you can NFS mount the source and obj directories
573152909Sanholt# and do a 'make reinstall' on the *client* to install new binaries from the
574145132Sanholt# most recent server build.
575145132Sanholt#
576145132Sanholtreinstall: ${SPECIAL_INSTALLCHECKS}
577145132Sanholt	@echo "--------------------------------------------------------------"
578145132Sanholt	@echo ">>> Making hierarchy"
579145132Sanholt	@echo "--------------------------------------------------------------"
580145132Sanholt	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
581145132Sanholt	@echo
582145132Sanholt	@echo "--------------------------------------------------------------"
583145132Sanholt	@echo ">>> Installing everything"
584145132Sanholt	@echo "--------------------------------------------------------------"
585145132Sanholt	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
586145132Sanholt.if ${MACHINE_ARCH} == "amd64" && defined(WITH_LIB32)
587145132Sanholt	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
588145132Sanholt.endif
589145132Sanholt
590182080Srnolandredistribute:
591157617Sanholt	@echo "--------------------------------------------------------------"
592157617Sanholt	@echo ">>> Distributing everything"
593182080Srnoland	@echo "--------------------------------------------------------------"
594145132Sanholt	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
595157617Sanholt
596157617Sanholt#
597157617Sanholt# buildkernel and installkernel
598182080Srnoland#
599145132Sanholt# Which kernels to build and/or install is specified by setting
600157617Sanholt# KERNCONF. If not defined a GENERIC kernel is built/installed.
601182080Srnoland# Only the existing (depending TARGET) config files are used
602157617Sanholt# for building kernels and only the first of these is designated
603145132Sanholt# as the one being installed.
604145132Sanholt#
605145132Sanholt# Note that we have to use TARGET instead of TARGET_ARCH when
606145132Sanholt# we're in kernel-land. Since only TARGET_ARCH is (expected) to
607152909Sanholt# be set to cross-build, we have to make sure TARGET is set
608152909Sanholt# properly.
609145132Sanholt
610145132Sanholt.if !defined(KERNCONF) && defined(KERNEL)
611145132SanholtKERNCONF=	${KERNEL}
612145132SanholtKERNWARN=
613145132Sanholt.else
614145132SanholtKERNCONF?=	GENERIC
615145132Sanholt.endif
616145132SanholtINSTKERNNAME?=	kernel
617145132Sanholt
618145132SanholtKERNSRCDIR?=	${.CURDIR}/sys
619145132SanholtKRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
620145132SanholtKRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
621182080SrnolandKERNCONFDIR?=	${KRNLCONFDIR}
622157617Sanholt
623157617SanholtBUILDKERNELS=
624145132SanholtINSTALLKERNEL=
625145132Sanholt.for _kernel in ${KERNCONF}
626145132Sanholt.if exists(${KERNCONFDIR}/${_kernel})
627145132SanholtBUILDKERNELS+=	${_kernel}
628145132Sanholt.if empty(INSTALLKERNEL)
629145132SanholtINSTALLKERNEL= ${_kernel}
630145132Sanholt.endif
631145132Sanholt.endif
632145132Sanholt.endfor
633145132Sanholt
634145132Sanholt#
635145132Sanholt# buildkernel
636145132Sanholt#
637145132Sanholt# Builds all kernels defined by BUILDKERNELS.
638152909Sanholt#
639152909Sanholtbuildkernel:
640152909Sanholt.if empty(BUILDKERNELS)
641145132Sanholt	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
642145132Sanholt	false
643152909Sanholt.endif
644152909Sanholt.if defined(KERNWARN)
645152909Sanholt	@echo "--------------------------------------------------------------"
646145132Sanholt	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
647145132Sanholt	@echo "--------------------------------------------------------------"
648152909Sanholt	@sleep 3
649152909Sanholt.endif
650152909Sanholt	@echo
651152909Sanholt.for _kernel in ${BUILDKERNELS}
652145132Sanholt	@echo "--------------------------------------------------------------"
653145132Sanholt	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
654145132Sanholt	@echo "--------------------------------------------------------------"
655145132Sanholt	@echo "===> ${_kernel}"
656145132Sanholt	mkdir -p ${KRNLOBJDIR}
657145132Sanholt.if !defined(NO_KERNELCONFIG)
658145132Sanholt	@echo
659145132Sanholt	@echo "--------------------------------------------------------------"
660182080Srnoland	@echo ">>> stage 1: configuring the kernel"
661145132Sanholt	@echo "--------------------------------------------------------------"
662145132Sanholt	cd ${KRNLCONFDIR}; \
663145132Sanholt		PATH=${TMPPATH} \
664145132Sanholt		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
665145132Sanholt			${KERNCONFDIR}/${_kernel}
666145132Sanholt.endif
667152909Sanholt.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
668152909Sanholt	@echo
669157617Sanholt	@echo "--------------------------------------------------------------"
670152909Sanholt	@echo ">>> stage 2.1: cleaning up the object tree"
671145132Sanholt	@echo "--------------------------------------------------------------"
672182080Srnoland	cd ${KRNLOBJDIR}/${_kernel}; \
673152909Sanholt	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
674152909Sanholt.endif
675152909Sanholt	@echo
676145132Sanholt	@echo "--------------------------------------------------------------"
677145132Sanholt	@echo ">>> stage 2.2: rebuilding the object tree"
678145132Sanholt	@echo "--------------------------------------------------------------"
679145132Sanholt	cd ${KRNLOBJDIR}/${_kernel}; \
680145132Sanholt	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
681182080Srnoland	@echo
682145132Sanholt	@echo "--------------------------------------------------------------"
683145132Sanholt	@echo ">>> stage 2.3: build tools"
684145132Sanholt	@echo "--------------------------------------------------------------"
685145132Sanholt	cd ${KRNLOBJDIR}/${_kernel}; \
686145132Sanholt	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
687182080Srnoland	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
688145132Sanholt# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
689145132Sanholt.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
690145132Sanholt.for target in obj depend all
691182080Srnoland	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
692145132Sanholt	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
693145132Sanholt	    ${MAKE} -DNO_CPU_CFLAGS ${target}
694145132Sanholt.endfor
695145132Sanholt.endif
696182080Srnoland.if !defined(NO_KERNELDEPEND)
697145132Sanholt	@echo
698145132Sanholt	@echo "--------------------------------------------------------------"
699145132Sanholt	@echo ">>> stage 3.1: making dependencies"
700145132Sanholt	@echo "--------------------------------------------------------------"
701145132Sanholt	cd ${KRNLOBJDIR}/${_kernel}; \
702145132Sanholt	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
703145132Sanholt.endif
704145132Sanholt	@echo
705145132Sanholt	@echo "--------------------------------------------------------------"
706145132Sanholt	@echo ">>> stage 3.2: building everything"
707145132Sanholt	@echo "--------------------------------------------------------------"
708145132Sanholt	cd ${KRNLOBJDIR}/${_kernel}; \
709145132Sanholt	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
710145132Sanholt	@echo "--------------------------------------------------------------"
711145132Sanholt	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
712145132Sanholt	@echo "--------------------------------------------------------------"
713145132Sanholt.endfor
714145132Sanholt
715145132Sanholt#
716182080Srnoland# installkernel, etc.
717145132Sanholt#
718145132Sanholt# Install the kernel defined by INSTALLKERNEL
719145132Sanholt#
720182080Srnolandinstallkernel installkernel.debug \
721145132Sanholtreinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
722145132Sanholt.if empty(INSTALLKERNEL)
723145132Sanholt	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
724145132Sanholt	false
725145132Sanholt.endif
726145132Sanholt	@echo "--------------------------------------------------------------"
727182080Srnoland	@echo ">>> Making hierarchy"
728145132Sanholt	@echo "--------------------------------------------------------------"
729145132Sanholt	cd ${.CURDIR}; \
730145132Sanholt	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
731145132Sanholt	@echo
732145132Sanholt	@echo "--------------------------------------------------------------"
733182080Srnoland	@echo ">>> Installing kernel"
734145132Sanholt	@echo "--------------------------------------------------------------"
735145132Sanholt	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
736145132Sanholt	    ${CROSSENV} PATH=${TMPPATH} \
737145132Sanholt	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
738145132Sanholt
739182080Srnoland#
740145132Sanholt# update
741145132Sanholt#
742145132Sanholt# Update the source tree, by running sup and/or running cvs to update to the
743145132Sanholt# latest copy.
744145132Sanholt#
745182080Srnolandupdate:
746145132Sanholt.if defined(SUP_UPDATE)
747145132Sanholt	@echo "--------------------------------------------------------------"
748145132Sanholt	@echo ">>> Running ${SUP}"
749145132Sanholt	@echo "--------------------------------------------------------------"
750145132Sanholt.if defined(SUPFILE)
751145132Sanholt	@${SUP} ${SUPFLAGS} ${SUPFILE}
752145132Sanholt.endif
753145132Sanholt.if defined(SUPFILE1)
754182080Srnoland	@${SUP} ${SUPFLAGS} ${SUPFILE1}
755145132Sanholt.endif
756145132Sanholt.if defined(SUPFILE2)
757145132Sanholt	@${SUP} ${SUPFLAGS} ${SUPFILE2}
758145132Sanholt.endif
759145132Sanholt.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
760145132Sanholt	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
761145132Sanholt.endif
762145132Sanholt.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
763145132Sanholt	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
764145132Sanholt.endif
765182080Srnoland.endif
766145132Sanholt.if defined(CVS_UPDATE)
767145132Sanholt	@echo "--------------------------------------------------------------"
768145132Sanholt	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
769145132Sanholt	@echo "--------------------------------------------------------------"
770145132Sanholt	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
771182080Srnoland.endif
772145132Sanholt
773145132Sanholt#
774145132Sanholt# ------------------------------------------------------------------------
775145132Sanholt#
776145132Sanholt# From here onwards are utility targets used by the 'make world' and
777182080Srnoland# related targets.  If your 'world' breaks, you may like to try to fix
778145132Sanholt# the problem and manually run the following targets to attempt to
779145132Sanholt# complete the build.  Beware, this is *not* guaranteed to work, you
780145132Sanholt# need to have a pretty good grip on the current state of the system
781145132Sanholt# to attempt to manually finish it.  If in doubt, 'make world' again.
782145132Sanholt#
783145132Sanholt
784182080Srnoland#
785145132Sanholt# legacy: Build compatibility shims for the next three targets
786145132Sanholt#
787207066Srnolandlegacy:
788145132Sanholt.for _tool in tools/build
789145132Sanholt	${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
790145132Sanholt	    cd ${.CURDIR}/${_tool}; \
791182080Srnoland	    ${MAKE} DIRPRFX=${_tool}/ obj; \
792145132Sanholt	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
793145132Sanholt	    ${MAKE} DIRPRFX=${_tool}/ depend; \
794145132Sanholt	    ${MAKE} DIRPRFX=${_tool}/ all; \
795145132Sanholt	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
796145132Sanholt.endfor
797182080Srnoland
798145132Sanholt#
799145132Sanholt# bootstrap-tools: Build tools needed for compatibility
800145132Sanholt#
801145132Sanholt.if !defined(NOGAMES)
802145132Sanholt_strfile=	games/fortune/strfile
803145132Sanholt.endif
804145132Sanholt
805145132Sanholt.if !defined(NO_CXX)
806145132Sanholt_gperf=	gnu/usr.bin/gperf
807145132Sanholt.if ${BOOTSTRAPPING} < 500113
808145132Sanholt_groff=		gnu/usr.bin/groff
809207066Srnoland.else
810145132Sanholt_groff=		gnu/usr.bin/groff/tmac
811207066Srnoland.endif
812145132Sanholt.endif
813145132Sanholt
814182080Srnoland.if ${BOOTSTRAPPING} < 502102
815145132Sanholt_lex=		usr.bin/lex
816145132Sanholt.endif
817145132Sanholt
818145132Sanholt.if ${BOOTSTRAPPING} < 450005 || \
819145132Sanholt    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
820145132Sanholt_uudecode=	usr.bin/uudecode
821207066Srnoland.endif
822145132Sanholt
823145132Sanholt.if ${BOOTSTRAPPING} < 430002 || \
824145132Sanholt    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
825145132Sanholt_xargs=		usr.bin/xargs
826145132Sanholt.endif
827145132Sanholt
828145132Sanholt.if ${BOOTSTRAPPING} < 430002 || \
829145132Sanholt    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
830145132Sanholt_yacc=		usr.bin/yacc
831145132Sanholt.endif
832145132Sanholt
833145132Sanholt.if !defined(NO_RESCUE) && \
834145132Sanholt    ${BOOTSTRAPPING} < 502128
835145132Sanholt_crunchgen=	usr.sbin/crunch/crunchgen
836145132Sanholt.endif
837145132Sanholt
838157617Sanholt.if ${BOOTSTRAPPING} < 502128
839182080Srnoland_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
840182080Srnoland.endif
841157617Sanholt
842145132Sanholt.if ${BOOTSTRAPPING} < 500019
843145132Sanholt_kbdcontrol=	usr.sbin/kbdcontrol
844145132Sanholt.endif
845145132Sanholt
846145132Sanholtbootstrap-tools:
847145132Sanholt.for _tool in \
848145132Sanholt    ${_strfile} \
849145132Sanholt    ${_gperf} \
850145132Sanholt    ${_groff} \
851145132Sanholt    gnu/usr.bin/texinfo \
852145132Sanholt    usr.bin/colldef \
853145132Sanholt    ${_lex} \
854145132Sanholt    usr.bin/makewhatis \
855145132Sanholt    usr.bin/rpcgen \
856145132Sanholt    ${_uudecode} \
857145132Sanholt    ${_xargs} \
858145132Sanholt    usr.bin/xinstall \
859145132Sanholt    ${_yacc} \
860207066Srnoland    usr.sbin/config \
861145132Sanholt    ${_crunchgen} \
862145132Sanholt    ${_gensnmptree} \
863145132Sanholt    ${_kbdcontrol}
864145132Sanholt	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
865145132Sanholt		cd ${.CURDIR}/${_tool}; \
866145132Sanholt		${MAKE} DIRPRFX=${_tool}/ obj; \
867145132Sanholt		${MAKE} DIRPRFX=${_tool}/ depend; \
868207066Srnoland		${MAKE} DIRPRFX=${_tool}/ all; \
869145132Sanholt		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
870145132Sanholt.endfor
871145132Sanholt
872145132Sanholt#
873145132Sanholt# build-tools: Build special purpose build tools
874145132Sanholt#
875145132Sanholt.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
876145132Sanholt_aicasm= sys/modules/aic7xxx/aicasm
877145132Sanholt.endif
878145132Sanholt
879145132Sanholt.if !defined(NOSHARE)
880145132Sanholt_share=	share/syscons/scrnmaps
881145132Sanholt.endif
882145132Sanholt
883145132Sanholt.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
884145132Sanholt_kerberos5_tools= kerberos5/tools
885145132Sanholt.endif
886145132Sanholt
887145132Sanholt.if !defined(NO_RESCUE)
888145132Sanholt_rescue= rescue/rescue
889145132Sanholt.endif
890145132Sanholt
891182080Srnolandbuild-tools:
892145132Sanholt.for _tool in \
893145132Sanholt    bin/csh \
894182080Srnoland    bin/sh \
895145132Sanholt    ${_rescue} \
896145132Sanholt    lib/libncurses \
897182080Srnoland    ${_share} \
898145132Sanholt    ${_aicasm} \
899145132Sanholt    usr.bin/awk \
900145132Sanholt    lib/libmagic \
901145132Sanholt    usr.sbin/sysinstall
902145132Sanholt	${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
903182080Srnoland		cd ${.CURDIR}/${_tool}; \
904145132Sanholt		${MAKE} DIRPRFX=${_tool}/ obj; \
905145132Sanholt		${MAKE} DIRPRFX=${_tool}/ build-tools
906145132Sanholt.endfor
907145132Sanholt.for _tool in \
908207066Srnoland    gnu/usr.bin/cc/cc_tools \
909207066Srnoland    ${_kerberos5_tools}
910145132Sanholt	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
911207066Srnoland		cd ${.CURDIR}/${_tool}; \
912145132Sanholt		${MAKE} DIRPRFX=${_tool}/ obj; \
913145132Sanholt		${MAKE} DIRPRFX=${_tool}/ depend; \
914145132Sanholt		${MAKE} DIRPRFX=${_tool}/ all
915145132Sanholt.endfor
916145132Sanholt
917207066Srnoland#
918145132Sanholt# cross-tools: Build cross-building tools
919145132Sanholt#
920145132Sanholt.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
921145132Sanholt    ${BOOTSTRAPPING} < 500037
922145132Sanholt_elf2aout=	usr.bin/elf2aout
923145132Sanholt.endif
924145132Sanholt
925145132Sanholt.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
926145132Sanholt_btxld=		usr.sbin/btxld
927145132Sanholt.endif
928145132Sanholt
929145132Sanholt.if (!defined(NO_RESCUE) || \
930145132Sanholt    defined(RELEASEDIR)) && \
931145132Sanholt    (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
932145132Sanholt_crunchide=	usr.sbin/crunch/crunchide
933182080Srnoland.endif
934145132Sanholt
935182080Srnoland.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
936145132Sanholt_elf2exe=	usr.sbin/elf2exe
937182080Srnoland.endif
938145132Sanholt
939182080Srnoland.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
940145132Sanholt    defined(RELEASEDIR)
941182080Srnoland_kgzip=		usr.sbin/kgzip
942145132Sanholt.endif
943145132Sanholt
944145132Sanholtcross-tools:
945145132Sanholt.for _tool in \
946182080Srnoland    gnu/usr.bin/binutils \
947145132Sanholt    gnu/usr.bin/cc \
948145132Sanholt    ${_elf2aout} \
949182080Srnoland    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
950145132Sanholt    ${_btxld} \
951145132Sanholt    ${_crunchide} \
952182080Srnoland    ${_elf2exe} \
953145132Sanholt    ${_kgzip}
954145132Sanholt	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
955145132Sanholt		cd ${.CURDIR}/${_tool}; \
956182080Srnoland		${MAKE} DIRPRFX=${_tool}/ obj; \
957145132Sanholt		${MAKE} DIRPRFX=${_tool}/ depend; \
958182080Srnoland		${MAKE} DIRPRFX=${_tool}/ all; \
959182080Srnoland		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
960145132Sanholt.endfor
961145132Sanholt
962145132Sanholt#
963145132Sanholt# hierarchy - ensure that all the needed directories are present
964182080Srnoland#
965145132Sanholthierarchy:
966145132Sanholt	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
967182080Srnoland
968145132Sanholt#
969145132Sanholt# libraries - build all libraries, and install them under ${DESTDIR}.
970145132Sanholt#
971145132Sanholt# The list of libraries with dependents (${_prebuild_libs}) and their
972145132Sanholt# interdependencies (__L) are built automatically by the
973145132Sanholt# ${.CURDIR}/tools/make_libdeps.sh script.
974145132Sanholt#
975145132Sanholtlibraries:
976145132Sanholt	cd ${.CURDIR}; \
977145132Sanholt	    ${MAKE} -f Makefile.inc1 _startup_libs; \
978145132Sanholt	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
979145132Sanholt	    ${MAKE} -f Makefile.inc1 _generic_libs;
980145132Sanholt
981145132Sanholt# These dependencies are not automatically generated:
982182080Srnoland#
983182080Srnoland# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
984145132Sanholt# shared libraries for ELF.
985145132Sanholt#
986145132Sanholt_startup_libs=	gnu/lib/csu gnu/lib/libgcc
987145132Sanholt.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
988145132Sanholt_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
989182080Srnoland.else
990145132Sanholt_startup_libs+=	lib/csu/${MACHINE_ARCH}
991145132Sanholt.endif
992145132Sanholt
993145132Sanholt_prebuild_libs=
994145132Sanholt
995145132Sanholt_generic_libs=	gnu/lib
996145132Sanholt
997145132Sanholt.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
998145132Sanholt_prebuild_libs+=	kerberos5/lib/libasn1
999182080Srnoland_prebuild_libs+=	kerberos5/lib/libgssapi
1000182080Srnoland_prebuild_libs+=	kerberos5/lib/libkrb5
1001182080Srnoland_prebuild_libs+=	kerberos5/lib/libroken
1002145132Sanholt_generic_libs+=	kerberos5/lib
1003182080Srnoland.endif
1004145132Sanholt
1005145132Sanholt_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
1006145132Sanholt		lib/libkvm lib/libmd \
1007145132Sanholt		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
1008145132Sanholt		lib/libradius \
1009182080Srnoland		lib/libsbuf lib/libtacplus lib/libutil \
1010145132Sanholt		lib/libz lib/msun
1011182080Srnoland
1012145132Sanholtlib/libopie__L lib/libtacplus__L: lib/libmd__L
1013145132Sanholt
1014145132Sanholt.if !defined(NO_BIND)
1015182080Srnoland.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
1016145132Sanholt_prebuild_libs+= lib/libc_r
1017145132Sanholt.else
1018182080Srnoland_prebuild_libs+= lib/libpthread
1019145132Sanholt.endif
1020145132Sanholt.endif
1021145132Sanholt
1022145132Sanholt_generic_libs+=	lib
1023145132Sanholt
1024145132Sanholt.if !defined(NOCRYPT)
1025182080Srnoland.if !defined(NO_OPENSSL)
1026145132Sanholt_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
1027182080Srnolandlib/libradius__L: secure/lib/libssl__L
1028182080Srnolandsecure/lib/libssl__L: secure/lib/libcrypto__L
1029145132Sanholt.if !defined(NO_OPENSSH)
1030145132Sanholt_prebuild_libs+=	secure/lib/libssh
1031182080Srnolandsecure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1032145132Sanholt.if !defined(NO_KERBEROS)
1033145132Sanholtsecure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
1034145132Sanholt    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1035182080Srnoland    kerberos5/lib/libroken__L
1036145132Sanholt.endif
1037182080Srnoland.endif
1038182080Srnoland.endif
1039145132Sanholt_generic_libs+=	secure/lib
1040145132Sanholt.endif
1041145132Sanholt
1042145132Sanholt.if defined(NOCRYPT) || defined(NO_OPENSSL)
1043182080Srnolandlib/libradius__L: lib/libmd__L
1044145132Sanholt.endif
1045182080Srnoland
1046182080Srnoland.if !defined(NO_NIS)
1047145132Sanholt_prebuild_libs+=	lib/libypclnt
1048145132Sanholt.endif
1049182080Srnoland
1050145132Sanholt_generic_libs+=	usr.bin/lex/lib
1051182080Srnoland
1052182080Srnoland.if ${MACHINE_ARCH} == "i386"
1053145132Sanholt_generic_libs+=	usr.sbin/pcvt/keycap
1054145132Sanholt.endif
1055145132Sanholt
1056145132Sanholt.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1057145132Sanholt${_lib}__L: .PHONY
1058182080Srnoland.if exists(${.CURDIR}/${_lib})
1059157617Sanholt	${_+_}@${ECHODIR} "===> ${_lib} (depend,all,install)"; \
1060182080Srnoland		cd ${.CURDIR}/${_lib}; \
1061145132Sanholt		${MAKE} DIRPRFX=${_lib}/ depend; \
1062145132Sanholt		${MAKE} DIRPRFX=${_lib}/ all; \
1063145132Sanholt		${MAKE} DIRPRFX=${_lib}/ install
1064145132Sanholt.endif
1065145132Sanholt.endfor
1066145132Sanholt
1067145132Sanholt# libpam is special: we need to build static PAM modules before
1068145132Sanholt# static PAM library, and dynamic PAM library before dynamic PAM
1069145132Sanholt# modules.
1070145132Sanholtlib/libpam__L: .PHONY
1071145132Sanholt	${_+_}@${ECHODIR} "===> lib/libpam (depend,all,install)"; \
1072182080Srnoland		cd ${.CURDIR}/lib/libpam; \
1073145132Sanholt		${MAKE} DIRPRFX=lib/libpam/ depend; \
1074145132Sanholt		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1075182080Srnoland		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1076145132Sanholt
1077145132Sanholt_startup_libs: ${_startup_libs:S/$/__L/}
1078145132Sanholt_prebuild_libs: ${_prebuild_libs:S/$/__L/}
1079145132Sanholt_generic_libs: ${_generic_libs:S/$/__L/}
1080145132Sanholt
1081145132Sanholt.for __target in all clean cleandepend cleandir depend includes obj
1082145132Sanholt.for entry in ${SUBDIR}
1083145132Sanholt${entry}.${__target}__D: .PHONY
1084145132Sanholt	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1085182080Srnoland		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1086145132Sanholt		edir=${entry}.${MACHINE_ARCH}; \
1087152909Sanholt		cd ${.CURDIR}/$${edir}; \
1088182080Srnoland	else \
1089182080Srnoland		${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1090182080Srnoland		edir=${entry}; \
1091182080Srnoland		cd ${.CURDIR}/$${edir}; \
1092182080Srnoland	fi; \
1093152909Sanholt	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1094152909Sanholt.endfor
1095152909Sanholtpar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1096.endfor
1097
1098.include <bsd.subdir.mk>
1099