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