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