Makefile.inc1 revision 133942
1#
2# $FreeBSD: head/Makefile.inc1 133942 2004-08-18 06:49:56Z 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!=	MAKEFLAGS= ${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
204.if empty(.MAKEFLAGS:M-n)
205IMAKEENV=	${CROSSENV} \
206		PATH=${STRICTTMPPATH}:${INSTALLTMP}
207.else
208IMAKEENV=	${CROSSENV} \
209		PATH=${TMPPATH}:${INSTALLTMP}
210.endif
211IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
212
213# kernel stage
214KMAKEENV=	${WMAKEENV}
215
216#
217# buildworld
218#
219# Attempt to rebuild the entire system, with reasonable chance of
220# success, regardless of how old your existing system is.
221#
222_worldtmp:
223.if ${.CURDIR:C/[^,]//g} != ""
224#	The m4 build of sendmail files doesn't like it if ',' is used
225#	anywhere in the path of it's files.
226	@echo
227	@echo "*** Error: path to source tree contains a comma ','"
228	@echo
229	false
230.endif
231	@echo
232	@echo "--------------------------------------------------------------"
233	@echo ">>> Rebuilding the temporary build tree"
234	@echo "--------------------------------------------------------------"
235.if !defined(NOCLEAN)
236	rm -rf ${WORLDTMP}
237.else
238	rm -rf ${WORLDTMP}/legacy/usr/include
239	# XXX - These two can depend on any header file.
240	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
241	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
242.endif
243.for _dir in \
244    usr/bin usr/games usr/include/c++/3.3 usr/include/sys usr/lib \
245    usr/libexec usr/sbin usr/share/dict \
246    usr/share/groff_font/devX100 \
247    usr/share/groff_font/devX100-12 \
248    usr/share/groff_font/devX75 \
249    usr/share/groff_font/devX75-12 \
250    usr/share/groff_font/devascii \
251    usr/share/groff_font/devcp1047 \
252    usr/share/groff_font/devdvi \
253    usr/share/groff_font/devhtml \
254    usr/share/groff_font/devkoi8-r \
255    usr/share/groff_font/devlatin1 \
256    usr/share/groff_font/devlbp \
257    usr/share/groff_font/devlj4 \
258    usr/share/groff_font/devps \
259    usr/share/groff_font/devutf8 \
260    usr/share/tmac/mdoc usr/share/tmac/mm
261	mkdir -p ${WORLDTMP}/legacy/${_dir}
262.endfor
263.for _dir in \
264    lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
265    usr/libexec usr/sbin usr/share/misc \
266    usr/share/snmp/defs usr/share/snmp/mibs
267	mkdir -p ${WORLDTMP}/${_dir}
268.endfor
269	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
270	    -p ${WORLDTMP}/usr/include >/dev/null
271	ln -sf ${.CURDIR}/sys ${WORLDTMP}
272_legacy:
273	@echo
274	@echo "--------------------------------------------------------------"
275	@echo ">>> stage 1.1: legacy release compatibility shims"
276	@echo "--------------------------------------------------------------"
277	${_+_}cd ${.CURDIR}; ${BMAKE} legacy
278_bootstrap-tools:
279	@echo
280	@echo "--------------------------------------------------------------"
281	@echo ">>> stage 1.2: bootstrap tools"
282	@echo "--------------------------------------------------------------"
283	${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
284_cleanobj:
285.if !defined(NOCLEAN)
286	@echo
287	@echo "--------------------------------------------------------------"
288	@echo ">>> stage 2.1: cleaning up the object tree"
289	@echo "--------------------------------------------------------------"
290	${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
291.endif
292_obj:
293	@echo
294	@echo "--------------------------------------------------------------"
295	@echo ">>> stage 2.2: rebuilding the object tree"
296	@echo "--------------------------------------------------------------"
297	${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
298_build-tools:
299	@echo
300	@echo "--------------------------------------------------------------"
301	@echo ">>> stage 2.3: build tools"
302	@echo "--------------------------------------------------------------"
303	${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
304_cross-tools:
305	@echo
306	@echo "--------------------------------------------------------------"
307	@echo ">>> stage 3: cross tools"
308	@echo "--------------------------------------------------------------"
309	${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
310_includes:
311	@echo
312	@echo "--------------------------------------------------------------"
313	@echo ">>> stage 4.1: building includes"
314	@echo "--------------------------------------------------------------"
315	${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
316_libraries:
317	@echo
318	@echo "--------------------------------------------------------------"
319	@echo ">>> stage 4.2: building libraries"
320	@echo "--------------------------------------------------------------"
321	${_+_}cd ${.CURDIR}; \
322	    ${WMAKE} -DNOFSCHG -DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPROFILE \
323	    libraries
324_depend:
325	@echo
326	@echo "--------------------------------------------------------------"
327	@echo ">>> stage 4.3: make dependencies"
328	@echo "--------------------------------------------------------------"
329	${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
330everything:
331	@echo
332	@echo "--------------------------------------------------------------"
333	@echo ">>> stage 4.4: building everything"
334	@echo "--------------------------------------------------------------"
335	${_+_}cd ${.CURDIR}; ${WMAKE} par-all
336
337
338WMAKE_TGTS=
339.if !defined(SUBDIR_OVERRIDE)
340WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
341.endif
342WMAKE_TGTS+=	_cleanobj _obj _build-tools
343.if !defined(SUBDIR_OVERRIDE)
344WMAKE_TGTS+=	_cross-tools
345.endif
346WMAKE_TGTS+=	_includes _libraries _depend everything
347
348buildworld: ${WMAKE_TGTS}
349.ORDER: ${WMAKE_TGTS}
350
351TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything}
352toolchain: ${TOOLCHAIN_TGTS}
353kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
354
355#
356# Use this to add checks to installworld/installkernel targets.
357#
358SPECIAL_INSTALLCHECKS=
359
360#
361# The following install-time check will see if the installation will
362# change the type used for time_t, and if it will, the target makes
363# sure that the user is expecting to make that change.
364#
365.if ${TARGET_ARCH} == "sparc64"
366SPECIAL_INSTALLCHECKS+=sparc64_installcheck
367
368CUR_TIMET!=	grep __time_t /usr/include/machine/_types.h | awk '{print $$2}'
369SRC_TIMET!=	grep __time_t ${.CURDIR}/sys/sparc64/include/_types.h | \
370		awk '{print $$2}'
371NEWSPARC_TIMETYPE?=${CUR_TIMET}
372
373sparc64_installcheck:
374.if ${CUR_TIMET} != ${SRC_TIMET}
375	@echo
376.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
377	@echo "***  ERROR: This target would change the type used for time_t!"
378.else
379	@echo "* Note: This installation changes the type used for time_t."
380.endif
381	@echo "* "
382	@echo "* This host has time_t defined as ${CUR_TIMET},"
383	@echo "* and this installation would change that to type ${SRC_TIMET}."
384.if ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
385	@echo "* "
386	@echo "* If that is *NOT* what you wanted, then you need to change the"
387	@echo "* typedef of __time_t in ${.CURDIR}/sys/sparc64/include/_types.h"
388	@echo "* from '${SRC_TIMET}' to '${CUR_TIMET}'.  After that you *MUST*"
389	@echo "* do a complete cleanworld, buildworld, buildkernel before you"
390	@echo "* retry the 'make' command.  Also read /usr/src/UPDATING.64BTT."
391	@echo "* "
392	@echo "* If that *is* what you want, then enter the commands:"
393	@echo "      NEWSPARC_TIMETYPE=${SRC_TIMET}"
394	@echo "      export NEWSPARC_TIMETYPE"
395	@echo "* and repeat your 'make' command."
396	@echo
397	false
398.endif
399	@echo
400.elif ${NEWSPARC_TIMETYPE} != ${SRC_TIMET}
401	@echo
402	@echo "***  ERROR: NEWSPARC_TIMETYPE is set to '${NEWSPARC_TIMETYPE}'"
403	@echo "***         but ${.CURDIR}/sys/sparc64/include/_types.h"
404	@echo "***         has __time_t defined as '${SRC_TIMET}'."
405	false
406.else
407	@# in sparc64_installcheck, all TIMETYPEs == '${CUR_TIMET}'
408.endif
409.endif
410
411#
412# installcheck
413#
414# Checks to be sure system is ready for installworld
415#
416CHECK_UIDS=
417CHECK_GIDS=
418.if !defined(NO_SENDMAIL)
419CHECK_UIDS+=	smmsp
420CHECK_GIDS+=	smmsp
421.endif
422.if !defined(NO_PF)
423CHECK_UIDS+=	proxy
424CHECK_GIDS+=	proxy authpf
425.endif
426installcheck: ${SPECIAL_INSTALLCHECKS}
427.for uid in ${CHECK_UIDS}
428	@if ! `id -u ${uid} >/dev/null 2>&1`; then \
429		echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
430		false; \
431	fi
432.endfor
433.for gid in ${CHECK_GIDS}
434	@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
435		echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
436		false; \
437	fi
438.endfor
439
440#
441# distributeworld
442#
443# Distributes everything compiled by a `buildworld'.
444#
445# installworld
446#
447# Installs everything compiled by a 'buildworld'.
448#
449distributeworld installworld: installcheck
450	mkdir -p ${INSTALLTMP}
451	for prog in [ awk cap_mkdb cat chflags chmod chown \
452	    date echo egrep find grep \
453	    ln make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
454	    test true uname wc zic; do \
455		cp `which $$prog` ${INSTALLTMP}; \
456	done
457	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
458	rm -rf ${INSTALLTMP}
459
460#
461# reinstall
462#
463# If you have a build server, you can NFS mount the source and obj directories
464# and do a 'make reinstall' on the *client* to install new binaries from the
465# most recent server build.
466#
467reinstall: ${SPECIAL_INSTALLCHECKS}
468	@echo "--------------------------------------------------------------"
469	@echo ">>> Making hierarchy"
470	@echo "--------------------------------------------------------------"
471	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
472	@echo
473	@echo "--------------------------------------------------------------"
474	@echo ">>> Installing everything"
475	@echo "--------------------------------------------------------------"
476	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
477
478redistribute:
479	@echo "--------------------------------------------------------------"
480	@echo ">>> Distributing everything"
481	@echo "--------------------------------------------------------------"
482	${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
483
484#
485# buildkernel and installkernel
486#
487# Which kernels to build and/or install is specified by setting
488# KERNCONF. If not defined a GENERIC kernel is built/installed.
489# Only the existing (depending TARGET) config files are used
490# for building kernels and only the first of these is designated
491# as the one being installed.
492#
493# Note that we have to use TARGET instead of TARGET_ARCH when
494# we're in kernel-land. Since only TARGET_ARCH is (expected) to
495# be set to cross-build, we have to make sure TARGET is set
496# properly.
497
498.if !defined(KERNCONF) && defined(KERNEL)
499KERNCONF=	${KERNEL}
500KERNWARN=	yes
501.else
502KERNCONF?=	GENERIC
503.endif
504INSTKERNNAME?=	kernel
505
506KERNSRCDIR?=	${.CURDIR}/sys
507KRNLCONFDIR=	${KERNSRCDIR}/${TARGET}/conf
508KRNLOBJDIR=	${OBJTREE}${KERNSRCDIR}
509KERNCONFDIR?=	${KRNLCONFDIR}
510
511BUILDKERNELS=
512INSTALLKERNEL=
513.for _kernel in ${KERNCONF}
514.if exists(${KERNCONFDIR}/${_kernel})
515BUILDKERNELS+=	${_kernel}
516.if empty(INSTALLKERNEL)
517INSTALLKERNEL= ${_kernel}
518.endif
519.endif
520.endfor
521
522#
523# buildkernel
524#
525# Builds all kernels defined by BUILDKERNELS.
526#
527buildkernel:
528.if empty(BUILDKERNELS)
529	@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF}).";
530	false
531.endif
532.if defined(KERNWARN)
533	@echo "--------------------------------------------------------------"
534	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
535	@echo "--------------------------------------------------------------"
536	@sleep 3
537.endif
538	@echo
539.for _kernel in ${BUILDKERNELS}
540	@echo "--------------------------------------------------------------"
541	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
542	@echo "--------------------------------------------------------------"
543	@echo "===> ${_kernel}"
544	mkdir -p ${KRNLOBJDIR}
545.if !defined(NO_KERNELCONFIG)
546	@echo
547	@echo "--------------------------------------------------------------"
548	@echo ">>> stage 1: configuring the kernel"
549	@echo "--------------------------------------------------------------"
550	cd ${KRNLCONFDIR}; \
551		PATH=${TMPPATH} \
552		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
553			${KERNCONFDIR}/${_kernel}
554.endif
555.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
556	@echo
557	@echo "--------------------------------------------------------------"
558	@echo ">>> stage 2.1: cleaning up the object tree"
559	@echo "--------------------------------------------------------------"
560	cd ${KRNLOBJDIR}/${_kernel}; \
561	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} ${CLEANDIR}
562.endif
563	@echo
564	@echo "--------------------------------------------------------------"
565	@echo ">>> stage 2.2: rebuilding the object tree"
566	@echo "--------------------------------------------------------------"
567	cd ${KRNLOBJDIR}/${_kernel}; \
568	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} obj
569	@echo
570	@echo "--------------------------------------------------------------"
571	@echo ">>> stage 2.3: build tools"
572	@echo "--------------------------------------------------------------"
573	cd ${KRNLOBJDIR}/${_kernel}; \
574	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
575	    ${MAKE} -DNO_CPU_CFLAGS -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
576# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
577.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
578.for target in obj depend all
579	cd ${.CURDIR}/sys/modules/aic7xxx/aicasm; \
580	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
581	    ${MAKE} -DNO_CPU_CFLAGS ${target}
582.endfor
583.endif
584.if !defined(NO_KERNELDEPEND)
585	@echo
586	@echo "--------------------------------------------------------------"
587	@echo ">>> stage 3.1: making dependencies"
588	@echo "--------------------------------------------------------------"
589	cd ${KRNLOBJDIR}/${_kernel}; \
590	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend -DNO_MODULES_OBJ
591.endif
592	@echo
593	@echo "--------------------------------------------------------------"
594	@echo ">>> stage 3.2: building everything"
595	@echo "--------------------------------------------------------------"
596	cd ${KRNLOBJDIR}/${_kernel}; \
597	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all -DNO_MODULES_OBJ
598	@echo "--------------------------------------------------------------"
599	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
600	@echo "--------------------------------------------------------------"
601.endfor
602
603#
604# installkernel, etc.
605#
606# Install the kernel defined by INSTALLKERNEL
607#
608installkernel installkernel.debug \
609reinstallkernel reinstallkernel.debug: ${SPECIAL_INSTALLCHECKS}
610.if empty(INSTALLKERNEL)
611	@echo "ERROR: No kernel \"${KERNCONF}\" to install."
612	false
613.endif
614	@echo "--------------------------------------------------------------"
615	@echo ">>> Making hierarchy"
616	@echo "--------------------------------------------------------------"
617	cd ${.CURDIR}; \
618	    ${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
619	@echo
620	@echo "--------------------------------------------------------------"
621	@echo ">>> Installing kernel"
622	@echo "--------------------------------------------------------------"
623	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
624	    ${CROSSENV} PATH=${TMPPATH} \
625	    ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
626
627#
628# update
629#
630# Update the source tree, by running sup and/or running cvs to update to the
631# latest copy.
632#
633update:
634.if defined(SUP_UPDATE)
635	@echo "--------------------------------------------------------------"
636	@echo ">>> Running ${SUP}"
637	@echo "--------------------------------------------------------------"
638.if defined(SUPFILE)
639	@${SUP} ${SUPFLAGS} ${SUPFILE}
640.endif
641.if defined(SUPFILE1)
642	@${SUP} ${SUPFLAGS} ${SUPFILE1}
643.endif
644.if defined(SUPFILE2)
645	@${SUP} ${SUPFLAGS} ${SUPFILE2}
646.endif
647.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
648	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
649.endif
650.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
651	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
652.endif
653.endif
654.if defined(CVS_UPDATE)
655	@echo "--------------------------------------------------------------"
656	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
657	@echo "--------------------------------------------------------------"
658	cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
659.endif
660
661#
662# ------------------------------------------------------------------------
663#
664# From here onwards are utility targets used by the 'make world' and
665# related targets.  If your 'world' breaks, you may like to try to fix
666# the problem and manually run the following targets to attempt to
667# complete the build.  Beware, this is *not* guaranteed to work, you
668# need to have a pretty good grip on the current state of the system
669# to attempt to manually finish it.  If in doubt, 'make world' again.
670#
671
672#
673# legacy: Build compatibility shims for the next three targets
674#
675legacy:
676.for _tool in tools/build
677	${_+_}@${ECHODIR} "===> ${_tool}"; \
678	    cd ${.CURDIR}/${_tool}; \
679	    ${MAKE} DIRPRFX=${_tool}/ obj; \
680	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
681	    ${MAKE} DIRPRFX=${_tool}/ depend; \
682	    ${MAKE} DIRPRFX=${_tool}/ all; \
683	    ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
684.endfor
685
686#
687# bootstrap-tools: Build tools needed for compatibility
688#
689.if !defined(NOGAMES)
690_strfile=	games/fortune/strfile
691.endif
692
693.if !defined(NO_CXX)
694_gperf=	gnu/usr.bin/gperf
695.if ${BOOTSTRAPPING} < 500113
696_groff=		gnu/usr.bin/groff
697.else
698_groff=		gnu/usr.bin/groff/tmac
699.endif
700.endif
701
702.if ${BOOTSTRAPPING} < 502102
703_lex=		usr.bin/lex
704.endif
705
706.if ${BOOTSTRAPPING} < 450005 || \
707    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500034
708_uudecode=	usr.bin/uudecode
709.endif
710
711.if ${BOOTSTRAPPING} < 430002 || \
712    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500019
713_xargs=		usr.bin/xargs
714.endif
715
716.if ${BOOTSTRAPPING} < 430002 || \
717    ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500018
718_yacc=		usr.bin/yacc
719.endif
720
721.if !defined(NO_RESCUE) && \
722    ${BOOTSTRAPPING} < 502128
723_crunchgen=	usr.sbin/crunch/crunchgen
724.endif
725
726.if ${BOOTSTRAPPING} < 502128
727_gensnmptree=	usr.sbin/bsnmpd/gensnmptree
728.endif
729
730.if ${BOOTSTRAPPING} < 500019
731_kbdcontrol=	usr.sbin/kbdcontrol
732.endif
733
734bootstrap-tools:
735.for _tool in \
736    ${_strfile} \
737    ${_gperf} \
738    ${_groff} \
739    gnu/usr.bin/texinfo \
740    usr.bin/colldef \
741    ${_lex} \
742    usr.bin/makewhatis \
743    usr.bin/rpcgen \
744    ${_uudecode} \
745    ${_xargs} \
746    usr.bin/xinstall \
747    ${_yacc} \
748    usr.sbin/config \
749    ${_crunchgen} \
750    ${_gensnmptree} \
751    ${_kbdcontrol}
752	${_+_}@${ECHODIR} "===> ${_tool}"; \
753		cd ${.CURDIR}/${_tool}; \
754		${MAKE} DIRPRFX=${_tool}/ obj; \
755		${MAKE} DIRPRFX=${_tool}/ depend; \
756		${MAKE} DIRPRFX=${_tool}/ all; \
757		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
758.endfor
759
760#
761# build-tools: Build special purpose build tools
762#
763.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
764_aicasm= sys/modules/aic7xxx/aicasm
765.endif
766
767.if !defined(NOSHARE)
768_share=	share/syscons/scrnmaps
769.endif
770
771.if !defined(NO_KERBEROS) && !defined(NOCRYPT) && !defined(NO_OPENSSL)
772_kerberos5_tools= kerberos5/tools
773.endif
774
775.if !defined(NO_RESCUE)
776_rescue= rescue/rescue
777.endif
778
779build-tools:
780.for _tool in \
781    bin/csh \
782    bin/sh \
783    ${_rescue} \
784    gnu/usr.bin/cc/cc_tools \
785    lib/libncurses \
786    ${_share} \
787    ${_aicasm} \
788    usr.bin/awk \
789    lib/libmagic \
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 \
897		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
898		lib/libz lib/msun
899
900lib/libopie__L lib/libtacplus__L: lib/libmd__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
907lib/libradius__L: secure/lib/libssl__L
908secure/lib/libssl__L: secure/lib/libcrypto__L
909.if !defined(NO_OPENSSH)
910_prebuild_libs+=	secure/lib/libssh
911secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
912.if !defined(NO_KERBEROS)
913secure/lib/libssh__L: kerberos5/lib/libgssapi__L kerberos5/lib/libkrb5__L \
914    kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
915    kerberos5/lib/libroken__L
916.endif
917.endif
918.endif
919_generic_libs+=	secure/lib
920.endif
921
922.if defined(NOCRYPT) || defined(NO_OPENSSL)
923lib/libradius__L: lib/libmd__L
924.endif
925
926_generic_libs+=	usr.bin/lex/lib
927
928.if ${MACHINE_ARCH} == "i386"
929_generic_libs+=	usr.sbin/pcvt/keycap
930.endif
931
932.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
933${_lib}__L: .PHONY
934.if exists(${.CURDIR}/${_lib})
935	${_+_}@${ECHODIR} "===> ${_lib}"; \
936		cd ${.CURDIR}/${_lib}; \
937		${MAKE} DIRPRFX=${_lib}/ depend; \
938		${MAKE} DIRPRFX=${_lib}/ all; \
939		${MAKE} DIRPRFX=${_lib}/ install
940.endif
941.endfor
942
943# libpam is special: we need to build static PAM modules before
944# static PAM library, and dynamic PAM library before dynamic PAM
945# modules.
946lib/libpam__L: .PHONY
947	${_+_}@${ECHODIR} "===> lib/libpam"; \
948		cd ${.CURDIR}/lib/libpam; \
949		${MAKE} DIRPRFX=lib/libpam/ depend; \
950		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
951		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
952
953_startup_libs: ${_startup_libs:S/$/__L/}
954_prebuild_libs: ${_prebuild_libs:S/$/__L/}
955_generic_libs: ${_generic_libs:S/$/__L/}
956
957.for __target in all clean cleandepend cleandir depend includes obj
958.for entry in ${SUBDIR}
959${entry}.${__target}__D: .PHONY
960	${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
961		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
962		edir=${entry}.${MACHINE_ARCH}; \
963		cd ${.CURDIR}/$${edir}; \
964	else \
965		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
966		edir=${entry}; \
967		cd ${.CURDIR}/$${edir}; \
968	fi; \
969	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
970.endfor
971par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
972.endfor
973
974.include <bsd.subdir.mk>
975