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