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