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