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