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