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