Makefile.inc1 revision 116005
1#
2# $FreeBSD: head/Makefile.inc1 116005 2003-06-08 04:15:05Z imp $
3#
4# Make command line options:
5#	-DNO_KERBEROS Do not build Heimdal (Kerberos 5)
6#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
7#	-DNOCLEAN do not clean at all
8#	-DNOCRYPT will prevent building of crypt versions
9#	-DNOMAN do not build the manual pages
10#	-DNOPROFILE do not build profiled libraries
11#	-DNOGAMES do not go into games subdir
12#	-DNOSHARE do not go into share subdir
13#	-DNOINFO do not make or install info files
14#	-DNOLIBC_R do not build libc_r.
15#	-DNO_FORTRAN do not build g77 and related libraries.
16#	-DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
17#	-DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
18#	-DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
19#	-DNO_PORTSUPDATE do not update ports in ${MAKE} update
20#	-DNO_DOCUPDATE do not update doc in ${MAKE} update
21#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
22#	TARGET_ARCH="arch" to crossbuild world to a different arch
23
24#
25# The intended user-driven targets are:
26# buildworld  - rebuild *everything*, including glue to help do upgrades
27# installworld- install everything built by "buildworld"
28# update      - convenient way to update your source tree (eg: sup/cvs)
29# most        - build user commands, no libraries or include files
30# installmost - install user commands, no libraries or include files
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# Put initial settings here.
37SUBDIR=
38
39# We must do share/info early so that installation of info `dir'
40# entries works correctly.  Do it first since it is less likely to
41# grow dependencies on include and lib than vice versa.
42.if exists(${.CURDIR}/share/info)
43SUBDIR+= share/info
44.endif
45
46.if exists(${.CURDIR}/include)
47SUBDIR+= include
48.endif
49.if exists(${.CURDIR}/lib)
50SUBDIR+= lib
51.endif
52
53.if exists(${.CURDIR}/bin)
54SUBDIR+= bin
55.endif
56.if exists(${.CURDIR}/games) && !defined(NOGAMES)
57SUBDIR+= games
58.endif
59.if exists(${.CURDIR}/gnu)
60SUBDIR+= gnu
61.endif
62.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
63    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
64SUBDIR+= kerberos5
65.endif
66.if exists(${.CURDIR}/libexec)
67SUBDIR+= libexec
68.endif
69.if exists(${.CURDIR}/sbin)
70SUBDIR+= sbin
71.endif
72.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
73SUBDIR+= secure
74.endif
75.if exists(${.CURDIR}/share) && !defined(NOSHARE)
76SUBDIR+= share
77.endif
78.if exists(${.CURDIR}/sys)
79SUBDIR+= sys
80.endif
81.if exists(${.CURDIR}/usr.bin)
82SUBDIR+= usr.bin
83.endif
84.if exists(${.CURDIR}/usr.sbin)
85SUBDIR+= usr.sbin
86.endif
87
88# etc must be last for "distribute" to work
89.if exists(${.CURDIR}/etc)
90SUBDIR+= etc
91.endif
92
93# These are last, since it is nice to at least get the base system
94# rebuilt before you do them.
95.if defined(LOCAL_DIRS)
96.for _DIR in ${LOCAL_DIRS}
97.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
98SUBDIR+= ${_DIR}
99.endif
100.endfor
101.endif
102
103.if defined(SUBDIR_OVERRIDE)
104SUBDIR=		${SUBDIR_OVERRIDE}
105.endif
106
107.if defined(NOCLEANDIR)
108CLEANDIR=	clean cleandepend
109.else
110CLEANDIR=	cleandir
111.endif
112
113CVS?=		cvs
114SUP?=		/usr/local/bin/cvsup
115SUPFLAGS?=	-g -L 2 -P -
116.if defined(SUPHOST)
117SUPFLAGS+=	-h ${SUPHOST}
118.endif
119
120MAKEOBJDIRPREFIX?=	/usr/obj
121.if !defined(OSRELDATE)
122OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
123		/usr/include/osreldate.h
124.endif
125TARGET_ARCH?=	${MACHINE_ARCH}
126.if ${TARGET_ARCH} == ${MACHINE_ARCH}
127TARGET?=	${MACHINE}
128TARGET_CPUTYPE?=${CPUTYPE}
129.else
130TARGET?=	${TARGET_ARCH}
131TARGET_CPUTYPE?=
132.endif
133.if !empty(TARGET_CPUTYPE)
134_TARGET_CPUTYPE=${TARGET_CPUTYPE}
135.else
136_TARGET_CPUTYPE=dummy
137.endif
138_CPUTYPE!=	${MAKE} -f /dev/null -m ${.CURDIR}/share/mk \
139		CPUTYPE=${_TARGET_CPUTYPE} -V CPUTYPE
140.if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
141.error CPUTYPE global should be set with ?=.
142.endif
143.if make(buildworld)
144BUILD_ARCH!=	sysctl -n hw.machine_arch
145.if ${MACHINE_ARCH} != ${BUILD_ARCH}
146.error To cross-build, set TARGET_ARCH.
147.endif
148.endif
149.if ${MACHINE} == ${TARGET}
150OBJTREE=	${MAKEOBJDIRPREFIX}
151.else
152OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
153.endif
154WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
155# /usr/games added for fortune which depend on strfile
156BPATH=		${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
157XPATH=		${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
158STRICTTMPPATH=	${BPATH}:${XPATH}
159TMPPATH=	${STRICTTMPPATH}:${PATH}
160
161INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
162
163#
164# Building a world goes through the following stages
165#
166# 1. legacy stage [BMAKE]
167#	This stage is responsible for creating compatibility
168#	shims that are needed by the bootstrap-tools,
169#	build-tools and cross-tools stages.
170# 1. bootstrap-tools stage [BMAKE]
171#	This stage is responsible for creating programs that
172#	are needed for backward compatibility reasons. They
173#	are not built as cross-tools.
174# 2. build-tools stage [TMAKE]
175#	This stage is responsible for creating the object
176#	tree and building any tools that are needed during
177#	the build process.
178# 3. cross-tools stage [XMAKE]
179#	This stage is responsible for creating any tools that
180#	are needed for cross-builds. A cross-compiler is one
181#	of them.
182# 4. world stage [WMAKE]
183#	This stage actually builds the world.
184# 5. install stage (optional) [IMAKE]
185#	This stage installs a previously built world.
186#
187
188BOOTSTRAPPING?=	0
189
190# Common environment for world related stages
191CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
192		MACHINE_ARCH=${TARGET_ARCH} \
193		MACHINE=${TARGET} \
194		CPUTYPE=${TARGET_CPUTYPE} \
195		GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
196		GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
197		GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
198
199# bootstrap-tools stage
200BMAKEENV=	DESTDIR= \
201		INSTALL="sh ${.CURDIR}/tools/install.sh" \
202		PATH=${BPATH}:${PATH} \
203		WORLDTMP=${WORLDTMP} \
204		MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
205.if ${BOOTSTRAPPING} < 501100
206BMAKEENV+=	CSTD=
207.endif
208BMAKE=		MAKEOBJDIRPREFIX=${WORLDTMP} \
209		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
210		BOOTSTRAPPING=${OSRELDATE} \
211		-DNOHTML -DNOINFO -DNOLINT -DNOMAN -DNOPIC -DNOPROFILE \
212		-DNOSHARED -DNO_CPU_CFLAGS -DNO_WARNS
213
214# build-tools stage
215TMAKE=		MAKEOBJDIRPREFIX=${OBJTREE} \
216		${BMAKEENV} ${MAKE} -f Makefile.inc1 \
217		BOOTSTRAPPING=${OSRELDATE} -DNOLINT -DNO_CPU_CFLAGS -DNO_WARNS
218
219# cross-tools stage
220XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
221
222# world stage
223WMAKEENV=	${CROSSENV} \
224		DESTDIR=${WORLDTMP} \
225		INSTALL="sh ${.CURDIR}/tools/install.sh" \
226		PATH=${TMPPATH}
227WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
228
229# install stage
230IMAKEENV=	${CROSSENV} \
231		PATH=${STRICTTMPPATH}:${INSTALLTMP}
232IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
233
234# kernel stage
235KMAKEENV=	${WMAKEENV}
236
237#
238# buildworld
239#
240# Attempt to rebuild the entire system, with reasonable chance of
241# success, regardless of how old your existing system is.
242#
243_worldtmp:
244.if ${.CURDIR:C/[^,]//g} != ""
245#	The m4 build of sendmail files doesn't like it if ',' is used
246#	anywhere in the path of it's files.
247	@echo
248	@echo "*** Error: path to source tree contains a comma ','"
249	@echo
250	@false
251.endif
252	@echo
253	@echo "--------------------------------------------------------------"
254	@echo ">>> Rebuilding the temporary build tree"
255	@echo "--------------------------------------------------------------"
256.if !defined(NOCLEAN)
257	rm -rf ${WORLDTMP}
258.else
259	rm -rf ${WORLDTMP}/legacy/usr/include
260	# XXX - These two can depend on any header file.
261	rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
262	rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
263.endif
264.for _dir in \
265    usr/bin usr/games usr/include/sys usr/lib \
266    usr/libexec usr/sbin usr/share/dict \
267    usr/share/groff_font/devX100 \
268    usr/share/groff_font/devX100-12 \
269    usr/share/groff_font/devX75 \
270    usr/share/groff_font/devX75-12 \
271    usr/share/groff_font/devascii \
272    usr/share/groff_font/devcp1047 \
273    usr/share/groff_font/devdvi \
274    usr/share/groff_font/devhtml \
275    usr/share/groff_font/devkoi8-r \
276    usr/share/groff_font/devlatin1 \
277    usr/share/groff_font/devlbp \
278    usr/share/groff_font/devlj4 \
279    usr/share/groff_font/devps \
280    usr/share/groff_font/devutf8 \
281    usr/share/tmac/mdoc usr/share/tmac/mm
282	mkdir -p ${WORLDTMP}/legacy/${_dir}
283.endfor
284.for _dir in \
285    usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
286    usr/libexec usr/share/misc
287	mkdir -p ${WORLDTMP}/${_dir}
288.endfor
289	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
290	    -p ${WORLDTMP}/usr/include
291	ln -sf ${.CURDIR}/sys ${WORLDTMP}
292_legacy:
293	@echo
294	@echo "--------------------------------------------------------------"
295	@echo ">>> stage 1: legacy release compatibility shims"
296	@echo "--------------------------------------------------------------"
297	cd ${.CURDIR}; ${BMAKE} legacy
298_bootstrap-tools:
299	@echo
300	@echo "--------------------------------------------------------------"
301	@echo ">>> stage 1: bootstrap tools"
302	@echo "--------------------------------------------------------------"
303	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
304_cleanobj:
305.if !defined(NOCLEAN)
306	@echo
307	@echo "--------------------------------------------------------------"
308	@echo ">>> stage 2: cleaning up the object tree"
309	@echo "--------------------------------------------------------------"
310	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
311.endif
312_obj:
313	@echo
314	@echo "--------------------------------------------------------------"
315	@echo ">>> stage 2: rebuilding the object tree"
316	@echo "--------------------------------------------------------------"
317	cd ${.CURDIR}; ${WMAKE} par-obj
318_build-tools:
319	@echo
320	@echo "--------------------------------------------------------------"
321	@echo ">>> stage 2: build tools"
322	@echo "--------------------------------------------------------------"
323	cd ${.CURDIR}; ${TMAKE} build-tools
324_cross-tools:
325	@echo
326	@echo "--------------------------------------------------------------"
327	@echo ">>> stage 3: cross tools"
328	@echo "--------------------------------------------------------------"
329	cd ${.CURDIR}; ${XMAKE} cross-tools
330_includes:
331	@echo
332	@echo "--------------------------------------------------------------"
333	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
334	@echo "--------------------------------------------------------------"
335	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
336_libraries:
337	@echo
338	@echo "--------------------------------------------------------------"
339	@echo ">>> stage 4: building libraries"
340	@echo "--------------------------------------------------------------"
341	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
342_depend:
343	@echo
344	@echo "--------------------------------------------------------------"
345	@echo ">>> stage 4: make dependencies"
346	@echo "--------------------------------------------------------------"
347	cd ${.CURDIR}; ${WMAKE} par-depend
348everything:
349	@echo
350	@echo "--------------------------------------------------------------"
351	@echo ">>> stage 4: building everything.."
352	@echo "--------------------------------------------------------------"
353	cd ${.CURDIR}; ${WMAKE} par-all
354
355
356WMAKE_TGTS=
357.if !defined(SUBDIR_OVERRIDE)
358WMAKE_TGTS+=	_worldtmp _legacy _bootstrap-tools
359.endif
360WMAKE_TGTS+=	_cleanobj _obj _build-tools
361.if !defined(SUBDIR_OVERRIDE)
362WMAKE_TGTS+=	_cross-tools
363.endif
364WMAKE_TGTS+=	_includes _libraries _depend everything
365
366buildworld: ${WMAKE_TGTS}
367.ORDER: ${WMAKE_TGTS}
368
369#
370# installcheck
371#
372# Checks to be sure system is ready for installworld
373#
374installcheck:
375.if !defined(NO_SENDMAIL)
376	@if ! `grep -q '^smmsp:' /etc/passwd`; then \
377		echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
378		false; \
379	fi
380	@if ! `grep -q '^smmsp:' /etc/group`; then \
381		echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
382		false; \
383	fi
384.endif
385.if ${TARGET_ARCH} == ${MACHINE_ARCH} && !defined(DISTDIR) && \
386    (!defined(DESTDIR) || empty(DESTDIR) || ${DESTDIR} == "/")
387	@echo "Checking to see if your booted kernel is fresh enough.."
388	${.OBJDIR}/bin/sh/sh -c \
389	    'echo "Testing installed kernel for new sigaction(2) syscall"'
390	@echo "Seems ok.."
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:
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 ${BOOTSTRAPPING} < 500019
671_kbdcontrol=	usr.sbin/kbdcontrol
672.endif
673
674bootstrap-tools:
675.for _tool in ${_strfile} usr.bin/colldef \
676    usr.bin/makewhatis usr.bin/rpcgen ${_uudecode} \
677    ${_xargs} usr.bin/xinstall ${_yacc} \
678    usr.sbin/config ${_kbdcontrol} \
679    ${_gperf} ${_groff} gnu/usr.bin/texinfo
680	@${ECHODIR} "===> ${_tool}"; \
681		cd ${.CURDIR}/${_tool}; \
682		${MAKE} DIRPRFX=${_tool}/ obj; \
683		${MAKE} DIRPRFX=${_tool}/ depend; \
684		${MAKE} DIRPRFX=${_tool}/ all; \
685		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
686.endfor
687
688#
689# build-tools: Build special purpose build tools
690#
691.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
692_aicasm= sys/modules/aic7xxx/aicasm
693.endif
694
695.if exists(${.CURDIR}/share) && !defined(NOSHARE)
696_share=	share/syscons/scrnmaps
697.endif
698
699.if !defined(NO_FORTRAN)
700_fortran= gnu/usr.bin/cc/f771
701.endif
702
703.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
704    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
705_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
706    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
707.endif
708
709build-tools:
710.for _tool in bin/csh bin/sh gnu/usr.bin/cc/cc_tools ${_fortran} \
711    ${_libkrb5} lib/libncurses ${_share} \
712    ${_aicasm} usr.bin/awk usr.bin/file usr.sbin/sysinstall
713	@${ECHODIR} "===> ${_tool}"; \
714		cd ${.CURDIR}/${_tool}; \
715		${MAKE} DIRPRFX=${_tool}/ obj; \
716		${MAKE} DIRPRFX=${_tool}/ build-tools
717.endfor
718
719#
720# cross-tools: Build cross-building tools
721#
722.if ${TARGET_ARCH} == "alpha" && ${TARGET_ARCH} != ${MACHINE_ARCH}
723_elf2exe=	usr.sbin/elf2exe
724.endif
725
726.if ${TARGET_ARCH} == "i386" && ${TARGET_ARCH} != ${MACHINE_ARCH}
727_btxld=	usr.sbin/btxld
728.if defined(RELEASEDIR)
729_kgzip=	usr.sbin/kgzip
730.endif
731.endif
732
733.if ${TARGET_ARCH} == "sparc64" && ${TARGET_ARCH} != ${MACHINE_ARCH} && \
734    ${BOOTSTRAPPING} < 500037
735_elf2aout=	usr.bin/elf2aout
736.endif
737
738.if defined(RELEASEDIR)
739_crunchide=	usr.sbin/crunch/crunchide
740.endif
741
742_xlint=	usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
743
744cross-tools:
745.for _tool in ${_btxld} ${_elf2aout} ${_elf2exe} \
746    gnu/usr.bin/binutils ${_crunchide} \
747    gnu/usr.bin/cc ${_xlint} ${_kgzip}
748	@${ECHODIR} "===> ${_tool}"; \
749		cd ${.CURDIR}/${_tool}; \
750		${MAKE} DIRPRFX=${_tool}/ obj; \
751		${MAKE} DIRPRFX=${_tool}/ depend; \
752		${MAKE} DIRPRFX=${_tool}/ all; \
753		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
754.endfor
755
756#
757# hierarchy - ensure that all the needed directories are present
758#
759hierarchy:
760	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
761
762#
763# libraries - build all libraries, and install them under ${DESTDIR}.
764#
765# The list of libraries with dependents (${_prebuild_libs}) and their
766# interdependencies (__L) are built automatically by the
767# ${.CURDIR}/tools/make_libdeps.sh script.
768#
769libraries:
770	cd ${.CURDIR}; \
771	    ${MAKE} -f Makefile.inc1 _startup_libs; \
772	    ${MAKE} -f Makefile.inc1 _prebuild_libs; \
773	    ${MAKE} -f Makefile.inc1 _generic_libs;
774
775# These dependencies are not automatically generated:
776#
777# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
778# shared libraries for ELF.
779#
780_startup_libs=	gnu/lib/csu gnu/lib/libgcc
781.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
782_startup_libs+=	lib/csu/${MACHINE_ARCH}-elf
783.else
784_startup_libs+=	lib/csu/${MACHINE_ARCH}
785.endif
786
787_prebuild_libs+= lib/libc
788_generic_libs=	gnu/lib
789
790.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
791    !defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
792_prebuild_libs+=	kerberos5/lib/libasn1
793_prebuild_libs+=	kerberos5/lib/libgssapi
794_prebuild_libs+=	kerberos5/lib/libkrb5
795_prebuild_libs+=	kerberos5/lib/libroken
796_generic_libs+=	kerberos5/lib
797.endif
798
799_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
800		lib/libkvm lib/libmd \
801		lib/libncurses lib/libopie lib/libpam lib/libradius \
802		lib/librpcsvc \
803		lib/libsbuf lib/libtacplus lib/libutil lib/libypclnt \
804		lib/libz lib/msun
805
806lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
807lib/libypclnt__L: lib/librpcsvc__L
808
809_generic_libs+=	lib
810
811.if !defined(NOCRYPT)
812.if !defined(NO_OPENSSL)
813_prebuild_libs+=	secure/lib/libcrypto secure/lib/libssl
814.if !defined(NO_OPENSSH)
815_prebuild_libs+=	secure/lib/libssh
816secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
817.endif
818.endif
819_generic_libs+=	secure/lib
820.endif
821
822_generic_libs+=	usr.bin/lex/lib
823
824.if ${MACHINE_ARCH} == "i386"
825_generic_libs+=	usr.sbin/pcvt/keycap
826.endif
827
828.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
829${_lib}__L: .PHONY
830.if exists(${.CURDIR}/${_lib})
831	@${ECHODIR} "===> ${_lib}"; \
832		cd ${.CURDIR}/${_lib}; \
833		${MAKE} DIRPRFX=${_lib}/ depend; \
834		${MAKE} DIRPRFX=${_lib}/ all; \
835		${MAKE} DIRPRFX=${_lib}/ install
836.endif
837.endfor
838
839# libpam is special: we need to build static PAM modules before
840# static PAM library, and dynamic PAM library before dynamic PAM
841# modules.
842lib/libpam__L: .PHONY
843	@${ECHODIR} "===> lib/libpam"; \
844		cd ${.CURDIR}/lib/libpam; \
845		${MAKE} DIRPRFX=lib/libpam/ depend; \
846		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
847		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
848
849_startup_libs: ${_startup_libs:S/$/__L/}
850_prebuild_libs: ${_prebuild_libs:S/$/__L/}
851_generic_libs: ${_generic_libs:S/$/__L/}
852
853.for __target in all clean cleandepend cleandir depend includes obj
854.for entry in ${SUBDIR}
855${entry}.${__target}__D: .PHONY
856	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
857		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
858		edir=${entry}.${MACHINE_ARCH}; \
859		cd ${.CURDIR}/$${edir}; \
860	else \
861		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
862		edir=${entry}; \
863		cd ${.CURDIR}/$${edir}; \
864	fi; \
865	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
866.endfor
867par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
868.endfor
869
870.include <bsd.subdir.mk>
871