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