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