Makefile.inc1 revision 124544
155682Smarkm#
2178825Sdfr# $FreeBSD: head/Makefile.inc1 124544 2004-01-15 09:50:54Z ru $
355682Smarkm#
455682Smarkm# Make command line options:
555682Smarkm#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
655682Smarkm#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
755682Smarkm#	-DNO_RESCUE do not build rescue binaries
855682Smarkm#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
955682Smarkm#	-DNOCLEAN do not clean at all
1055682Smarkm#	-DNOCRYPT will prevent building of crypt versions
1155682Smarkm#	-DNOMAN do not build the manual pages
1255682Smarkm#	-DNOPROFILE do not build profiled libraries
1355682Smarkm#	-DNOGAMES do not go into games subdir
1455682Smarkm#	-DNOSHARE do not go into share subdir
1555682Smarkm#	-DNOINFO do not make or install info files
1655682Smarkm#	-DNOLIBC_R do not build libc_r.
1755682Smarkm#	-DNO_FORTRAN do not build g77 and related libraries.
1855682Smarkm#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
1955682Smarkm#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
2055682Smarkm#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
2155682Smarkm#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
2255682Smarkm#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
2355682Smarkm#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
2455682Smarkm#	TARGET_ARCH="arch" to crossbuild world to a different arch
2555682Smarkm
2655682Smarkm#
2755682Smarkm# The intended user-driven targets are:
2855682Smarkm# buildworld  - rebuild *everything*, including glue to help do upgrades
2955682Smarkm# installworld- install everything built by "buildworld"
3055682Smarkm# update      - convenient way to update your source tree (eg: sup/cvs)
3155682Smarkm#
3255682Smarkm# Standard targets (not defined here) are documented in the makefiles in
3355682Smarkm# /usr/share/mk.  These include:
3455682Smarkm#		obj depend all install clean cleandepend cleanobj
35178825Sdfr
3655682Smarkm# Put initial settings here.
3755682SmarkmSUBDIR=
3855682Smarkm
3955682Smarkm# We must do share/info early so that installation of info `dir'
4055682Smarkm# entries works correctly.  Do it first since it is less likely to
4155682Smarkm# grow dependencies on include and lib than vice versa.
4255682Smarkm.if exists(${.CURDIR}/share/info)
4372445SassarSUBDIR+= share/info
4455682Smarkm.endif
4555682Smarkm
4655682Smarkm.if exists(${.CURDIR}/include)
4755682SmarkmSUBDIR+= include
4855682Smarkm.endif
4955682Smarkm
5055682Smarkm# We must do lib and libexec before bin, because if installworld
5155682Smarkm# installs a new /bin/sh, the 'make' command will *immediately*
5255682Smarkm# use that new version.  And the new (dynamically-linked) /bin/sh
5355682Smarkm# will expect to find appropriate libraries in /lib and /libexec.
5455682Smarkm.if exists(${.CURDIR}/lib)
5555682SmarkmSUBDIR+= lib
5655682Smarkm.endif
5755682Smarkm.if exists(${.CURDIR}/libexec)
5855682SmarkmSUBDIR+= libexec
5955682Smarkm.endif
6055682Smarkm
6155682Smarkm.if exists(${.CURDIR}/bin)
6255682SmarkmSUBDIR+= bin
6355682Smarkm.endif
6455682Smarkm.if exists(${.CURDIR}/games) && !defined(NOGAMES)
6555682SmarkmSUBDIR+= games
6655682Smarkm.endif
6755682Smarkm.if exists(${.CURDIR}/gnu)
6855682SmarkmSUBDIR+= gnu
6955682Smarkm.endif
7055682Smarkm.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
7155682Smarkm    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
7255682SmarkmSUBDIR+= kerberos5
7355682Smarkm.endif
7455682Smarkm.if exists(${.CURDIR}/rescue) && !defined(NO_RESCUE)
7555682SmarkmSUBDIR+= rescue
7655682Smarkm.endif
7755682Smarkm.if exists(${.CURDIR}/sbin)
7855682SmarkmSUBDIR+= sbin
7955682Smarkm.endif
8055682Smarkm.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
8155682SmarkmSUBDIR+= secure
8255682Smarkm.endif
8355682Smarkm.if exists(${.CURDIR}/share) && !defined(NOSHARE)
8455682SmarkmSUBDIR+= share
8555682Smarkm.endif
8655682Smarkm.if exists(${.CURDIR}/sys)
8755682SmarkmSUBDIR+= sys
8855682Smarkm.endif
8955682Smarkm.if exists(${.CURDIR}/usr.bin)
9055682SmarkmSUBDIR+= usr.bin
9155682Smarkm.endif
9255682Smarkm.if exists(${.CURDIR}/usr.sbin)
9355682SmarkmSUBDIR+= usr.sbin
9455682Smarkm.endif
9555682Smarkm
9655682Smarkm# etc must be last for "distribute" to work
9755682Smarkm.if exists(${.CURDIR}/etc)
9855682SmarkmSUBDIR+= etc
9955682Smarkm.endif
10055682Smarkm
10155682Smarkm# These are last, since it is nice to at least get the base system
10255682Smarkm# rebuilt before you do them.
10355682Smarkm.if defined(LOCAL_DIRS)
10455682Smarkm.for _DIR in ${LOCAL_DIRS}
10555682Smarkm.if exists(${.CURDIR}/${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
10655682SmarkmSUBDIR+= ${_DIR}
10755682Smarkm.endif
10855682Smarkm.endfor
10955682Smarkm.endif
11055682Smarkm
11155682Smarkm.if defined(SUBDIR_OVERRIDE)
11255682SmarkmSUBDIR=		${SUBDIR_OVERRIDE}
11355682Smarkm.endif
11455682Smarkm
11555682Smarkm.if defined(NOCLEANDIR)
11655682SmarkmCLEANDIR=	clean cleandepend
11755682Smarkm.else
11855682SmarkmCLEANDIR=	cleandir
11955682Smarkm.endif
12055682Smarkm
12155682SmarkmCVS?=		cvs
12255682SmarkmSUP?=		/usr/local/bin/cvsup
12355682SmarkmSUPFLAGS?=	-g -L 2 -P -
124178825Sdfr.if defined(SUPHOST)
125178825SdfrSUPFLAGS+=	-h ${SUPHOST}
126178825Sdfr.endif
127178825Sdfr
128178825SdfrMAKEOBJDIRPREFIX?=	/usr/obj
129178825Sdfr.if !defined(OSRELDATE)
130178825Sdfr.if exists(/usr/include/osreldate.h)
131178825SdfrOSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
132178825Sdfr		/usr/include/osreldate.h
13355682Smarkm.else
13455682SmarkmOSRELDATE=	0
13555682Smarkm.endif
13655682Smarkm.endif
13755682SmarkmTARGET_ARCH?=	${MACHINE_ARCH}
13855682Smarkm.if ${TARGET_ARCH} == ${MACHINE_ARCH}
13955682SmarkmTARGET?=	${MACHINE}
14055682SmarkmTARGET_CPUTYPE?=${CPUTYPE}
14155682Smarkm.else
14255682SmarkmTARGET?=	${TARGET_ARCH}
14355682SmarkmTARGET_CPUTYPE?=
14455682Smarkm.endif
14555682Smarkm.if !empty(TARGET_CPUTYPE)
14655682Smarkm_TARGET_CPUTYPE=${TARGET_CPUTYPE}
14755682Smarkm.else
14855682Smarkm_TARGET_CPUTYPE=dummy
14955682Smarkm.endif
150178825Sdfr_CPUTYPE!=	${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
15155682Smarkm		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
15255682Smarkm.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
15355682Smarkm.error CPUTYPE global should be set with ?=.
15455682Smarkm.endif
15555682Smarkm.if make(buildworld)
15655682SmarkmBUILD_ARCH!=	sysctl -n hw.machine_arch
15755682Smarkm.if ${MACHINE_ARCH} != ${BUILD_ARCH}
15855682Smarkm.error To cross-build, set TARGET_ARCH.
15955682Smarkm.endif
16055682Smarkm.endif
16155682Smarkm.if ${MACHINE} == ${TARGET}
16255682SmarkmOBJTREE=	${MAKEOBJDIRPREFIX}
16355682Smarkm.else
16455682SmarkmOBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
16555682Smarkm.endif
166178825SdfrWORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
16755682Smarkm# /usr/games added for fortune which depend on strfile
16855682SmarkmBPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
16955682SmarkmXPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
17055682SmarkmSTRICTTMPPATH=	${BPATH}:${XPATH}
17155682SmarkmTMPPATH=	${STRICTTMPPATH}:${PATH}
17255682Smarkm
17355682SmarkmINSTALLTMP!=	/usr/bin/mktemp -d -u -t install
17455682Smarkm
17555682Smarkm#
17655682Smarkm# Building a world goes through the following stages
17755682Smarkm#
17855682Smarkm# 1. legacy stage [BMAKE]
17955682Smarkm#	This stage is responsible for creating compatibility
18055682Smarkm#	shims that are needed by the bootstrap-tools,
18155682Smarkm#	build-tools and cross-tools stages.
18255682Smarkm# 1. bootstrap-tools stage [BMAKE]
18355682Smarkm#	This stage is responsible for creating programs that
18455682Smarkm#	are needed for backward compatibility reasons. They
18555682Smarkm#	are not built as cross-tools.
18655682Smarkm# 2. build-tools stage [TMAKE]
18755682Smarkm#	This stage is responsible for creating the object
18855682Smarkm#	tree and building any tools that are needed during
18955682Smarkm#	the build process.
19055682Smarkm# 3. cross-tools stage [XMAKE]
19155682Smarkm#	This stage is responsible for creating any tools that
19255682Smarkm#	are needed for cross-builds. A cross-compiler is one
19355682Smarkm#	of them.
19455682Smarkm# 4. world stage [WMAKE]
19555682Smarkm#	This stage actually builds the world.
19655682Smarkm# 5. install stage (optional) [IMAKE]
19755682Smarkm#	This stage installs a previously built world.
19855682Smarkm#
19955682Smarkm
20055682SmarkmBOOTSTRAPPING?=	0
20155682Smarkm
20255682Smarkm# Common environment for world related stages
20355682SmarkmCROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
20455682Smarkm		MACHINE_ARCH=${TARGET_ARCH} \
20555682Smarkm		MACHINE=${TARGET} \
20655682Smarkm		CPUTYPE=${TARGET_CPUTYPE} \
20755682Smarkm		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
20855682Smarkm		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
20955682Smarkm		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
21055682Smarkm
211# bootstrap-tools stage
212BMAKEENV=	DESTDIR= \
213		INSTALL="sh ${.CURDIR}/tools/install.sh" \
214		PATH=${BPATH}:${PATH} \
215		WORLDTMP=${WORLDTMP} \
216		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
217BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
218		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
219		BOOTSTRAPPING=${OSRELDATE} \
220		-DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
221		-DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
222
223# build-tools stage
224TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
225		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
226		BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
227
228# cross-tools stage
229XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
230
231# world stage
232WMAKEENV=	${CROSSENV} \
233		DESTDIR=${WORLDTMP} \
234		_SHLIBDIRPREFIX=${WORLDTMP} \
235		INSTALL="sh ${.CURDIR}/tools/install.sh" \
236		PATH=${TMPPATH}
237WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
238
239# install stage
240IMAKEENV=	${CROSSENV} \
241		PATH=${STRICTTMPPATH}:${INSTALLTMP}
242IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
243
244# kernel stage
245KMAKEENV=	${WMAKEENV}
246
247#
248# buildworld
249#
250# Attempt to rebuild the entire system, with reasonable chance of
251# success, regardless of how old your existing system is.
252#
253_worldtmp:
254.if ${.CURDIR:C/[^,]//g} != ""
255#	The m4 build of sendmail files doesn't like it if ',' is used
256#	anywhere in the path of it's files.
257	@echo
258	@echo "*** Error: path to source tree contains a comma ','"
259	@echo
260	@false
261.endif
262	@echo
263	@echo "--------------------------------------------------------------"
264	@echo ">>> Rebuilding the temporary build tree"
265	@echo "--------------------------------------------------------------"
266.if !defined(NOCLEAN)
267	rm -rf ${WORLDTMP}
268.else
269	rm -rf ${WORLDTMP}/legacy/usr/include
270	# XXX - These two can depend on any header file.
271	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
272	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
273.endif
274.for _dir in \
275    usr/bin usr/games usr/include/sys usr/lib \
276    usr/libexec usr/sbin usr/share/dict \
277    usr/share/groff_font/devX100 \
278    usr/share/groff_font/devX100-12 \
279    usr/share/groff_font/devX75 \
280    usr/share/groff_font/devX75-12 \
281    usr/share/groff_font/devascii \
282    usr/share/groff_font/devcp1047 \
283    usr/share/groff_font/devdvi \
284    usr/share/groff_font/devhtml \
285    usr/share/groff_font/devkoi8-r \
286    usr/share/groff_font/devlatin1 \
287    usr/share/groff_font/devlbp \
288    usr/share/groff_font/devlj4 \
289    usr/share/groff_font/devps \
290    usr/share/groff_font/devutf8 \
291    usr/share/tmac/mdoc usr/share/tmac/mm
292	mkdir -p ${WORLDTMP}/legacy/${_dir}
293.endfor
294.for _dir in \
295    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
296    usr/libexec usr/share/misc usr/share/bsnmp/defs usr/share/bsnmp/mibs
297	mkdir -p ${WORLDTMP}/${_dir}
298.endfor
299	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
300	    -p ${WORLDTMP}/usr/include
301	ln -sf ${.CURDIR}/sys ${WORLDTMP}
302_legacy:
303	@echo
304	@echo "--------------------------------------------------------------"
305	@echo ">>> stage 1.1: legacy release compatibility shims"
306	@echo "--------------------------------------------------------------"
307	cd ${.CURDIR}; ${BMAKE} legacy
308_bootstrap-tools:
309	@echo
310	@echo "--------------------------------------------------------------"
311	@echo ">>> stage 1.2: bootstrap tools"
312	@echo "--------------------------------------------------------------"
313	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
314_cleanobj:
315.if !defined(NOCLEAN)
316	@echo
317	@echo "--------------------------------------------------------------"
318	@echo ">>> stage 2.1: cleaning up the object tree"
319	@echo "--------------------------------------------------------------"
320	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
321.endif
322_obj:
323	@echo
324	@echo "--------------------------------------------------------------"
325	@echo ">>> stage 2.2: rebuilding the object tree"
326	@echo "--------------------------------------------------------------"
327	cd ${.CURDIR}; ${WMAKE} par-obj
328_build-tools:
329	@echo
330	@echo "--------------------------------------------------------------"
331	@echo ">>> stage 2.3: build tools"
332	@echo "--------------------------------------------------------------"
333	cd ${.CURDIR}; ${TMAKE} build-tools
334_cross-tools:
335	@echo
336	@echo "--------------------------------------------------------------"
337	@echo ">>> stage 3: cross tools"
338	@echo "--------------------------------------------------------------"
339	cd ${.CURDIR}; ${XMAKE} cross-tools
340_includes:
341	@echo
342	@echo "--------------------------------------------------------------"
343	@echo ">>> stage 4.1: building includes"
344	@echo "--------------------------------------------------------------"
345	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
346_libraries:
347	@echo
348	@echo "--------------------------------------------------------------"
349	@echo ">>> stage 4.2: building libraries"
350	@echo "--------------------------------------------------------------"
351	cd ${.CURDIR}; \
352	    ${WMAKE} -DNOFSCHG -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPROFILE \
353	    libraries
354_depend:
355	@echo
356	@echo "--------------------------------------------------------------"
357	@echo ">>> stage 4.3: make dependencies"
358	@echo "--------------------------------------------------------------"
359	cd ${.CURDIR}; ${WMAKE} par-depend
360everything:
361	@echo
362	@echo "--------------------------------------------------------------"
363	@echo ">>> stage 4.4: building everything.."
364	@echo "--------------------------------------------------------------"
365	cd ${.CURDIR}; ${WMAKE} par-all
366
367
368WMAKE_TGTS=
369.if !defined(SUBDIR_OVERRIDE)
370WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
371.endif
372WMAKE_TGTS+=	_cleanobj _obj _build-tools
373.if !defined(SUBDIR_OVERRIDE)
374WMAKE_TGTS+=	_cross-tools
375.endif
376WMAKE_TGTS+=	_includes _libraries _depend everything
377
378buildworld: ${WMAKE_TGTS}
379.ORDER: ${WMAKE_TGTS}
380
381#
382# installcheck
383#
384# Checks to be sure system is ready for installworld
385#
386installcheck:
387.if !defined(NO_SENDMAIL)
388	@if ! `id -u smmsp > /dev/null`; then \
389		echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
390		false; \
391	fi
392	@if ! `id -g smmsp > /dev/null`; then \
393		echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
394		false; \
395	fi
396.endif
397
398#
399# distributeworld
400#
401# Distributes everything compiled by a `buildworld'.
402#
403# installworld
404#
405# Installs everything compiled by a 'buildworld'.
406#
407distributeworld installworld: installcheck
408	mkdir -p ${INSTALLTMP}
409	for prog in [ awk cap_mkdb cat chflags chmod chown \
410	    date echo egrep find grep \
411	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
412	    test true uname wc zic; do \
413		cp `which $$prog` ${INSTALLTMP}; \
414	done
415	cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
416	rm -rf ${INSTALLTMP}
417
418#
419# reinstall
420#
421# If you have a build server, you can NFS mount the source and obj directories
422# and do a 'make reinstall' on the *client* to install new binaries from the
423# most recent server build.
424#
425reinstall:
426	@echo "--------------------------------------------------------------"
427	@echo ">>> Making hierarchy"
428	@echo "--------------------------------------------------------------"
429	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
430	@echo
431	@echo "--------------------------------------------------------------"
432	@echo ">>> Installing everything.."
433	@echo "--------------------------------------------------------------"
434	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
435.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
436	@echo
437	@echo "--------------------------------------------------------------"
438	@echo ">>> Rebuilding man page indices"
439	@echo "--------------------------------------------------------------"
440	cd ${.CURDIR}/share/man; ${MAKE} makedb
441.endif
442
443redistribute:
444	@echo "--------------------------------------------------------------"
445	@echo ">>> Distributing everything.."
446	@echo "--------------------------------------------------------------"
447	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
448
449#
450# buildkernel and installkernel
451#
452# Which kernels to build and/or install is specified by setting
453# KERNCONF. If not defined a GENERIC kernel is built/installed.
454# Only the existing (depending TARGET) config files are used
455# for building kernels and only the first of these is designated
456# as the one being installed.
457#
458# Note that we have to use TARGET instead of TARGET_ARCH when
459# we're in kernel-land. Since only TARGET_ARCH is (expected) to
460# be set to cross-build, we have to make sure TARGET is set
461# properly.
462
463.if !defined(KERNCONF) && defined(KERNEL)
464KERNCONF=	${KERNEL}
465KERNWARN=	yes
466.else
467KERNCONF?=	GENERIC
468.endif
469INSTKERNNAME?=	kernel
470
471KERNSRCDIR?=	${.CURDIR}/sys
472KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
473KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
474KERNCONFDIR?=	${KRNLCONFDIR}
475
476BUILDKERNELS=
477INSTALLKERNEL=
478.for _kernel in ${KERNCONF}
479.if exists(${KERNCONFDIR}/${_kernel})
480BUILDKERNELS+=	${_kernel}
481.if empty(INSTALLKERNEL)
482INSTALLKERNEL= ${_kernel}
483.endif
484.endif
485.endfor
486
487#
488# buildkernel
489#
490# Builds all kernels defined by BUILDKERNELS.
491#
492buildkernel:
493.if empty(BUILDKERNELS)
494	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
495	@false
496.endif
497.if defined(KERNWARN)
498	@echo "--------------------------------------------------------------"
499	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
500	@echo "--------------------------------------------------------------"
501	@sleep 3
502.endif
503	@echo
504.for _kernel in ${BUILDKERNELS}
505	@echo "--------------------------------------------------------------"
506	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
507	@echo "--------------------------------------------------------------"
508	@echo "===> ${_kernel}"
509	mkdir -p ${KRNLOBJDIR}
510.if !defined(NO_KERNELCONFIG)
511	cd ${KRNLCONFDIR}; \
512		PATH=${TMPPATH} \
513		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
514			${KERNCONFDIR}/${_kernel}
515.endif
516.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
517	cd ${KRNLOBJDIR}/${_kernel}; \
518	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
519.endif
520	cd ${KRNLOBJDIR}/${_kernel}; \
521	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
522	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
523	cd ${KRNLOBJDIR}/${_kernel}; \
524	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
525# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
526.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
527.for target in obj depend all
528	cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
529	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
530	    ${MAKE} -DNO_CPU_CFLAGS ${target}
531.endfor
532.endif
533.if !defined(NO_KERNELDEPEND)
534	cd ${KRNLOBJDIR}/${_kernel}; \
535	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
536.endif
537	cd ${KRNLOBJDIR}/${_kernel}; \
538	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
539	@echo "--------------------------------------------------------------"
540	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
541	@echo "--------------------------------------------------------------"
542.endfor
543
544#
545# installkernel
546#
547# Install the kernel defined by INSTALLKERNEL
548#
549installkernel reinstallkernel installkernel.debug reinstallkernel.debug:
550.if empty(INSTALLKERNEL)
551	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
552	@false
553.endif
554	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
555	    ${CROSSENV} PATH=${TMPPATH} \
556	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
557
558#
559# update
560#
561# Update the source tree, by running sup and/or running cvs to update to the
562# latest copy.
563#
564update:
565.if defined(SUP_UPDATE)
566	@echo "--------------------------------------------------------------"
567	@echo ">>> Running ${SUP}"
568	@echo "--------------------------------------------------------------"
569.if defined(SUPFILE)
570	@${SUP} ${SUPFLAGS} ${SUPFILE}
571.endif
572.if defined(SUPFILE1)
573	@${SUP} ${SUPFLAGS} ${SUPFILE1}
574.endif
575.if defined(SUPFILE2)
576	@${SUP} ${SUPFLAGS} ${SUPFILE2}
577.endif
578.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
579	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
580.endif
581.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
582	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
583.endif
584.endif
585.if defined(CVS_UPDATE)
586	@echo "--------------------------------------------------------------"
587	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
588	@echo "--------------------------------------------------------------"
589	cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
590.endif
591
592#
593# ------------------------------------------------------------------------
594#
595# From here onwards are utility targets used by the 'make world' and
596# related targets.  If your 'world' breaks, you may like to try to fix
597# the problem and manually run the following targets to attempt to
598# complete the build.  Beware, this is *not* guaranteed to work, you
599# need to have a pretty good grip on the current state of the system
600# to attempt to manually finish it.  If in doubt, 'make world' again.
601#
602
603#
604# legacy: Build compatibility shims for the next three targets
605#
606legacy:
607.for _tool in tools/build
608	@${ECHODIR} "===> ${_tool}"; \
609	    cd ${.CURDIR}/${_tool}; \
610	    ${MAKE} DIRPRFX=${_tool}/ obj; \
611	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
612	    ${MAKE} DIRPRFX=${_tool}/ depend; \
613	    ${MAKE} DIRPRFX=${_tool}/ all; \
614	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
615.endfor
616
617#
618# bootstrap-tools: Build tools needed for compatibility
619#
620.if exists(${.CURDIR}/games) && !defined(NOGAMES)
621_strfile=	games/fortune/strfile
622.endif
623
624.if !defined(NO_CXX)
625_gperf=	gnu/usr.bin/gperf
626.if ${BOOTSTRAPPING} < 500113
627_groff=		gnu/usr.bin/groff
628.else
629_groff=		gnu/usr.bin/groff/tmac
630.endif
631.endif
632
633.if ${BOOTSTRAPPING} < 450005 || \
634    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
635_uudecode=	usr.bin/uudecode
636.endif
637
638.if ${BOOTSTRAPPING} < 430002 || \
639    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
640_xargs=		usr.bin/xargs
641.endif
642
643.if ${BOOTSTRAPPING} < 430002 || \
644    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
645_yacc=		usr.bin/yacc
646.endif
647
648.if !defined(NO_RESCUE) && \
649    ${BOOTSTRAPPING} < 501100
650_crunchgen=	usr.sbin/crunch/crunchgen
651.endif
652
653.if ${BOOTSTRAPPING} < 500019
654_kbdcontrol=	usr.sbin/kbdcontrol
655.endif
656
657bootstrap-tools:
658.for _tool in \
659    ${_strfile} \
660    ${_gperf} \
661    ${_groff} \
662    gnu/usr.bin/texinfo \
663    usr.bin/colldef \
664    usr.bin/makewhatis \
665    usr.bin/rpcgen \
666    ${_uudecode} \
667    ${_xargs} \
668    usr.bin/xinstall \
669    ${_yacc} \
670    usr.sbin/config \
671    ${_crunchgen} \
672    ${_kbdcontrol}
673	@${ECHODIR} "===> ${_tool}"; \
674		cd ${.CURDIR}/${_tool}; \
675		${MAKE} DIRPRFX=${_tool}/ obj; \
676		${MAKE} DIRPRFX=${_tool}/ depend; \
677		${MAKE} DIRPRFX=${_tool}/ all; \
678		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
679.endfor
680
681#
682# build-tools: Build special purpose build tools
683#
684.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
685_aicasm= sys/modules/aic7xxx/aicasm
686.endif
687
688.if exists(${.CURDIR}/share) && !defined(NOSHARE)
689_share=	share/syscons/scrnmaps
690.endif
691
692.if !defined(NO_FORTRAN)
693_fortran= gnu/usr.bin/cc/f771
694.endif
695
696.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
697    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
698_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
699    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
700.endif
701
702.if exists(${.CURDIR}/rescue) && !defined(NO_RESCUE)
703_rescue= rescue/rescue
704.endif
705
706build-tools:
707.for _tool in \
708    bin/csh \
709    bin/sh \
710    ${_rescue} \
711    gnu/usr.bin/cc/cc_tools \
712    ${_fortran} \
713    ${_libkrb5} \
714    lib/libncurses \
715    ${_share} \
716    ${_aicasm} \
717    usr.bin/awk \
718    usr.bin/file \
719    usr.sbin/sysinstall
720	@${ECHODIR} "===> ${_tool}"; \
721		cd ${.CURDIR}/${_tool}; \
722		${MAKE} DIRPRFX=${_tool}/ obj; \
723		${MAKE} DIRPRFX=${_tool}/ build-tools
724.endfor
725
726#
727# cross-tools: Build cross-building tools
728#
729.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
730    ${BOOTSTRAPPING} < 500037
731_elf2aout=	usr.bin/elf2aout
732.endif
733
734.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
735_btxld=		usr.sbin/btxld
736.endif
737
738.if (!defined(NO_RESCUE) || \
739    defined(RELEASEDIR)) && \
740    (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
741_crunchide=	usr.sbin/crunch/crunchide
742.endif
743
744.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
745_elf2exe=	usr.sbin/elf2exe
746.endif
747
748.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
749    defined(RELEASEDIR)
750_kgzip=		usr.sbin/kgzip
751.endif
752
753cross-tools:
754.for _tool in \
755    gnu/usr.bin/binutils \
756    gnu/usr.bin/cc \
757    ${_elf2aout} \
758    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
759    ${_btxld} \
760    ${_crunchide} \
761    ${_elf2exe} \
762    ${_kgzip}
763	@${ECHODIR} "===> ${_tool}"; \
764		cd ${.CURDIR}/${_tool}; \
765		${MAKE} DIRPRFX=${_tool}/ obj; \
766		${MAKE} DIRPRFX=${_tool}/ depend; \
767		${MAKE} DIRPRFX=${_tool}/ all; \
768		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
769.endfor
770
771#
772# hierarchy - ensure that all the needed directories are present
773#
774hierarchy:
775	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
776
777#
778# libraries - build all libraries, and install them under ${DESTDIR}.
779#
780# The list of libraries with dependents (${_prebuild_libs}) and their
781# interdependencies (__L) are built automatically by the
782# ${.CURDIR}/tools/make_libdeps.sh script.
783#
784libraries:
785	cd ${.CURDIR}; \
786	    ${MAKE} -f Makefile.inc1 _startup_libs; \
787	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
788	    ${MAKE} -f Makefile.inc1 _generic_libs;
789
790# These dependencies are not automatically generated:
791#
792# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
793# shared libraries for ELF.
794#
795_startup_libs=	gnu/lib/csu gnu/lib/libgcc
796.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
797_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
798.else
799_startup_libs+=	lib/csu/${MACHINE_ARCH}
800.endif
801
802_prebuild_libs=
803
804_generic_libs=	gnu/lib
805
806.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
807    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
808_prebuild_libs+=	kerberos5/lib/libasn1
809_prebuild_libs+=	kerberos5/lib/libgssapi
810_prebuild_libs+=	kerberos5/lib/libkrb5
811_prebuild_libs+=	kerberos5/lib/libroken
812_generic_libs+=	kerberos5/lib
813.endif
814
815_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
816		lib/libkvm lib/libmd \
817		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
818		lib/libradius lib/librpcsvc \
819		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
820		lib/libz lib/msun
821
822lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
823lib/libypclnt__L: lib/librpcsvc__L
824
825_generic_libs+=	lib
826
827.if !defined(NOCRYPT)
828.if !defined(NO_OPENSSL)
829_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
830.if !defined(NO_OPENSSH)
831_prebuild_libs+=	secure/lib/libssh
832secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
833.endif
834.endif
835_generic_libs+=	secure/lib
836.endif
837
838_generic_libs+=	usr.bin/lex/lib
839
840.if ${MACHINE_ARCH} == "i386"
841_generic_libs+=	usr.sbin/pcvt/keycap
842.endif
843
844.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
845${_lib}__L: .PHONY
846.if exists(${.CURDIR}/${_lib})
847	@${ECHODIR} "===> ${_lib}"; \
848		cd ${.CURDIR}/${_lib}; \
849		${MAKE} DIRPRFX=${_lib}/ depend; \
850		${MAKE} DIRPRFX=${_lib}/ all; \
851		${MAKE} DIRPRFX=${_lib}/ install
852.endif
853.endfor
854
855# libpam is special: we need to build static PAM modules before
856# static PAM library, and dynamic PAM library before dynamic PAM
857# modules.
858lib/libpam__L: .PHONY
859	@${ECHODIR} "===> lib/libpam"; \
860		cd ${.CURDIR}/lib/libpam; \
861		${MAKE} DIRPRFX=lib/libpam/ depend; \
862		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
863		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
864
865_startup_libs: ${_startup_libs:S/$/__L/}
866_prebuild_libs: ${_prebuild_libs:S/$/__L/}
867_generic_libs: ${_generic_libs:S/$/__L/}
868
869.for __target in all clean cleandepend cleandir depend includes obj
870.for entry in ${SUBDIR}
871${entry}.${__target}__D: .PHONY
872	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
873		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
874		edir=${entry}.${MACHINE_ARCH}; \
875		cd ${.CURDIR}/$${edir}; \
876	else \
877		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
878		edir=${entry}; \
879		cd ${.CURDIR}/$${edir}; \
880	fi; \
881	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
882.endfor
883par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
884.endfor
885
886.include <bsd.subdir.mk>
887