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