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