Makefile.inc1 revision 88450
1163953Srrs#
2163953Srrs# $FreeBSD: head/Makefile.inc1 88450 2001-12-23 22:49:06Z jedgar $
3163953Srrs#
4163953Srrs# Make command line options:
5163953Srrs#	-DMAKE_KERBEROS4 to build KerberosIV
6163953Srrs#	-DMAKE_KERBEROS5 to build Kerberos5
7163953Srrs#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8163953Srrs#	-DNOCLEAN do not clean at all
9163953Srrs#	-DNOCRYPT will prevent building of crypt versions
10163953Srrs#	-DNOPROFILE do not build profiled libraries
11163953Srrs#	-DNOSECURE do not go into secure subdir
12163953Srrs#	-DNOGAMES do not go into games subdir
13163953Srrs#	-DNOSHARE do not go into share subdir
14163953Srrs#	-DNOINFO do not make or install info files
15163953Srrs#	-DNOLIBC_R do not build libc_r.
16163953Srrs#	-DNO_FORTRAN do not build g77 and related libraries.
17163953Srrs#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
18163953Srrs#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
19163953Srrs#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
20163953Srrs#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
21163953Srrs#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
22163953Srrs#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
23163953Srrs#	TARGET_ARCH="arch" to crossbuild world to a different arch
24163953Srrs
25163953Srrs#
26163953Srrs# The intended user-driven targets are:
27163953Srrs# buildworld  - rebuild *everything*, including glue to help do upgrades
28163953Srrs# installworld- install everything built by "buildworld"
29163953Srrs# update      - convenient way to update your source tree (eg: sup/cvs)
30163953Srrs# most        - build user commands, no libraries or include files
31163953Srrs# installmost - install user commands, no libraries or include files
32163953Srrs#
33163953Srrs# Standard targets (not defined here) are documented in the makefiles in
34163957Srrs# /usr/share/mk.  These include:
35163953Srrs#		obj depend all install clean cleandepend cleanobj
36163953Srrs
37163957Srrs# Put initial settings here.
38163953SrrsSUBDIR=
39163953Srrs
40163953Srrs# We must do share/info early so that installation of info `dir'
41163953Srrs# entries works correctly.  Do it first since it is less likely to
42163953Srrs# grow dependencies on include and lib than vice versa.
43163953Srrs.if exists(${.CURDIR}/share/info)
44163953SrrsSUBDIR+= share/info
45163953Srrs.endif
46163953Srrs
47163953Srrs# We must do include and lib early so that the perl *.ph generation
48163953Srrs# works correctly as it uses the header files installed by this.
49163953Srrs.if exists(${.CURDIR}/include)
50163953SrrsSUBDIR+= include
51163953Srrs.endif
52163953Srrs.if exists(${.CURDIR}/lib)
53163953SrrsSUBDIR+= lib
54163953Srrs.endif
55163953Srrs
56163953Srrs.if exists(${.CURDIR}/bin)
57163953SrrsSUBDIR+= bin
58163953Srrs.endif
59163953Srrs.if exists(${.CURDIR}/games) && !defined(NOGAMES)
60163953SrrsSUBDIR+= games
61163953Srrs.endif
62163953Srrs.if exists(${.CURDIR}/gnu)
63163953SrrsSUBDIR+= gnu
64163953Srrs.endif
65163953Srrs.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
66163953Srrs    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
67163953SrrsSUBDIR+= kerberosIV
68163953Srrs.endif
69163953Srrs.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
70163953Srrs    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
71163953SrrsSUBDIR+= kerberos5
72163953Srrs.endif
73163953Srrs.if exists(${.CURDIR}/libexec)
74163953SrrsSUBDIR+= libexec
75163953Srrs.endif
76163953Srrs.if exists(${.CURDIR}/sbin)
77163953SrrsSUBDIR+= sbin
78163953Srrs.endif
79163953Srrs.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
80163953SrrsSUBDIR+= secure
81163953Srrs.endif
82163953Srrs.if exists(${.CURDIR}/share) && !defined(NOSHARE)
83163953SrrsSUBDIR+= share
84163953Srrs.endif
85163953Srrs.if exists(${.CURDIR}/sys)
86163953SrrsSUBDIR+= sys
87163953Srrs.endif
88163953Srrs.if exists(${.CURDIR}/usr.bin)
89163953SrrsSUBDIR+= usr.bin
90163953Srrs.endif
91163953Srrs.if exists(${.CURDIR}/usr.sbin)
92163953SrrsSUBDIR+= usr.sbin
93163953Srrs.endif
94163953Srrs
95163953Srrs# etc must be last for "distribute" to work
96163953Srrs.if exists(${.CURDIR}/etc)
97163953SrrsSUBDIR+= etc
98163953Srrs.endif
99163953Srrs
100163953Srrs# These are last, since it is nice to at least get the base system
101163953Srrs# rebuilt before you do them.
102163953Srrs.if defined(LOCAL_DIRS)
103163953Srrs.for _DIR in ${LOCAL_DIRS}
104163953Srrs.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
105163953SrrsSUBDIR+= ${_DIR}
106163953Srrs.endif
107163953Srrs.endfor
108163953Srrs.endif
109163953Srrs
110163953Srrs.if defined(NOCLEANDIR)
111163953SrrsCLEANDIR=	clean cleandepend
112163953Srrs.else
113163953SrrsCLEANDIR=	cleandir
114163953Srrs.endif
115163953Srrs
116163953SrrsCVS?=		cvs
117163953SrrsSUP?=		/usr/local/bin/cvsup
118163953SrrsSUPFLAGS?=	-g -L 2 -P -
119163953Srrs.if defined(SUPHOST)
120163953SrrsSUPFLAGS+=	-h ${SUPHOST}
121163953Srrs.endif
122163953Srrs
123163953SrrsMAKEOBJDIRPREFIX?=	/usr/obj
124163953SrrsTARGET_ARCH?=	${MACHINE_ARCH}
125163953SrrsTARGET?=	${MACHINE}
126163953Srrs.if make(buildworld)
127163953SrrsBUILD_ARCH!=	sysctl -n hw.machine_arch
128163953Srrs.if ${MACHINE_ARCH} != ${BUILD_ARCH}
129163953Srrs.error To cross-build, set TARGET_ARCH.
130163953Srrs.endif
131163953Srrs.endif
132163953Srrs.if ${MACHINE_ARCH} == ${TARGET_ARCH}
133163953SrrsOBJTREE=	${MAKEOBJDIRPREFIX}
134163953Srrs.else
135163953SrrsOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET_ARCH}
136163953Srrs.endif
137163953SrrsWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
138163953Srrs# /usr/games added for fortune which depend on strfile
139163953SrrsSTRICTTMPPATH=	${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
140163953SrrsTMPPATH=	${STRICTTMPPATH}:${PATH}
141163953SrrsOBJFORMAT_PATH?=	/usr/libexec
142163953Srrs
143163953SrrsINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
144163953Srrs
145163953Srrs#
146163953Srrs# Building a world goes through the following stages
147163953Srrs#
148163953Srrs# 1. bootstrap-tool stage [BMAKE]
149163953Srrs#	This stage is responsible for creating programs that
150163953Srrs#	are needed for backward compatibility reasons. They
151163953Srrs#	are not built as cross-tools.
152163953Srrs# 2. build-tool stage [TMAKE]
153163953Srrs#	This stage is responsible for creating the object
154163953Srrs#	tree and building any tools that are needed during
155163953Srrs#	the build process.
156163953Srrs# 3. cross-tool stage [XMAKE]
157163953Srrs#	This stage is responsible for creating any tools that
158163953Srrs#	are needed for cross-builds. A cross-compiler is one
159163953Srrs#	of them.
160163953Srrs# 4. world stage [WMAKE]
161163953Srrs#	This stage actually builds the world.
162163953Srrs# 5. install stage (optional) [IMAKE]
163163953Srrs#	This stage installs a previously built world.
164163953Srrs#
165163953Srrs
166163953Srrs# Common environment for world related stages
167163953SrrsCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
168163953Srrs		MACHINE_ARCH=${TARGET_ARCH} \
169163953Srrs		MACHINE=${TARGET} \
170163953Srrs		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
171163953Srrs		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
172163953Srrs		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
173163953Srrs		CFLAGS="-nostdinc ${CFLAGS}" \
174163953Srrs		CXXINCLUDES="-nostdinc++ ${CXXINCLUDES}" \
175163953Srrs		PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.0 \
176163953Srrs		GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
177163953Srrs		GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
178163953Srrs		GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
179163953Srrs
180163953Srrs# bootstrap-tool stage
181163953SrrsBMAKEENV=	MAKEOBJDIRPREFIX=${WORLDTMP} \
182163953Srrs		DESTDIR= \
183163953Srrs		INSTALL="sh ${.CURDIR}/tools/install.sh"
184163953SrrsBMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
185163953Srrs		-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
186163953Srrs		-DNO_WERROR
187163953Srrs
188163953Srrs# build-tool stage
189163953SrrsTMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
190163953Srrs		DESTDIR= \
191163953Srrs		INSTALL="sh ${.CURDIR}/tools/install.sh"
192163953SrrsTMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1
193163953Srrs
194163953Srrs# cross-tool stage
195163953SrrsXMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
196163953Srrs
197163953Srrs# world stage
198163953SrrsWMAKEENV=	${CROSSENV} \
199163953Srrs		DESTDIR=${WORLDTMP} \
200163953Srrs		INSTALL="sh ${.CURDIR}/tools/install.sh" \
201163953Srrs		PATH=${TMPPATH}
202163953SrrsWMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
203163953Srrs
204163953Srrs# install stage
205163953SrrsIMAKEENV=	${CROSSENV} \
206163953Srrs		PATH=${STRICTTMPPATH}:${INSTALLTMP}
207163953SrrsIMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
208163953Srrs
209163953Srrs# kernel stage
210163953SrrsKMAKEENV=	${WMAKEENV} \
211163953Srrs		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
212163953Srrs
213163953SrrsUSRDIRS=	usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
214163953Srrs		usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc \
215163953Srrs		usr/share/dict \
216163953Srrs		usr/share/groff_font/devX100 \
217163953Srrs		usr/share/groff_font/devX100-12 \
218163953Srrs		usr/share/groff_font/devX75 \
219163953Srrs		usr/share/groff_font/devX75-12 \
220163953Srrs		usr/share/groff_font/devascii \
221163953Srrs		usr/share/groff_font/devcp1047 \
222163953Srrs		usr/share/groff_font/devdvi \
223163953Srrs		usr/share/groff_font/devhtml \
224163953Srrs		usr/share/groff_font/devkoi8-r \
225163953Srrs		usr/share/groff_font/devlatin1 \
226163953Srrs		usr/share/groff_font/devlbp \
227163953Srrs		usr/share/groff_font/devlj4 \
228163953Srrs		usr/share/groff_font/devps \
229163953Srrs		usr/share/groff_font/devutf8 \
230163953Srrs		usr/share/tmac/mdoc usr/share/tmac/mm
231163953Srrs
232163953SrrsINCDIRS=	arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
233163953Srrs		security
234163953Srrs
235163953Srrs#
236163953Srrs# buildworld
237163953Srrs#
238163953Srrs# Attempt to rebuild the entire system, with reasonable chance of
239163953Srrs# success, regardless of how old your existing system is.
240163953Srrs#
241163953Srrsbuildworld:
242163953Srrs	@echo
243163953Srrs	@echo "--------------------------------------------------------------"
244163953Srrs	@echo ">>> Rebuilding the temporary build tree"
245163953Srrs	@echo "--------------------------------------------------------------"
246163953Srrs.if !defined(NOCLEAN)
247163953Srrs	rm -rf ${WORLDTMP}
248163953Srrs.endif
249163953Srrs.for _dir in ${USRDIRS}
250163953Srrs	mkdir -p ${WORLDTMP}/${_dir}
251163953Srrs.endfor
252163953Srrs.for _dir in ${INCDIRS}
253163953Srrs	mkdir -p ${WORLDTMP}/usr/include/${_dir}
254163953Srrs.endfor
255163953Srrs	ln -sf ${.CURDIR}/sys ${WORLDTMP}
256163953Srrs	@echo
257163953Srrs	@echo "--------------------------------------------------------------"
258163953Srrs	@echo ">>> stage 1: bootstrap tools"
259163953Srrs	@echo "--------------------------------------------------------------"
260163953Srrs	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
261163953Srrs.if !defined(NOCLEAN)
262163953Srrs	@echo
263163953Srrs	@echo "--------------------------------------------------------------"
264163953Srrs	@echo ">>> stage 2: cleaning up the object tree"
265163953Srrs	@echo "--------------------------------------------------------------"
266163953Srrs	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
267163953Srrs.endif
268163953Srrs	@echo
269163953Srrs	@echo "--------------------------------------------------------------"
270163953Srrs	@echo ">>> stage 2: rebuilding the object tree"
271163953Srrs	@echo "--------------------------------------------------------------"
272163953Srrs	cd ${.CURDIR}; ${WMAKE} par-obj
273163953Srrs	@echo
274163953Srrs	@echo "--------------------------------------------------------------"
275163953Srrs	@echo ">>> stage 2: build tools"
276163953Srrs	@echo "--------------------------------------------------------------"
277163953Srrs	cd ${.CURDIR}; ${TMAKE} build-tools
278163953Srrs	@echo
279163953Srrs	@echo "--------------------------------------------------------------"
280163953Srrs	@echo ">>> stage 3: cross tools"
281163953Srrs	@echo "--------------------------------------------------------------"
282163953Srrs	cd ${.CURDIR}; ${XMAKE} cross-tools
283163953Srrs	@echo
284163953Srrs	@echo "--------------------------------------------------------------"
285163953Srrs	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
286163953Srrs	@echo "--------------------------------------------------------------"
287163953Srrs	cd ${.CURDIR}; ${WMAKE} SHARED=copies includes
288163953Srrs	@echo
289163953Srrs	@echo "--------------------------------------------------------------"
290163953Srrs	@echo ">>> stage 4: building libraries"
291163953Srrs	@echo "--------------------------------------------------------------"
292163953Srrs	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
293163953Srrs	@echo
294163953Srrs	@echo "--------------------------------------------------------------"
295163953Srrs	@echo ">>> stage 4: make dependencies"
296163953Srrs	@echo "--------------------------------------------------------------"
297163953Srrs	cd ${.CURDIR}; ${WMAKE} par-depend
298163953Srrs	@echo
299163953Srrs	@echo "--------------------------------------------------------------"
300163953Srrs	@echo ">>> stage 4: building everything.."
301163953Srrs	@echo "--------------------------------------------------------------"
302163953Srrs	cd ${.CURDIR}; ${WMAKE} all
303163953Srrs
304163953Srrseverything:
305163953Srrs	@echo "--------------------------------------------------------------"
306163953Srrs	@echo ">>> Building everything.."
307163953Srrs	@echo "--------------------------------------------------------------"
308163953Srrs	cd ${.CURDIR}; ${WMAKE} all
309163953Srrs
310163953Srrs#
311163953Srrs# installworld
312163953Srrs#
313163953Srrs# Installs everything compiled by a 'buildworld'.
314163953Srrs#
315163953Srrsinstallworld:
316163953Srrs	mkdir -p ${INSTALLTMP}
317163953Srrs	for prog in [ awk cat chflags chmod chown date echo egrep find grep \
318163953Srrs	    ln make makewhatis mkdir mtree mv perl rm sed sh sysctl \
319163953Srrs	    test true uname wc zic; do \
320163953Srrs		cp `which $$prog` ${INSTALLTMP}; \
321163953Srrs	done
322163953Srrs	cd ${.CURDIR}; ${IMAKE} reinstall
323163953Srrs	rm -rf ${INSTALLTMP}
324163953Srrs
325163953Srrs#
326163953Srrs# reinstall
327163953Srrs#
328163953Srrs# If you have a build server, you can NFS mount the source and obj directories
329163953Srrs# and do a 'make reinstall' on the *client* to install new binaries from the
330163953Srrs# most recent server build.
331163953Srrs#
332163953Srrsreinstall:
333163953Srrs	@echo "--------------------------------------------------------------"
334163953Srrs	@echo ">>> Making hierarchy"
335163953Srrs	@echo "--------------------------------------------------------------"
336163953Srrs	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
337163953Srrs	@echo
338163953Srrs	@echo "--------------------------------------------------------------"
339163953Srrs	@echo ">>> Installing everything.."
340163953Srrs	@echo "--------------------------------------------------------------"
341163953Srrs	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
342163953Srrs.if !defined(NOMAN)
343163953Srrs	@echo
344163953Srrs	@echo "--------------------------------------------------------------"
345163953Srrs	@echo ">>> Rebuilding man page indices"
346163953Srrs	@echo "--------------------------------------------------------------"
347163953Srrs	cd ${.CURDIR}/share/man; ${MAKE} makedb
348163953Srrs.endif
349163953Srrs
350163953Srrs#
351163953Srrs# distribworld
352163953Srrs#
353163953Srrs# Front-end to distribute to make sure the search path contains
354163953Srrs# the object directory. Needed for miniperl.
355163953Srrs#
356163953Srrsdistribworld:
357163953Srrs	cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
358163953Srrs
359163953Srrs#
360163953Srrs# buildkernel and installkernel
361163953Srrs#
362163953Srrs# Which kernels to build and/or install is specified by setting
363163953Srrs# KERNCONF. If not defined a GENERIC kernel is built/installed.
364163953Srrs# Only the existing (depending TARGET) config files are used
365163953Srrs# for building kernels and only the first of these is designated
366163953Srrs# as the one being installed.
367163953Srrs#
368163953Srrs# Note that we have to use TARGET instead of TARGET_ARCH when
369163953Srrs# we're in kernel-land. Since only TARGET_ARCH is (expected) to
370163953Srrs# be set to cross-build, we have to make sure TARGET is set
371163953Srrs# properly.
372163953Srrs
373163953Srrs.if !defined(KERNCONF) && defined(KERNEL)
374163953SrrsKERNCONF=	${KERNEL}
375163953SrrsKERNWARN=	yes
376163953Srrs.else
377163953SrrsKERNCONF?=	GENERIC
378163953Srrs.endif
379163953SrrsINSTKERNNAME?=	kernel
380163953Srrs
381163953Srrs# The only exotic TARGET_ARCH/TARGET combination valid at this
382163953Srrs# time is i386/pc98. In all other cases set TARGET equal to
383163953Srrs# TARGET_ARCH.
384163953Srrs.if ${TARGET_ARCH} != "i386" || ${TARGET} != "pc98"
385163953SrrsTARGET=		${TARGET_ARCH}
386163953Srrs.endif
387163953Srrs
388163953SrrsKRNLSRCDIR=	${.CURDIR}/sys
389163953SrrsKRNLCONFDIR=	${KRNLSRCDIR}/${TARGET}/conf
390163953SrrsKRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
391163953SrrsKERNCONFDIR?=	${KRNLCONFDIR}
392163953Srrs
393163953SrrsBUILDKERNELS=
394163953SrrsINSTALLKERNEL=
395163953Srrs.for _kernel in ${KERNCONF}
396163953Srrs.if exists(${KERNCONFDIR}/${_kernel})
397163953SrrsBUILDKERNELS+=	${_kernel}
398163953Srrs.if empty(INSTALLKERNEL)
399163953SrrsINSTALLKERNEL= ${_kernel}
400163953Srrs.endif
401163953Srrs.endif
402163953Srrs.endfor
403163953Srrs
404163953Srrs#
405163953Srrs# buildkernel
406163953Srrs#
407163953Srrs# Builds all kernels defined by BUILDKERNELS.
408163953Srrs#
409163953Srrsbuildkernel:
410163953Srrs.if empty(BUILDKERNELS)
411163953Srrs	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
412163953Srrs	@false
413163953Srrs.endif
414163953Srrs.if defined(KERNWARN)
415163953Srrs	@echo "--------------------------------------------------------------"
416163953Srrs	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
417163953Srrs	@echo "--------------------------------------------------------------"
418163953Srrs	@sleep 3
419163953Srrs.endif
420163953Srrs	@echo
421163953Srrs.for _kernel in ${BUILDKERNELS}
422163953Srrs	@echo "--------------------------------------------------------------"
423163953Srrs	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
424163953Srrs	@echo "--------------------------------------------------------------"
425163953Srrs	@echo "===> ${_kernel}"
426163953Srrs	mkdir -p ${KRNLOBJDIR}
427163953Srrs.if !defined(NO_KERNELCONFIG)
428163953Srrs	cd ${KRNLCONFDIR}; \
429163953Srrs		PATH=${TMPPATH} \
430163953Srrs		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
431163953Srrs			${KERNCONFDIR}/${_kernel}
432163953Srrs.endif
433163953Srrs.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
434163953Srrs.if defined(MODULES_WITH_WORLD) || defined(NO_MODULES) || !exists(${KRNLSRCDIR}/modules)
435163953Srrs	cd ${KRNLOBJDIR}/${_kernel}; \
436163953Srrs	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean
437163953Srrs.else
438163953Srrs	cd ${KRNLOBJDIR}/${_kernel}; \
439163953Srrs	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean cleandir
440163953Srrs.endif
441163953Srrs.endif
442163953Srrs	cd ${KRNLOBJDIR}/${_kernel}; \
443163953Srrs		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
444163953Srrs		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
445163953Srrs.if !defined(NO_KERNELDEPEND)
446163953Srrs	cd ${KRNLOBJDIR}/${_kernel}; \
447163953Srrs	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
448163953Srrs.endif
449163953Srrs	cd ${KRNLOBJDIR}/${_kernel}; \
450163953Srrs	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
451163953Srrs	@echo "--------------------------------------------------------------"
452163953Srrs	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
453163953Srrs	@echo "--------------------------------------------------------------"
454163953Srrs.endfor
455163953Srrs
456163953Srrs#
457163953Srrs# installkernel
458163953Srrs#
459163953Srrs# Install the kernel defined by INSTALLKERNEL
460163953Srrs#
461163953Srrsinstallkernel:
462163953Srrs	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
463163953Srrs	    ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} install
464163953Srrsreinstallkernel:
465163953Srrs	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
466163953Srrs	    ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
467163953Srrs
468163953Srrs#
469163953Srrs# kernel
470163953Srrs#
471163953Srrs# Short hand for `make buildkernel installkernel'
472163953Srrs#
473163953Srrskernel: buildkernel installkernel
474163953Srrs
475163953Srrs#
476163953Srrs# update
477163953Srrs#
478163953Srrs# Update the source tree, by running sup and/or running cvs to update to the
479163953Srrs# latest copy.
480163953Srrs#
481163953Srrsupdate:
482163953Srrs.if defined(SUP_UPDATE)
483163953Srrs	@echo "--------------------------------------------------------------"
484163953Srrs	@echo ">>> Running ${SUP}"
485163953Srrs	@echo "--------------------------------------------------------------"
486163953Srrs.if defined(SUPFILE)
487163953Srrs	@${SUP} ${SUPFLAGS} ${SUPFILE}
488163953Srrs.endif
489163953Srrs.if defined(SUPFILE1)
490163953Srrs	@${SUP} ${SUPFLAGS} ${SUPFILE1}
491163953Srrs.endif
492163953Srrs.if defined(SUPFILE2)
493163953Srrs	@${SUP} ${SUPFLAGS} ${SUPFILE2}
494163953Srrs.endif
495163953Srrs.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
496163953Srrs	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
497163953Srrs.endif
498163953Srrs.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
499163953Srrs	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
500163953Srrs.endif
501163953Srrs.endif
502163953Srrs.if defined(CVS_UPDATE)
503163953Srrs	@echo "--------------------------------------------------------------"
504163953Srrs	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
505163953Srrs	@echo "--------------------------------------------------------------"
506163953Srrs	cd ${.CURDIR}; ${CVS} -q update -A -P -d
507163953Srrs.endif
508163953Srrs
509163953Srrs#
510163953Srrs# most
511163953Srrs#
512163953Srrs# Build most of the user binaries on the existing system libs and includes.
513163953Srrs#
514163953Srrsmost:
515163953Srrs	@echo "--------------------------------------------------------------"
516163953Srrs	@echo ">>> Building programs only"
517163953Srrs	@echo "--------------------------------------------------------------"
518163953Srrs	cd ${.CURDIR}/bin;		${MAKE} all
519163953Srrs	cd ${.CURDIR}/sbin;		${MAKE} all
520163953Srrs	cd ${.CURDIR}/libexec;		${MAKE} all
521163953Srrs	cd ${.CURDIR}/usr.bin;		${MAKE} all
522163953Srrs	cd ${.CURDIR}/usr.sbin;		${MAKE} all
523163953Srrs	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
524163953Srrs	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
525163953Srrs	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
526163953Srrs
527163953Srrs#
528163953Srrs# installmost
529163953Srrs#
530163953Srrs# Install the binaries built by the 'most' target.  This does not include
531163953Srrs# libraries or include files.
532163953Srrs#
533163953Srrsinstallmost:
534163953Srrs	@echo "--------------------------------------------------------------"
535163953Srrs	@echo ">>> Installing programs only"
536163953Srrs	@echo "--------------------------------------------------------------"
537163953Srrs	cd ${.CURDIR}/bin;		${MAKE} install
538163953Srrs	cd ${.CURDIR}/sbin;		${MAKE} install
539163953Srrs	cd ${.CURDIR}/libexec;		${MAKE} install
540163953Srrs	cd ${.CURDIR}/usr.bin;		${MAKE} install
541163953Srrs	cd ${.CURDIR}/usr.sbin;		${MAKE} install
542163953Srrs	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
543163953Srrs	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
544163953Srrs	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
545163953Srrs
546163953Srrs#
547163953Srrs# ------------------------------------------------------------------------
548163953Srrs#
549163953Srrs# From here onwards are utility targets used by the 'make world' and
550163953Srrs# related targets.  If your 'world' breaks, you may like to try to fix
551163953Srrs# the problem and manually run the following targets to attempt to
552163953Srrs# complete the build.  Beware, this is *not* guaranteed to work, you
553163953Srrs# need to have a pretty good grip on the current state of the system
554163953Srrs# to attempt to manually finish it.  If in doubt, 'make world' again.
555163953Srrs#
556163953Srrs
557163953Srrs#
558163953Srrs# bootstrap-tools: Build tools needed for compatibility
559163953Srrs#
560163953Srrs.if exists(${.CURDIR}/games) && !defined(NOGAMES)
561163953Srrs_strfile=	games/fortune/strfile
562163953Srrs.endif
563163953Srrs
564163953Srrsbootstrap-tools:
565163953Srrs.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.bin/xinstall \
566163953Srrs    usr.sbin/config usr.sbin/kbdcontrol \
567163953Srrs    gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
568163953Srrs	cd ${.CURDIR}/${_tool}; \
569163953Srrs		${MAKE} obj; \
570163953Srrs		${MAKE} depend; \
571163953Srrs		${MAKE} all; \
572163953Srrs		${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
573163953Srrs.endfor
574163953Srrs
575163953Srrs#
576163953Srrs# build-tools: Build special purpose build tools
577163953Srrs#
578163953Srrs.if exists(${.CURDIR}/games) && !defined(NOGAMES)
579163953Srrs_games=	games/adventure games/hack games/phantasia
580163953Srrs.endif
581163953Srrs
582163953Srrs.if exists(${.CURDIR}/share) && !defined(NOSHARE)
583163953Srrs_share=	share/syscons/scrnmaps
584163953Srrs.endif
585163953Srrs
586163953Srrs.if !defined(NO_FORTRAN)
587163953Srrs_fortran= gnu/usr.bin/cc/f771
588163953Srrs.endif
589163953Srrs
590163953Srrs.if !defined(NOPERL)
591163953Srrs_perl=	gnu/usr.bin/perl/miniperl
592163953Srrs.endif
593163953Srrs
594163953Srrs.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
595163953Srrs    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
596163953Srrs_libroken4= kerberosIV/lib/libroken
597163953Srrs.endif
598163953Srrs
599163953Srrs.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
600163953Srrs    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
601163953Srrs_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
602163953Srrs.endif
603163953Srrs
604163953Srrsbuild-tools:
605163953Srrs.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
606163953Srrs    ${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
607163953Srrs    usr.bin/file usr.sbin/sysinstall
608163953Srrs	cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
609163953Srrs.endfor
610163953Srrs
611163953Srrs#
612163953Srrs# cross-tools: Build cross-building tools
613163953Srrs#
614163953Srrs.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
615163953Srrs_elf2exe=	usr.sbin/elf2exe
616163953Srrs.endif
617163953Srrs
618163953Srrs.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
619163953Srrs_btxld=	usr.sbin/btxld
620163953Srrs.endif
621163953Srrs
622163953Srrscross-tools:
623163953Srrs.for _tool in ${_btxld} ${_elf2exe} \
624163953Srrs    gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
625163953Srrs	cd ${.CURDIR}/${_tool}; \
626163953Srrs		${MAKE} obj; \
627163953Srrs		${MAKE} depend; \
628163953Srrs		${MAKE} all; \
629163953Srrs		${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
630163953Srrs.endfor
631163953Srrs
632163953Srrs#
633163953Srrs# hierarchy - ensure that all the needed directories are present
634163953Srrs#
635163953Srrshierarchy:
636163953Srrs	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
637163953Srrs
638163953Srrs#
639163953Srrs# includes - possibly generate and install the include files.
640163953Srrs#
641163953Srrsincludes:
642163953Srrs	cd ${.CURDIR}/include;			${MAKE} -B all install
643163953Srrs	cd ${.CURDIR}/gnu/include;		${MAKE} install
644163953Srrs	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
645163953Srrs	cd ${.CURDIR}/gnu/lib/libreadline/readline;	${MAKE} beforeinstall
646163953Srrs	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
647163953Srrs	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
648163953Srrs	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
649163953Srrs	cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;	${MAKE} beforeinstall
650163953Srrs.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
651163953Srrs.if exists(${.CURDIR}/secure/lib/libcrypto)
652163953Srrs	cd ${.CURDIR}/secure/lib/libcrypto;	${MAKE} beforeinstall
653163953Srrs.endif
654163953Srrs.if exists(${.CURDIR}/secure/lib/libssl)
655163953Srrs	cd ${.CURDIR}/secure/lib/libssl;	${MAKE} beforeinstall
656163953Srrs.endif
657163953Srrs.endif
658163953Srrs.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
659163953Srrs    defined(MAKE_KERBEROS4)
660163953Srrs	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
661163953Srrs	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
662163953Srrs	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
663163953Srrs	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
664163953Srrs	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
665163953Srrs	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
666163953Srrs.elif exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
667163953Srrs	cd ${.CURDIR}/secure/lib/libtelnet;	${MAKE} beforeinstall
668163953Srrs.else
669163953Srrs	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
670163953Srrs.endif
671163953Srrs.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
672163953Srrs    defined(MAKE_KERBEROS5)
673163953Srrs	cd ${.CURDIR}/kerberos5/lib/libasn1;		${MAKE} beforeinstall
674163953Srrs	cd ${.CURDIR}/kerberos5/lib/libhdb;		${MAKE} beforeinstall
675163953Srrs	cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;	${MAKE} beforeinstall
676163953Srrs	cd ${.CURDIR}/kerberos5/lib/libkadm5srv;	${MAKE} beforeinstall
677163953Srrs	cd ${.CURDIR}/kerberos5/lib/libkafs5;		${MAKE} beforeinstall
678163953Srrs	cd ${.CURDIR}/kerberos5/lib/libkrb5;		${MAKE} beforeinstall
679163953Srrs	cd ${.CURDIR}/kerberos5/lib/libsl;		${MAKE} beforeinstall
680163953Srrs.endif
681163953Srrs.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
682163953Srrs	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
683163953Srrs.endif
684163953Srrs	cd ${.CURDIR}/gnu/lib/csu;		${MAKE} beforeinstall
685163953Srrs	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
686163953Srrs	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
687163953Srrs	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
688163953Srrs	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
689163953Srrs	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
690163953Srrs	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
691163953Srrs	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
692163953Srrs	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
693163953Srrs	cd ${.CURDIR}/lib/libfetch;		${MAKE} beforeinstall
694163953Srrs	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
695163953Srrs	cd ${.CURDIR}/lib/libkvm;		${MAKE} beforeinstall
696163953Srrs	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
697163953Srrs	cd ${.CURDIR}/lib/libmp;		${MAKE} beforeinstall
698163953Srrs	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
699163953Srrs	cd ${.CURDIR}/lib/libncp;		${MAKE} beforeinstall
700163953Srrs	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
701163953Srrs	cd ${.CURDIR}/lib/libnetgraph;		${MAKE} beforeinstall
702163953Srrs	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
703163953Srrs	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
704163953Srrs	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
705163953Srrs	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
706163953Srrs	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
707163953Srrs	cd ${.CURDIR}/lib/libsbuf;		${MAKE} beforeinstall
708163953Srrs	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
709163953Srrs	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
710163953Srrs	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
711163953Srrs	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
712163953Srrs	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
713163953Srrs	cd ${.CURDIR}/lib/libwrap;		${MAKE} beforeinstall
714163953Srrs	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
715163953Srrs	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
716163953Srrs
717163953Srrs#
718163953Srrs# libraries - build all libraries, and install them under ${DESTDIR}.
719163953Srrs#
720163953Srrs# The following dependencies exist between the libraries:
721163953Srrs#
722163953Srrs# lib*: csu libgcc_pic
723163953Srrs# libatm: libmd
724163953Srrs# libcam: libsbuf
725163953Srrs# libcrypt: libmd
726163953Srrs# libdevstat: libkvm
727163953Srrs# libdialog: libncurses
728163953Srrs# libedit: libncurses
729163953Srrs# libg++: msun
730163953Srrs# libkrb: libcrypt
731163953Srrs# libopie: libmd
732163953Srrs# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
733163953Srrs#	  librpcsvc libtacplus libutil libz libssh
734163953Srrs# libradius: libmd
735163953Srrs# libreadline: libncurses
736163953Srrs# libstc++: msun
737163953Srrs# libtacplus: libmd
738163953Srrs#
739163953Srrs# Across directories this comes down to (rougly):
740163953Srrs#
741163953Srrs# gnu/lib: lib/msun lib/libncurses
742163953Srrs# kerberosIV/lib kerberos5/lib: lib/libcrypt
743163953Srrs# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
744163953Srrs#             secure/lib/libssh lib/libz
745163953Srrs# secure/lib: lib/libmd
746163953Srrs#
747163953Srrs.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
748163953Srrs_csu=	lib/csu/${MACHINE_ARCH}.pcc
749163953Srrs.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
750163953Srrs_csu=	lib/csu/i386-elf
751163953Srrs.else
752163953Srrs_csu=	lib/csu/${MACHINE_ARCH}
753163953Srrs.endif
754163953Srrs
755163953Srrs.if !defined(NOSECURE) && !defined(NOCRYPT)
756163953Srrs_secure_lib=	secure/lib
757163953Srrs.endif
758163953Srrs
759163953Srrs.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
760163953Srrs_kerberosIV_lib=	kerberosIV/lib
761163953Srrs.endif
762163953Srrs
763163953Srrs.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
764163953Srrs_kerberos5_lib=	kerberos5/lib
765163953Srrs.endif
766163953Srrs
767163953Srrs.if ${MACHINE_ARCH} == "i386"
768163953Srrs_libkeycap=	usr.sbin/pcvt/keycap
769163953Srrs.endif
770163953Srrs
771163953Srrs.if !defined(NOPERL)
772163953Srrs_libperl=	gnu/usr.bin/perl/libperl
773163953Srrs.endif
774163953Srrs
775163953Srrslibraries:
776163953Srrs.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
777163953Srrs    ${_secure_lib} ${_kerberosIV_lib} \
778163953Srrs    ${_kerberos5_lib} lib/libcom_err lib/libkvm lib/msun lib/libncurses \
779163953Srrs    lib/libopie lib/libradius lib/librpcsvc lib/libsbuf lib/libtacplus \
780163953Srrs    lib/libutil lib/libz lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
781163953Srrs.if exists(${.CURDIR}/${_lib})
782163953Srrs	cd ${.CURDIR}/${_lib}; \
783163953Srrs		${MAKE} depend; \
784163953Srrs		${MAKE} all; \
785163953Srrs		${MAKE} install
786163953Srrs.endif
787163953Srrs.endfor
788163953Srrs
789163953Srrs.for __target in clean cleandepend cleandir depend obj
790163953Srrs.for entry in ${SUBDIR}
791163953Srrs${entry}.${__target}__D: .PHONY
792163953Srrs	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
793163953Srrs		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
794163953Srrs		edir=${entry}.${MACHINE_ARCH}; \
795163953Srrs		cd ${.CURDIR}/$${edir}; \
796163953Srrs	else \
797163953Srrs		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
798163953Srrs		edir=${entry}; \
799163953Srrs		cd ${.CURDIR}/$${edir}; \
800163953Srrs	fi; \
801163953Srrs	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
802163953Srrs.endfor
803163953Srrspar-${__target}: ${SUBDIR:S/$/.${__target}__D/}
804163953Srrs.endfor
805163953Srrs
806163953Srrs.include <bsd.subdir.mk>
807163953Srrs