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