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