Makefile.inc1 revision 134279
1#
2# $FreeBSD: head/Makefile.inc1 134279 2004-08-24 23:12:16Z paul $
3#
4# Make command line options:
5#	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
6#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
7#	-DNO_RESCUE do not build rescue binaries
8#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
9#	-DNOCLEAN do not clean at all
10#	-DNOCRYPT will prevent building of crypt versions
11#	-DNOMAN do not build the manual pages
12#	-DNOPROFILE do not build profiled libraries
13#	-DNOGAMES do not go into games subdir
14#	-DNOSHARE do not go into share subdir
15#	-DNOINFO do not make or install info files
16#	-DNOLIBC_R do not build libc_r.
17#	-DNO_FORTRAN do not build g77 and related libraries.
18#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
19#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
20#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
21#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
22#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
23#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
24#	TARGET_ARCH="arch" to crossbuild world to a different arch
25
26#
27# The intended user-driven targets are:
28# buildworld  - rebuild *everything*, including glue to help do upgrades
29# installworld- install everything built by "buildworld"
30# update      - convenient way to update your source tree (eg: sup/cvs)
31#
32# Standard targets (not defined here) are documented in the makefiles in
33# /usr/share/mk.  These include:
34#		obj depend all install clean cleandepend cleanobj
35
36# We must do share/info early so that installation of info `dir'
37# entries works correctly.  Do it first since it is less likely to
38# grow dependencies on include and lib than vice versa.
39#
40# We must do lib and libexec before bin, because if installworld
41# installs a new /bin/sh, the 'make' command will *immediately*
42# use that new version.  And the new (dynamically-linked) /bin/sh
43# will expect to find appropriate libraries in /lib and /libexec.
44#
45# We must do etc last for install/distribute to work.
46#
47SUBDIR=	share/info include lib libexec bin
48.if !defined(NOGAMES)
49SUBDIR+=games
50.endif
51SUBDIR+=gnu
52.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
53SUBDIR+=kerberos5
54.endif
55.if !defined(NO_RESCUE)
56SUBDIR+=rescue
57.endif
58SUBDIR+=sbin
59.if !defined(NOCRYPT)
60SUBDIR+=secure
61.endif
62.if !defined(NOSHARE)
63SUBDIR+=share
64.endif
65SUBDIR+=sys usr.bin usr.sbin etc
66
67# These are last, since it is nice to at least get the base system
68# rebuilt before you do them.
69.for _DIR in ${LOCAL_DIRS}
70.if exists(${.CURDIR}/${_DIR}/Makefile)
71SUBDIR+= ${_DIR}
72.endif
73.endfor
74
75.if defined(SUBDIR_OVERRIDE)
76SUBDIR=		${SUBDIR_OVERRIDE}
77.endif
78
79.if defined(NOCLEANDIR)
80CLEANDIR=	clean cleandepend
81.else
82CLEANDIR=	cleandir
83.endif
84
85CVS?=		cvs
86CVSFLAGS?=	-A -P -d
87.if defined(CVSTAG)
88CVSFLAGS+=	-r ${CVSTAG}
89.endif
90SUP?=		/usr/local/bin/cvsup
91SUPFLAGS?=	-g -L 2 -P -
92.if defined(SUPHOST)
93SUPFLAGS+=	-h ${SUPHOST}
94.endif
95
96MAKEOBJDIRPREFIX?=	/usr/obj
97.if !defined(OSRELDATE)
98.if exists(/usr/include/osreldate.h)
99OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
100		/usr/include/osreldate.h
101.else
102OSRELDATE=	0
103.endif
104.endif
105TARGET_ARCH?=	${MACHINE_ARCH}
106.if ${TARGET_ARCH} == ${MACHINE_ARCH}
107TARGET?=	${MACHINE}
108TARGET_CPUTYPE?=${CPUTYPE}
109.else
110TARGET?=	${TARGET_ARCH}
111TARGET_CPUTYPE?=
112.endif
113.if !empty(TARGET_CPUTYPE)
114_TARGET_CPUTYPE=${TARGET_CPUTYPE}
115.else
116_TARGET_CPUTYPE=dummy
117.endif
118_CPUTYPE!=	MAKEFLAGS= ${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
119		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
120.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
121.error CPUTYPE global should be set with ?=.
122.endif
123.if make(buildworld)
124BUILD_ARCH!=	sysctl -n hw.machine_arch
125.if ${MACHINE_ARCH} != ${BUILD_ARCH}
126.error To cross-build, set TARGET_ARCH.
127.endif
128.endif
129.if ${MACHINE} == ${TARGET}
130OBJTREE=	${MAKEOBJDIRPREFIX}
131.else
132OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
133.endif
134WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
135# /usr/games added for fortune which depend on strfile
136BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
137XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
138STRICTTMPPATH=	${BPATH}:${XPATH}
139TMPPATH=	${STRICTTMPPATH}:${PATH}
140
141INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
142
143#
144# Building a world goes through the following stages
145#
146# 1. legacy stage [BMAKE]
147#	This stage is responsible for creating compatibility
148#	shims that are needed by the bootstrap-tools,
149#	build-tools and cross-tools stages.
150# 1. bootstrap-tools stage [BMAKE]
151#	This stage is responsible for creating programs that
152#	are needed for backward compatibility reasons. They
153#	are not built as cross-tools.
154# 2. build-tools stage [TMAKE]
155#	This stage is responsible for creating the object
156#	tree and building any tools that are needed during
157#	the build process.
158# 3. cross-tools stage [XMAKE]
159#	This stage is responsible for creating any tools that
160#	are needed for cross-builds. A cross-compiler is one
161#	of them.
162# 4. world stage [WMAKE]
163#	This stage actually builds the world.
164# 5. install stage (optional) [IMAKE]
165#	This stage installs a previously built world.
166#
167
168BOOTSTRAPPING?=	0
169
170# Common environment for world related stages
171CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
172		MACHINE_ARCH=${TARGET_ARCH} \
173		MACHINE=${TARGET} \
174		CPUTYPE=${TARGET_CPUTYPE} \
175		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
176		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
177		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
178
179# bootstrap-tools stage
180BMAKEENV=	DESTDIR= \
181		INSTALL="sh ${.CURDIR}/tools/install.sh" \
182		PATH=${BPATH}:${PATH} \
183		WORLDTMP=${WORLDTMP} \
184		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
185BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
186		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
187		BOOTSTRAPPING=${OSRELDATE} \
188		-DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
189		-DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
190
191# build-tools stage
192TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
193		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
194		BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
195
196# cross-tools stage
197XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
198
199# world stage
200WMAKEENV=	${CROSSENV} \
201		DESTDIR=${WORLDTMP} \
202		_SHLIBDIRPREFIX=${WORLDTMP} \
203		INSTALL="sh ${.CURDIR}/tools/install.sh" \
204		PATH=${TMPPATH}
205WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
206
207# install stage
208.if empty(.MAKEFLAGS:M-n)
209IMAKEENV=	${CROSSENV} \
210		PATH=${STRICTTMPPATH}:${INSTALLTMP}
211.else
212IMAKEENV=	${CROSSENV} \
213		PATH=${TMPPATH}:${INSTALLTMP}
214.endif
215IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
216
217# kernel stage
218KMAKEENV=	${WMAKEENV}
219
220#
221# buildworld
222#
223# Attempt to rebuild the entire system, with reasonable chance of
224# success, regardless of how old your existing system is.
225#
226_worldtmp:
227.if ${.CURDIR:C/[^,]//g} != ""
228#	The m4 build of sendmail files doesn't like it if ',' is used
229#	anywhere in the path of it's files.
230	@echo
231	@echo "*** Error: path to source tree contains a comma ','"
232	@echo
233	false
234.endif
235	@echo
236	@echo "--------------------------------------------------------------"
237	@echo ">>> Rebuilding the temporary build tree"
238	@echo "--------------------------------------------------------------"
239.if !defined(NOCLEAN)
240	rm -rf ${WORLDTMP}
241.else
242	rm -rf ${WORLDTMP}/legacy/usr/include
243	# XXX - These two can depend on any header file.
244	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
245	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
246.endif
247.for _dir in \
248    usr/bin usr/games usr/include/c++/3.3 usr/include/sys usr/lib \
249    usr/libexec usr/sbin usr/share/dict \
250    usr/share/groff_font/devX100 \
251    usr/share/groff_font/devX100-12 \
252    usr/share/groff_font/devX75 \
253    usr/share/groff_font/devX75-12 \
254    usr/share/groff_font/devascii \
255    usr/share/groff_font/devcp1047 \
256    usr/share/groff_font/devdvi \
257    usr/share/groff_font/devhtml \
258    usr/share/groff_font/devkoi8-r \
259    usr/share/groff_font/devlatin1 \
260    usr/share/groff_font/devlbp \
261    usr/share/groff_font/devlj4 \
262    usr/share/groff_font/devps \
263    usr/share/groff_font/devutf8 \
264    usr/share/tmac/mdoc usr/share/tmac/mm
265	mkdir -p ${WORLDTMP}/legacy/${_dir}
266.endfor
267.for _dir in \
268    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
269    usr/libexec usr/sbin usr/share/misc \
270    usr/share/snmp/defs usr/share/snmp/mibs
271	mkdir -p ${WORLDTMP}/${_dir}
272.endfor
273	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
274	    -p ${WORLDTMP}/usr/include >/dev/null
275	ln -sf ${.CURDIR}/sys ${WORLDTMP}
276_legacy:
277	@echo
278	@echo "--------------------------------------------------------------"
279	@echo ">>> stage 1.1: legacy release compatibility shims"
280	@echo "--------------------------------------------------------------"
281	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
282_bootstrap-tools:
283	@echo
284	@echo "--------------------------------------------------------------"
285	@echo ">>> stage 1.2: bootstrap tools"
286	@echo "--------------------------------------------------------------"
287	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
288_cleanobj:
289.if !defined(NOCLEAN)
290	@echo
291	@echo "--------------------------------------------------------------"
292	@echo ">>> stage 2.1: cleaning up the object tree"
293	@echo "--------------------------------------------------------------"
294	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
295.endif
296_obj:
297	@echo
298	@echo "--------------------------------------------------------------"
299	@echo ">>> stage 2.2: rebuilding the object tree"
300	@echo "--------------------------------------------------------------"
301	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
302_build-tools:
303	@echo
304	@echo "--------------------------------------------------------------"
305	@echo ">>> stage 2.3: build tools"
306	@echo "--------------------------------------------------------------"
307	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
308_cross-tools:
309	@echo
310	@echo "--------------------------------------------------------------"
311	@echo ">>> stage 3: cross tools"
312	@echo "--------------------------------------------------------------"
313	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
314_includes:
315	@echo
316	@echo "--------------------------------------------------------------"
317	@echo ">>> stage 4.1: building includes"
318	@echo "--------------------------------------------------------------"
319	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
320_libraries:
321	@echo
322	@echo "--------------------------------------------------------------"
323	@echo ">>> stage 4.2: building libraries"
324	@echo "--------------------------------------------------------------"
325	${_+_}cd ${.CURDIR}; \
326	    ${WMAKE} -DNOFSCHG -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPROFILE \
327	    libraries
328_depend:
329	@echo
330	@echo "--------------------------------------------------------------"
331	@echo ">>> stage 4.3: make dependencies"
332	@echo "--------------------------------------------------------------"
333	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
334everything:
335	@echo
336	@echo "--------------------------------------------------------------"
337	@echo ">>> stage 4.4: building everything"
338	@echo "--------------------------------------------------------------"
339	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
340
341
342WMAKE_TGTS=
343.if !defined(SUBDIR_OVERRIDE)
344WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
345.endif
346WMAKE_TGTS+=	_cleanobj _obj _build-tools
347.if !defined(SUBDIR_OVERRIDE)
348WMAKE_TGTS+=	_cross-tools
349.endif
350WMAKE_TGTS+=	_includes _libraries _depend everything
351
352buildworld: ${WMAKE_TGTS}
353.ORDER: ${WMAKE_TGTS}
354
355TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
356toolchain: ${TOOLCHAIN_TGTS}
357kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
358
359#
360# Use this to add checks to installworld/installkernel targets.
361#
362SPECIAL_INSTALLCHECKS=
363
364#
365# The following install-time check will see if the installation will
366# change the type used for time_t, and if it will, the target makes
367# sure that the user is expecting to make that change.
368#
369.if ${TARGET_ARCH} == "sparc64"
370SPECIAL_INSTALLCHECKS+=sparc64_installcheck
371
372CUR_TIMET!=	grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
373SRC_TIMET!=	grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
374		awk '{print $$2}'
375NEWSPARC_TIMETYPE?=${CUR_TIMET}
376
377sparc64_installcheck:
378.if ${CUR_TIMET} != ${SRC_TIMET}
379	@echo
380.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
381	@echo "***  ERROR: This target would change the type used for time_t!"
382.else
383	@echo "* Note: This installation changes the type used for time_t."
384.endif
385	@echo "* "
386	@echo "* This host has time_t defined as ${CUR_TIMET},"
387	@echo "* and this installation would change that to type ${SRC_TIMET}."
388.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
389	@echo "* "
390	@echo "* If that is *NOT* what you wanted, then you need to change the"
391	@echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
392	@echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'.  After that you *MUST*"
393	@echo "* do a complete cleanworld, buildworld, buildkernel before you"
394	@echo "* retry the 'make' command.  Also read /usr/src/UPDATING.64BTT."
395	@echo "* "
396	@echo "* If that *is* what you want, then enter the commands:"
397	@echo "      NEWSPARC_TIMETYPE=${SRC_TIMET}"
398	@echo "      export NEWSPARC_TIMETYPE"
399	@echo "* and repeat your 'make' command."
400	@echo
401	false
402.endif
403	@echo
404.elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
405	@echo
406	@echo "***  ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
407	@echo "***         but ${.CURDIR}/sys/sparc64/include/_types.h"
408	@echo "***         has __time_t defined as '${SRC_TIMET}'."
409	false
410.else
411	@# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
412.endif
413.endif
414
415#
416# installcheck
417#
418# Checks to be sure system is ready for installworld
419#
420CHECK_UIDS=
421CHECK_GIDS=
422.if !defined(NO_SENDMAIL)
423CHECK_UIDS+=	smmsp
424CHECK_GIDS+=	smmsp
425.endif
426.if !defined(NO_PF)
427CHECK_UIDS+=	proxy
428CHECK_GIDS+=	proxy authpf
429.endif
430installcheck: ${SPECIAL_INSTALLCHECKS}
431.for uid in ${CHECK_UIDS}
432	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
433		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
434		false; \
435	fi
436.endfor
437.for gid in ${CHECK_GIDS}
438	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
439		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
440		false; \
441	fi
442.endfor
443
444#
445# distributeworld
446#
447# Distributes everything compiled by a `buildworld'.
448#
449# installworld
450#
451# Installs everything compiled by a 'buildworld'.
452#
453distributeworld installworld: installcheck
454	mkdir -p ${INSTALLTMP}
455	for prog in [ awk cap_mkdb cat chflags chmod chown \
456	    date echo egrep find grep \
457	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
458	    test true uname wc zic; do \
459		cp `which $$prog` ${INSTALLTMP}; \
460	done
461	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
462	rm -rf ${INSTALLTMP}
463
464#
465# reinstall
466#
467# If you have a build server, you can NFS mount the source and obj directories
468# and do a 'make reinstall' on the *client* to install new binaries from the
469# most recent server build.
470#
471reinstall: ${SPECIAL_INSTALLCHECKS}
472	@echo "--------------------------------------------------------------"
473	@echo ">>> Making hierarchy"
474	@echo "--------------------------------------------------------------"
475	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
476	@echo
477	@echo "--------------------------------------------------------------"
478	@echo ">>> Installing everything"
479	@echo "--------------------------------------------------------------"
480	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
481
482redistribute:
483	@echo "--------------------------------------------------------------"
484	@echo ">>> Distributing everything"
485	@echo "--------------------------------------------------------------"
486	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
487
488#
489# buildkernel and installkernel
490#
491# Which kernels to build and/or install is specified by setting
492# KERNCONF. If not defined a GENERIC kernel is built/installed.
493# Only the existing (depending TARGET) config files are used
494# for building kernels and only the first of these is designated
495# as the one being installed.
496#
497# Note that we have to use TARGET instead of TARGET_ARCH when
498# we're in kernel-land. Since only TARGET_ARCH is (expected) to
499# be set to cross-build, we have to make sure TARGET is set
500# properly.
501
502.if !defined(KERNCONF) && defined(KERNEL)
503KERNCONF=	${KERNEL}
504KERNWARN=	yes
505.else
506KERNCONF?=	GENERIC
507.endif
508INSTKERNNAME?=	kernel
509
510KERNSRCDIR?=	${.CURDIR}/sys
511KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
512KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
513KERNCONFDIR?=	${KRNLCONFDIR}
514
515BUILDKERNELS=
516INSTALLKERNEL=
517.for _kernel in ${KERNCONF}
518.if exists(${KERNCONFDIR}/${_kernel})
519BUILDKERNELS+=	${_kernel}
520.if empty(INSTALLKERNEL)
521INSTALLKERNEL= ${_kernel}
522.endif
523.endif
524.endfor
525
526#
527# buildkernel
528#
529# Builds all kernels defined by BUILDKERNELS.
530#
531buildkernel:
532.if empty(BUILDKERNELS)
533	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
534	false
535.endif
536.if defined(KERNWARN)
537	@echo "--------------------------------------------------------------"
538	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
539	@echo "--------------------------------------------------------------"
540	@sleep 3
541.endif
542	@echo
543.for _kernel in ${BUILDKERNELS}
544	@echo "--------------------------------------------------------------"
545	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
546	@echo "--------------------------------------------------------------"
547	@echo "===> ${_kernel}"
548	mkdir -p ${KRNLOBJDIR}
549.if !defined(NO_KERNELCONFIG)
550	@echo
551	@echo "--------------------------------------------------------------"
552	@echo ">>> stage 1: configuring the kernel"
553	@echo "--------------------------------------------------------------"
554	cd ${KRNLCONFDIR}; \
555		PATH=${TMPPATH} \
556		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
557			${KERNCONFDIR}/${_kernel}
558.endif
559.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
560	@echo
561	@echo "--------------------------------------------------------------"
562	@echo ">>> stage 2.1: cleaning up the object tree"
563	@echo "--------------------------------------------------------------"
564	cd ${KRNLOBJDIR}/${_kernel}; \
565	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
566.endif
567	@echo
568	@echo "--------------------------------------------------------------"
569	@echo ">>> stage 2.2: rebuilding the object tree"
570	@echo "--------------------------------------------------------------"
571	cd ${KRNLOBJDIR}/${_kernel}; \
572	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
573	@echo
574	@echo "--------------------------------------------------------------"
575	@echo ">>> stage 2.3: build tools"
576	@echo "--------------------------------------------------------------"
577	cd ${KRNLOBJDIR}/${_kernel}; \
578	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
579	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
580# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
581.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
582.for target in obj depend all
583	cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
584	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
585	    ${MAKE} -DNO_CPU_CFLAGS ${target}
586.endfor
587.endif
588.if !defined(NO_KERNELDEPEND)
589	@echo
590	@echo "--------------------------------------------------------------"
591	@echo ">>> stage 3.1: making dependencies"
592	@echo "--------------------------------------------------------------"
593	cd ${KRNLOBJDIR}/${_kernel}; \
594	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
595.endif
596	@echo
597	@echo "--------------------------------------------------------------"
598	@echo ">>> stage 3.2: building everything"
599	@echo "--------------------------------------------------------------"
600	cd ${KRNLOBJDIR}/${_kernel}; \
601	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
602	@echo "--------------------------------------------------------------"
603	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
604	@echo "--------------------------------------------------------------"
605.endfor
606
607#
608# installkernel, etc.
609#
610# Install the kernel defined by INSTALLKERNEL
611#
612installkernel installkernel.debug \
613reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
614.if empty(INSTALLKERNEL)
615	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
616	false
617.endif
618	@echo "--------------------------------------------------------------"
619	@echo ">>> Making hierarchy"
620	@echo "--------------------------------------------------------------"
621	cd ${.CURDIR}; \
622	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
623	@echo
624	@echo "--------------------------------------------------------------"
625	@echo ">>> Installing kernel"
626	@echo "--------------------------------------------------------------"
627	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
628	    ${CROSSENV} PATH=${TMPPATH} \
629	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
630
631#
632# update
633#
634# Update the source tree, by running sup and/or running cvs to update to the
635# latest copy.
636#
637update:
638.if defined(SUP_UPDATE)
639	@echo "--------------------------------------------------------------"
640	@echo ">>> Running ${SUP}"
641	@echo "--------------------------------------------------------------"
642.if defined(SUPFILE)
643	@${SUP} ${SUPFLAGS} ${SUPFILE}
644.endif
645.if defined(SUPFILE1)
646	@${SUP} ${SUPFLAGS} ${SUPFILE1}
647.endif
648.if defined(SUPFILE2)
649	@${SUP} ${SUPFLAGS} ${SUPFILE2}
650.endif
651.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
652	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
653.endif
654.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
655	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
656.endif
657.endif
658.if defined(CVS_UPDATE)
659	@echo "--------------------------------------------------------------"
660	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
661	@echo "--------------------------------------------------------------"
662	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
663.endif
664
665#
666# ------------------------------------------------------------------------
667#
668# From here onwards are utility targets used by the 'make world' and
669# related targets.  If your 'world' breaks, you may like to try to fix
670# the problem and manually run the following targets to attempt to
671# complete the build.  Beware, this is *not* guaranteed to work, you
672# need to have a pretty good grip on the current state of the system
673# to attempt to manually finish it.  If in doubt, 'make world' again.
674#
675
676#
677# legacy: Build compatibility shims for the next three targets
678#
679legacy:
680.for _tool in tools/build
681	${_+_}@${ECHODIR} "===> ${_tool}"; \
682	    cd ${.CURDIR}/${_tool}; \
683	    ${MAKE} DIRPRFX=${_tool}/ obj; \
684	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
685	    ${MAKE} DIRPRFX=${_tool}/ depend; \
686	    ${MAKE} DIRPRFX=${_tool}/ all; \
687	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
688.endfor
689
690#
691# bootstrap-tools: Build tools needed for compatibility
692#
693.if !defined(NOGAMES)
694_strfile=	games/fortune/strfile
695.endif
696
697.if !defined(NO_CXX)
698_gperf=	gnu/usr.bin/gperf
699.if ${BOOTSTRAPPING} < 500113
700_groff=		gnu/usr.bin/groff
701.else
702_groff=		gnu/usr.bin/groff/tmac
703.endif
704.endif
705
706.if ${BOOTSTRAPPING} < 502102
707_lex=		usr.bin/lex
708.endif
709
710.if ${BOOTSTRAPPING} < 450005 || \
711    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
712_uudecode=	usr.bin/uudecode
713.endif
714
715.if ${BOOTSTRAPPING} < 430002 || \
716    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
717_xargs=		usr.bin/xargs
718.endif
719
720.if ${BOOTSTRAPPING} < 430002 || \
721    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
722_yacc=		usr.bin/yacc
723.endif
724
725.if !defined(NO_RESCUE) && \
726    ${BOOTSTRAPPING} < 502128
727_crunchgen=	usr.sbin/crunch/crunchgen
728.endif
729
730.if ${BOOTSTRAPPING} < 502128
731_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
732.endif
733
734.if ${BOOTSTRAPPING} < 500019
735_kbdcontrol=	usr.sbin/kbdcontrol
736.endif
737
738bootstrap-tools:
739.for _tool in \
740    ${_strfile} \
741    ${_gperf} \
742    ${_groff} \
743    gnu/usr.bin/texinfo \
744    usr.bin/colldef \
745    ${_lex} \
746    usr.bin/makewhatis \
747    usr.bin/rpcgen \
748    ${_uudecode} \
749    ${_xargs} \
750    usr.bin/xinstall \
751    ${_yacc} \
752    usr.sbin/config \
753    ${_crunchgen} \
754    ${_gensnmptree} \
755    ${_kbdcontrol}
756	${_+_}@${ECHODIR} "===> ${_tool}"; \
757		cd ${.CURDIR}/${_tool}; \
758		${MAKE} DIRPRFX=${_tool}/ obj; \
759		${MAKE} DIRPRFX=${_tool}/ depend; \
760		${MAKE} DIRPRFX=${_tool}/ all; \
761		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
762.endfor
763
764#
765# build-tools: Build special purpose build tools
766#
767.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
768_aicasm= sys/modules/aic7xxx/aicasm
769.endif
770
771.if !defined(NOSHARE)
772_share=	share/syscons/scrnmaps
773.endif
774
775.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
776_kerberos5_tools= kerberos5/tools
777.endif
778
779.if !defined(NO_RESCUE)
780_rescue= rescue/rescue
781.endif
782
783build-tools:
784.for _tool in \
785    bin/csh \
786    bin/sh \
787    ${_rescue} \
788    lib/libncurses \
789    ${_share} \
790    ${_aicasm} \
791    usr.bin/awk \
792    lib/libmagic \
793    usr.sbin/sysinstall
794	${_+_}@${ECHODIR} "===> ${_tool}"; \
795		cd ${.CURDIR}/${_tool}; \
796		${MAKE} DIRPRFX=${_tool}/ obj; \
797		${MAKE} DIRPRFX=${_tool}/ build-tools
798.endfor
799.for _tool in \
800    gnu/usr.bin/cc/cc_tools \
801    ${_kerberos5_tools}
802	${_+_}@${ECHODIR} "===> ${_tool}"; \
803		cd ${.CURDIR}/${_tool}; \
804		${MAKE} DIRPRFX=${_tool}/ obj; \
805		${MAKE} DIRPRFX=${_tool}/ depend; \
806		${MAKE} DIRPRFX=${_tool}/ all
807.endfor
808
809#
810# cross-tools: Build cross-building tools
811#
812.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
813    ${BOOTSTRAPPING} < 500037
814_elf2aout=	usr.bin/elf2aout
815.endif
816
817.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
818_btxld=		usr.sbin/btxld
819.endif
820
821.if (!defined(NO_RESCUE) || \
822    defined(RELEASEDIR)) && \
823    (${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 501101)
824_crunchide=	usr.sbin/crunch/crunchide
825.endif
826
827.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
828_elf2exe=	usr.sbin/elf2exe
829.endif
830
831.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
832    defined(RELEASEDIR)
833_kgzip=		usr.sbin/kgzip
834.endif
835
836cross-tools:
837.for _tool in \
838    gnu/usr.bin/binutils \
839    gnu/usr.bin/cc \
840    ${_elf2aout} \
841    usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
842    ${_btxld} \
843    ${_crunchide} \
844    ${_elf2exe} \
845    ${_kgzip}
846	${_+_}@${ECHODIR} "===> ${_tool}"; \
847		cd ${.CURDIR}/${_tool}; \
848		${MAKE} DIRPRFX=${_tool}/ obj; \
849		${MAKE} DIRPRFX=${_tool}/ depend; \
850		${MAKE} DIRPRFX=${_tool}/ all; \
851		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
852.endfor
853
854#
855# hierarchy - ensure that all the needed directories are present
856#
857hierarchy:
858	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
859
860#
861# libraries - build all libraries, and install them under ${DESTDIR}.
862#
863# The list of libraries with dependents (${_prebuild_libs}) and their
864# interdependencies (__L) are built automatically by the
865# ${.CURDIR}/tools/make_libdeps.sh script.
866#
867libraries:
868	cd ${.CURDIR}; \
869	    ${MAKE} -f Makefile.inc1 _startup_libs; \
870	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
871	    ${MAKE} -f Makefile.inc1 _generic_libs;
872
873# These dependencies are not automatically generated:
874#
875# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
876# shared libraries for ELF.
877#
878_startup_libs=	gnu/lib/csu gnu/lib/libgcc
879.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
880_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
881.else
882_startup_libs+=	lib/csu/${MACHINE_ARCH}
883.endif
884
885_prebuild_libs=
886
887_generic_libs=	gnu/lib
888
889.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
890_prebuild_libs+=	kerberos5/lib/libasn1
891_prebuild_libs+=	kerberos5/lib/libgssapi
892_prebuild_libs+=	kerberos5/lib/libkrb5
893_prebuild_libs+=	kerberos5/lib/libroken
894_generic_libs+=	kerberos5/lib
895.endif
896
897_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
898		lib/libkvm lib/libmd \
899		lib/libncurses lib/libnetgraph lib/libopie lib/libpam \
900		lib/libradius \
901		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
902		lib/libz lib/msun
903
904lib/libopie__L lib/libtacplus__L: lib/libmd__L
905
906_generic_libs+=	lib
907
908.if !defined(NOCRYPT)
909.if !defined(NO_OPENSSL)
910_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
911lib/libradius__L: secure/lib/libssl__L
912secure/lib/libssl__L: secure/lib/libcrypto__L
913.if !defined(NO_OPENSSH)
914_prebuild_libs+=	secure/lib/libssh
915secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
916.if !defined(NO_KERBEROS)
917secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
918    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
919    kerberos5/lib/libroken__L
920.endif
921.endif
922.endif
923_generic_libs+=	secure/lib
924.endif
925
926.if defined(NOCRYPT) || defined(NO_OPENSSL)
927lib/libradius__L: lib/libmd__L
928.endif
929
930_generic_libs+=	usr.bin/lex/lib
931
932.if ${MACHINE_ARCH} == "i386"
933_generic_libs+=	usr.sbin/pcvt/keycap
934.endif
935
936.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
937${_lib}__L: .PHONY
938.if exists(${.CURDIR}/${_lib})
939	${_+_}@${ECHODIR} "===> ${_lib}"; \
940		cd ${.CURDIR}/${_lib}; \
941		${MAKE} DIRPRFX=${_lib}/ depend; \
942		${MAKE} DIRPRFX=${_lib}/ all; \
943		${MAKE} DIRPRFX=${_lib}/ install
944.endif
945.endfor
946
947# libpam is special: we need to build static PAM modules before
948# static PAM library, and dynamic PAM library before dynamic PAM
949# modules.
950lib/libpam__L: .PHONY
951	${_+_}@${ECHODIR} "===> lib/libpam"; \
952		cd ${.CURDIR}/lib/libpam; \
953		${MAKE} DIRPRFX=lib/libpam/ depend; \
954		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
955		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
956
957_startup_libs: ${_startup_libs:S/$/__L/}
958_prebuild_libs: ${_prebuild_libs:S/$/__L/}
959_generic_libs: ${_generic_libs:S/$/__L/}
960
961.for __target in all clean cleandepend cleandir depend includes obj
962.for entry in ${SUBDIR}
963${entry}.${__target}__D: .PHONY
964	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
965		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
966		edir=${entry}.${MACHINE_ARCH}; \
967		cd ${.CURDIR}/$${edir}; \
968	else \
969		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
970		edir=${entry}; \
971		cd ${.CURDIR}/$${edir}; \
972	fi; \
973	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
974.endfor
975par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
976.endfor
977
978.include <bsd.subdir.mk>
979