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