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