Makefile.inc1 revision 94431
1#
2# $FreeBSD: head/Makefile.inc1 94431 2002-04-11 13:43:50Z ru $
3#
4# Make command line options:
5#	-DMAKE_KERBEROS4 to build KerberosIV
6#	-DMAKE_KERBEROS5 to build Kerberos5
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#	-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_PERL do not build perl5 and related libraries
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# most        - build user commands, no libraries or include files
32# installmost - install user commands, no libraries or include files
33#
34# Standard targets (not defined here) are documented in the makefiles in
35# /usr/share/mk.  These include:
36#		obj depend all install clean cleandepend cleanobj
37
38# Put initial settings here.
39SUBDIR=
40
41# We must do share/info early so that installation of info `dir'
42# entries works correctly.  Do it first since it is less likely to
43# grow dependencies on include and lib than vice versa.
44.if exists(${.CURDIR}/share/info)
45SUBDIR+= share/info
46.endif
47
48# We must do include and lib early so that the perl *.ph generation
49# works correctly as it uses the header files installed by this.
50.if exists(${.CURDIR}/include)
51SUBDIR+= include
52.endif
53.if exists(${.CURDIR}/lib)
54SUBDIR+= lib
55.endif
56
57.if exists(${.CURDIR}/bin)
58SUBDIR+= bin
59.endif
60.if exists(${.CURDIR}/games) && !defined(NOGAMES)
61SUBDIR+= games
62.endif
63.if exists(${.CURDIR}/gnu)
64SUBDIR+= gnu
65.endif
66.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
67    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
68SUBDIR+= kerberosIV
69.endif
70.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
71    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
72SUBDIR+= kerberos5
73.endif
74.if exists(${.CURDIR}/libexec)
75SUBDIR+= libexec
76.endif
77.if exists(${.CURDIR}/sbin)
78SUBDIR+= sbin
79.endif
80.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
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(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
125TARGET_ARCH?=	${MACHINE_ARCH}
126.if ${TARGET_ARCH} == ${MACHINE_ARCH}
127TARGET?=	${MACHINE}
128.else
129TARGET?=	${TARGET_ARCH}
130.endif
131.if make(buildworld)
132BUILD_ARCH!=	sysctl -n hw.machine_arch
133.if ${MACHINE_ARCH} != ${BUILD_ARCH}
134.error To cross-build, set TARGET_ARCH.
135.endif
136.endif
137.if ${MACHINE} == ${TARGET}
138OBJTREE=	${MAKEOBJDIRPREFIX}
139.else
140OBJTREE=	${MAKEOBJDIRPREFIX}/${TARGET}
141.endif
142WORLDTMP=	${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
143# /usr/games added for fortune which depend on strfile
144STRICTTMPPATH=	${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
145TMPPATH=	${STRICTTMPPATH}:${PATH}
146OBJFORMAT_PATH?=	/usr/libexec
147
148INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
149
150#
151# Building a world goes through the following stages
152#
153# 1. bootstrap-tool stage [BMAKE]
154#	This stage is responsible for creating programs that
155#	are needed for backward compatibility reasons. They
156#	are not built as cross-tools.
157# 2. build-tool stage [TMAKE]
158#	This stage is responsible for creating the object
159#	tree and building any tools that are needed during
160#	the build process.
161# 3. cross-tool stage [XMAKE]
162#	This stage is responsible for creating any tools that
163#	are needed for cross-builds. A cross-compiler is one
164#	of them.
165# 4. world stage [WMAKE]
166#	This stage actually builds the world.
167# 5. install stage (optional) [IMAKE]
168#	This stage installs a previously built world.
169#
170
171# Common environment for world related stages
172CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
173		MACHINE_ARCH=${TARGET_ARCH} \
174		MACHINE=${TARGET} \
175		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
176		PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.1 \
177		GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
178		GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
179		GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
180
181# bootstrap-tool stage
182BMAKEENV=	MAKEOBJDIRPREFIX=${WORLDTMP} \
183		DESTDIR= \
184		INSTALL="sh ${.CURDIR}/tools/install.sh"
185BMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
186		-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
187		-DNO_WERROR
188
189# build-tool stage
190TMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
191		DESTDIR= \
192		INSTALL="sh ${.CURDIR}/tools/install.sh"
193TMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING
194
195# cross-tool stage
196XMAKE=		TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
197
198# world stage
199WMAKEENV=	${CROSSENV} \
200		DESTDIR=${WORLDTMP} \
201		INSTALL="sh ${.CURDIR}/tools/install.sh" \
202		PATH=${TMPPATH}
203WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
204
205# install stage
206IMAKEENV=	${CROSSENV} \
207		PATH=${STRICTTMPPATH}:${INSTALLTMP}
208IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
209
210# kernel stage
211KMAKEENV=	${WMAKEENV} \
212		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
213
214USRDIRS=	usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
215		usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc \
216		usr/share/dict \
217		usr/share/groff_font/devX100 \
218		usr/share/groff_font/devX100-12 \
219		usr/share/groff_font/devX75 \
220		usr/share/groff_font/devX75-12 \
221		usr/share/groff_font/devascii \
222		usr/share/groff_font/devcp1047 \
223		usr/share/groff_font/devdvi \
224		usr/share/groff_font/devhtml \
225		usr/share/groff_font/devkoi8-r \
226		usr/share/groff_font/devlatin1 \
227		usr/share/groff_font/devlbp \
228		usr/share/groff_font/devlj4 \
229		usr/share/groff_font/devps \
230		usr/share/groff_font/devutf8 \
231		usr/share/tmac/mdoc usr/share/tmac/mm
232
233INCDIRS=	arpa dev fs g++/std isc isofs objc protocols \
234		readline rpc rpcsvc openssl security ufs
235
236#
237# buildworld
238#
239# Attempt to rebuild the entire system, with reasonable chance of
240# success, regardless of how old your existing system is.
241#
242buildworld:
243	@echo
244	@echo "--------------------------------------------------------------"
245	@echo ">>> Rebuilding the temporary build tree"
246	@echo "--------------------------------------------------------------"
247.if !defined(NOCLEAN)
248	rm -rf ${WORLDTMP}
249.endif
250.for _dir in ${USRDIRS}
251	mkdir -p ${WORLDTMP}/${_dir}
252.endfor
253.for _dir in ${INCDIRS}
254	mkdir -p ${WORLDTMP}/usr/include/${_dir}
255.endfor
256	ln -sf ${.CURDIR}/sys ${WORLDTMP}
257	@echo
258	@echo "--------------------------------------------------------------"
259	@echo ">>> stage 1: bootstrap tools"
260	@echo "--------------------------------------------------------------"
261	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
262.if !defined(NOCLEAN)
263	@echo
264	@echo "--------------------------------------------------------------"
265	@echo ">>> stage 2: cleaning up the object tree"
266	@echo "--------------------------------------------------------------"
267	cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
268.endif
269	@echo
270	@echo "--------------------------------------------------------------"
271	@echo ">>> stage 2: rebuilding the object tree"
272	@echo "--------------------------------------------------------------"
273	cd ${.CURDIR}; ${WMAKE} par-obj
274	@echo
275	@echo "--------------------------------------------------------------"
276	@echo ">>> stage 2: build tools"
277	@echo "--------------------------------------------------------------"
278	cd ${.CURDIR}; ${TMAKE} build-tools
279	@echo
280	@echo "--------------------------------------------------------------"
281	@echo ">>> stage 3: cross tools"
282	@echo "--------------------------------------------------------------"
283	cd ${.CURDIR}; ${XMAKE} cross-tools
284	@echo
285	@echo "--------------------------------------------------------------"
286	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
287	@echo "--------------------------------------------------------------"
288	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
289	@echo
290	@echo "--------------------------------------------------------------"
291	@echo ">>> stage 4: building libraries"
292	@echo "--------------------------------------------------------------"
293	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
294	@echo
295	@echo "--------------------------------------------------------------"
296	@echo ">>> stage 4: make dependencies"
297	@echo "--------------------------------------------------------------"
298	cd ${.CURDIR}; ${WMAKE} par-depend
299	@echo
300	@echo "--------------------------------------------------------------"
301	@echo ">>> stage 4: building everything.."
302	@echo "--------------------------------------------------------------"
303	cd ${.CURDIR}; ${WMAKE} all
304
305everything:
306	@echo "--------------------------------------------------------------"
307	@echo ">>> Building everything.."
308	@echo "--------------------------------------------------------------"
309	cd ${.CURDIR}; ${WMAKE} all
310
311#
312# installworld
313#
314# Installs everything compiled by a 'buildworld'.
315#
316installworld:
317	mkdir -p ${INSTALLTMP}
318	for prog in [ awk cat chflags chmod chown date echo egrep find grep \
319	    ln make makewhatis mkdir mtree mv perl rm sed sh sysctl \
320	    test true uname wc zic; do \
321		cp `which $$prog` ${INSTALLTMP}; \
322	done
323	cd ${.CURDIR}; ${IMAKE} reinstall
324	rm -rf ${INSTALLTMP}
325
326#
327# reinstall
328#
329# If you have a build server, you can NFS mount the source and obj directories
330# and do a 'make reinstall' on the *client* to install new binaries from the
331# most recent server build.
332#
333reinstall:
334	@echo "--------------------------------------------------------------"
335	@echo ">>> Making hierarchy"
336	@echo "--------------------------------------------------------------"
337	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
338	@echo
339	@echo "--------------------------------------------------------------"
340	@echo ">>> Installing everything.."
341	@echo "--------------------------------------------------------------"
342	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
343.if !defined(NOMAN)
344	@echo
345	@echo "--------------------------------------------------------------"
346	@echo ">>> Rebuilding man page indices"
347	@echo "--------------------------------------------------------------"
348	cd ${.CURDIR}/share/man; ${MAKE} makedb
349.endif
350
351#
352# distribworld
353#
354# Front-end to distribute to make sure the search path contains
355# the object directory. Needed for miniperl.
356#
357distribworld:
358	cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
359
360#
361# buildkernel and installkernel
362#
363# Which kernels to build and/or install is specified by setting
364# KERNCONF. If not defined a GENERIC kernel is built/installed.
365# Only the existing (depending TARGET) config files are used
366# for building kernels and only the first of these is designated
367# as the one being installed.
368#
369# Note that we have to use TARGET instead of TARGET_ARCH when
370# we're in kernel-land. Since only TARGET_ARCH is (expected) to
371# be set to cross-build, we have to make sure TARGET is set
372# properly.
373
374.if !defined(KERNCONF) && defined(KERNEL)
375KERNCONF=	${KERNEL}
376KERNWARN=	yes
377.else
378KERNCONF?=	GENERIC
379.endif
380INSTKERNNAME?=	kernel
381
382KRNLSRCDIR=	${.CURDIR}/sys
383KRNLCONFDIR=	${KRNLSRCDIR}/${TARGET}/conf
384KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
385KERNCONFDIR?=	${KRNLCONFDIR}
386
387BUILDKERNELS=
388INSTALLKERNEL=
389.for _kernel in ${KERNCONF}
390.if exists(${KERNCONFDIR}/${_kernel})
391BUILDKERNELS+=	${_kernel}
392.if empty(INSTALLKERNEL)
393INSTALLKERNEL= ${_kernel}
394.endif
395.endif
396.endfor
397
398#
399# buildkernel
400#
401# Builds all kernels defined by BUILDKERNELS.
402#
403buildkernel:
404.if empty(BUILDKERNELS)
405	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
406	@false
407.endif
408.if defined(KERNWARN)
409	@echo "--------------------------------------------------------------"
410	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
411	@echo "--------------------------------------------------------------"
412	@sleep 3
413.endif
414	@echo
415.for _kernel in ${BUILDKERNELS}
416	@echo "--------------------------------------------------------------"
417	@echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
418	@echo "--------------------------------------------------------------"
419	@echo "===> ${_kernel}"
420	mkdir -p ${KRNLOBJDIR}
421.if !defined(NO_KERNELCONFIG)
422	cd ${KRNLCONFDIR}; \
423		PATH=${TMPPATH} \
424		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
425			${KERNCONFDIR}/${_kernel}
426.endif
427.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
428	cd ${KRNLOBJDIR}/${_kernel}; \
429	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
430.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
431	cd ${KRNLOBJDIR}/${_kernel}; \
432	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
433.endif
434.endif
435	cd ${KRNLOBJDIR}/${_kernel}; \
436		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
437		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
438.if !defined(NO_KERNELDEPEND)
439	cd ${KRNLOBJDIR}/${_kernel}; \
440	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
441.endif
442	cd ${KRNLOBJDIR}/${_kernel}; \
443	    ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
444	@echo "--------------------------------------------------------------"
445	@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
446	@echo "--------------------------------------------------------------"
447.endfor
448
449#
450# installkernel
451#
452# Install the kernel defined by INSTALLKERNEL
453#
454installkernel:
455	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
456	    ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} install
457reinstallkernel:
458	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
459	    ${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
460
461#
462# kernel
463#
464# Short hand for `make buildkernel installkernel'
465#
466kernel: buildkernel installkernel
467
468#
469# update
470#
471# Update the source tree, by running sup and/or running cvs to update to the
472# latest copy.
473#
474update:
475.if defined(SUP_UPDATE)
476	@echo "--------------------------------------------------------------"
477	@echo ">>> Running ${SUP}"
478	@echo "--------------------------------------------------------------"
479.if defined(SUPFILE)
480	@${SUP} ${SUPFLAGS} ${SUPFILE}
481.endif
482.if defined(SUPFILE1)
483	@${SUP} ${SUPFLAGS} ${SUPFILE1}
484.endif
485.if defined(SUPFILE2)
486	@${SUP} ${SUPFLAGS} ${SUPFILE2}
487.endif
488.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
489	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
490.endif
491.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
492	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
493.endif
494.endif
495.if defined(CVS_UPDATE)
496	@echo "--------------------------------------------------------------"
497	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
498	@echo "--------------------------------------------------------------"
499	cd ${.CURDIR}; ${CVS} -q update -A -P -d
500.endif
501
502#
503# most
504#
505# Build most of the user binaries on the existing system libs and includes.
506#
507most:
508	@echo "--------------------------------------------------------------"
509	@echo ">>> Building programs only"
510	@echo "--------------------------------------------------------------"
511	cd ${.CURDIR}/bin;		${MAKE} all
512	cd ${.CURDIR}/sbin;		${MAKE} all
513	cd ${.CURDIR}/libexec;		${MAKE} all
514	cd ${.CURDIR}/usr.bin;		${MAKE} all
515	cd ${.CURDIR}/usr.sbin;		${MAKE} all
516	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
517	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
518
519#
520# installmost
521#
522# Install the binaries built by the 'most' target.  This does not include
523# libraries or include files.
524#
525installmost:
526	@echo "--------------------------------------------------------------"
527	@echo ">>> Installing programs only"
528	@echo "--------------------------------------------------------------"
529	cd ${.CURDIR}/bin;		${MAKE} install
530	cd ${.CURDIR}/sbin;		${MAKE} install
531	cd ${.CURDIR}/libexec;		${MAKE} install
532	cd ${.CURDIR}/usr.bin;		${MAKE} install
533	cd ${.CURDIR}/usr.sbin;		${MAKE} install
534	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
535	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
536
537#
538# ------------------------------------------------------------------------
539#
540# From here onwards are utility targets used by the 'make world' and
541# related targets.  If your 'world' breaks, you may like to try to fix
542# the problem and manually run the following targets to attempt to
543# complete the build.  Beware, this is *not* guaranteed to work, you
544# need to have a pretty good grip on the current state of the system
545# to attempt to manually finish it.  If in doubt, 'make world' again.
546#
547
548#
549# bootstrap-tools: Build tools needed for compatibility
550#
551.if exists(${.CURDIR}/games) && !defined(NOGAMES)
552_strfile=	games/fortune/strfile
553.endif
554
555bootstrap-tools:
556.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
557    usr.bin/xargs usr.bin/xinstall \
558    usr.sbin/config usr.sbin/kbdcontrol \
559    gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
560	cd ${.CURDIR}/${_tool}; \
561		${MAKE} obj; \
562		${MAKE} depend; \
563		${MAKE} all; \
564		${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
565.endfor
566
567#
568# build-tools: Build special purpose build tools
569#
570.if exists(${.CURDIR}/games) && !defined(NOGAMES)
571_games=	games/adventure games/hack games/phantasia
572.endif
573
574.if exists(${.CURDIR}/share) && !defined(NOSHARE)
575_share=	share/syscons/scrnmaps
576.endif
577
578.if !defined(NO_FORTRAN)
579_fortran= gnu/usr.bin/cc/f771
580.endif
581
582.if !defined(NOPERL) && !defined(NO_PERL)
583_perl=	gnu/usr.bin/perl/miniperl
584.endif
585
586.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
587    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
588_libroken4= kerberosIV/lib/libroken
589.endif
590
591.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
592    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
593_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
594    kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
595.endif
596
597build-tools:
598.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
599    ${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
600    usr.bin/awk usr.bin/file usr.sbin/sysinstall
601	cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
602.endfor
603
604#
605# cross-tools: Build cross-building tools
606#
607.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
608_elf2exe=	usr.sbin/elf2exe
609.endif
610
611.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
612_btxld=	usr.sbin/btxld
613.endif
614
615_xlint=	usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint
616
617cross-tools:
618.for _tool in ${_btxld} ${_elf2exe} \
619    gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc ${_xlint}
620	cd ${.CURDIR}/${_tool}; \
621		${MAKE} obj; \
622		${MAKE} depend; \
623		${MAKE} all; \
624		${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
625.endfor
626
627#
628# hierarchy - ensure that all the needed directories are present
629#
630hierarchy:
631	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
632
633#
634# includes - possibly generate and install the include files.
635#
636includes:
637	cd ${.CURDIR}/include;			${MAKE} -B all install
638	cd ${.CURDIR}/gnu/include;		${MAKE} install
639	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
640	cd ${.CURDIR}/gnu/lib/libreadline/readline;	${MAKE} beforeinstall
641	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
642	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
643	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
644	cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;	${MAKE} beforeinstall
645.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
646.if exists(${.CURDIR}/secure/lib/libcrypto)
647	cd ${.CURDIR}/secure/lib/libcrypto;	${MAKE} beforeinstall
648.endif
649.if exists(${.CURDIR}/secure/lib/libssl)
650	cd ${.CURDIR}/secure/lib/libssl;	${MAKE} beforeinstall
651.endif
652.endif
653.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
654    defined(MAKE_KERBEROS4)
655	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
656	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
657	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
658	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
659	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
660	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
661.elif exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
662	cd ${.CURDIR}/secure/lib/libtelnet;	${MAKE} beforeinstall
663.else
664	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
665.endif
666.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
667    defined(MAKE_KERBEROS5)
668	cd ${.CURDIR}/kerberos5/lib/libasn1;		${MAKE} beforeinstall
669	cd ${.CURDIR}/kerberos5/lib/libhdb;		${MAKE} beforeinstall
670	cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;	${MAKE} beforeinstall
671	cd ${.CURDIR}/kerberos5/lib/libkadm5srv;	${MAKE} beforeinstall
672	cd ${.CURDIR}/kerberos5/lib/libkafs5;		${MAKE} beforeinstall
673	cd ${.CURDIR}/kerberos5/lib/libkrb5;		${MAKE} beforeinstall
674	cd ${.CURDIR}/kerberos5/lib/libsl;		${MAKE} beforeinstall
675.endif
676.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
677	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
678.endif
679	cd ${.CURDIR}/gnu/lib/csu;		${MAKE} beforeinstall
680	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
681	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
682	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
683	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
684	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
685	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
686	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
687	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
688	cd ${.CURDIR}/lib/libfetch;		${MAKE} beforeinstall
689	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
690	cd ${.CURDIR}/lib/libkvm;		${MAKE} beforeinstall
691	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
692	cd ${.CURDIR}/lib/libmp;		${MAKE} beforeinstall
693	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
694	cd ${.CURDIR}/lib/libncp;		${MAKE} beforeinstall
695	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
696	cd ${.CURDIR}/lib/libnetgraph;		${MAKE} beforeinstall
697	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
698	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
699	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
700	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
701	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
702	cd ${.CURDIR}/lib/libsbuf;		${MAKE} beforeinstall
703	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
704	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
705	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
706	cd ${.CURDIR}/lib/libusbhid;		${MAKE} beforeinstall
707	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
708	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
709	cd ${.CURDIR}/lib/libwrap;		${MAKE} beforeinstall
710	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
711	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
712
713#
714# libraries - build all libraries, and install them under ${DESTDIR}.
715#
716# The following dependencies exist between the libraries:
717#
718# lib*: csu libgcc_pic
719# libatm: libmd
720# libcam: libsbuf
721# libcrypt: libmd
722# libdevstat: libkvm
723# libdialog: libncurses
724# libedit: libncurses
725# libg++: msun
726# libkrb: libcrypt
727# libopie: libmd
728# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
729#	  librpcsvc libtacplus libutil libz libssh
730# libradius: libmd
731# libreadline: libncurses
732# libssh: libcrypto libz
733# libstc++: msun
734# libtacplus: libmd
735#
736# Across directories this comes down to (rougly):
737#
738# gnu/lib: lib/msun lib/libncurses
739# kerberosIV/lib kerberos5/lib: lib/libcrypt
740# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
741#             secure/lib/libssh lib/libz
742# secure/lib: secure/lib/libcrypto lib/libmd lib/libz
743#
744.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
745_csu=	lib/csu/${MACHINE_ARCH}.pcc
746.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
747_csu=	lib/csu/i386-elf
748.else
749_csu=	lib/csu/${MACHINE_ARCH}
750.endif
751
752.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
753_secure_lib=	secure/lib
754.if exists(${.CURDIR}/secure/lib/libcrypto)
755_libcrypto=	secure/lib/libcrypto
756.endif
757.endif
758
759.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
760_kerberosIV_lib=	kerberosIV/lib
761.endif
762
763.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
764_kerberos5_lib=	kerberos5/lib
765.endif
766
767.if ${MACHINE_ARCH} == "i386"
768_libkeycap=	usr.sbin/pcvt/keycap
769.endif
770
771.if !defined(NOPERL) && !defined(NO_PERL)
772_libperl=	gnu/usr.bin/perl/libperl
773.endif
774
775libraries:
776.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
777    lib/libz ${_libcrypto} ${_secure_lib} ${_kerberosIV_lib} \
778    ${_kerberos5_lib} lib/libcom_err lib/libkvm lib/msun lib/libncurses \
779    lib/libopie lib/libradius lib/librpcsvc lib/libsbuf lib/libtacplus \
780    lib/libutil lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
781.if exists(${.CURDIR}/${_lib})
782	cd ${.CURDIR}/${_lib}; \
783		${MAKE} depend; \
784		${MAKE} all; \
785		${MAKE} install
786.endif
787.endfor
788
789.for __target in clean cleandepend cleandir depend obj
790.for entry in ${SUBDIR}
791${entry}.${__target}__D: .PHONY
792	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
793		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
794		edir=${entry}.${MACHINE_ARCH}; \
795		cd ${.CURDIR}/$${edir}; \
796	else \
797		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
798		edir=${entry}; \
799		cd ${.CURDIR}/$${edir}; \
800	fi; \
801	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
802.endfor
803par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
804.endfor
805
806.include <bsd.subdir.mk>
807