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