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