Makefile.inc1 revision 71419
1#
2# $FreeBSD: head/Makefile.inc1 71419 2001-01-23 09:52:50Z 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
361.if !defined(KERNCONF) && defined(KERNEL)
362KERNCONF=	${KERNEL}
363KERNWARN=	yes
364.else
365KERNCONF?=	GENERIC
366.endif
367INSTKERNNAME?=	kernel
368
369# The only exotic MACHINE_ARCH/MACHINE combination valid at this
370# time is i386/pc98. In all other cases set MACHINE equal to
371# MACHINE_ARCH.
372.if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
373MACHINE=	${MACHINE_ARCH}
374.endif
375
376KRNLSRCDIR=	${.CURDIR}/sys
377KRNLCONFDIR=	${KRNLSRCDIR}/${MACHINE}/conf
378KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
379
380BUILDKERNELS=
381INSTALLKERNEL=
382.for _kernel in ${KERNCONF}
383.if exists(${KRNLCONFDIR}/${_kernel})
384BUILDKERNELS+=	${_kernel}
385.if empty(INSTALLKERNEL)
386INSTALLKERNEL= ${_kernel}
387.endif
388.endif
389.endfor
390
391#
392# buildkernel
393#
394# Builds all kernels defined by BUILDKERNELS.
395#
396buildkernel:
397.if empty(BUILDKERNELS)
398	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
399	@false
400.endif
401.if defined(KERNWARN)
402	@echo "--------------------------------------------------------------"
403	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
404	@echo "--------------------------------------------------------------"
405	@sleep 3
406.endif
407	@echo
408.for _kernel in ${BUILDKERNELS}
409	@echo "--------------------------------------------------------------"
410	@echo ">>> Kernel build for ${_kernel} started on `LC_TIME=C date`"
411	@echo "--------------------------------------------------------------"
412	@echo "===> ${_kernel}"
413	mkdir -p ${KRNLOBJDIR}
414.if !defined(NO_KERNELCONFIG)
415	cd ${KRNLCONFDIR}; \
416		PATH=${TMPPATH} \
417		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
418.endif
419.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
420	cd ${KRNLOBJDIR}/${_kernel}; \
421	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} clean
422.endif
423	cd ${KRNLOBJDIR}/${_kernel}; \
424		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
425		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
426.if !defined(NO_KERNELDEPEND)
427	cd ${KRNLOBJDIR}/${_kernel}; \
428	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} depend
429.endif
430	cd ${KRNLOBJDIR}/${_kernel}; \
431	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} all
432	@echo "--------------------------------------------------------------"
433	@echo ">>> Kernel build for ${_kernel} completed on `LC_TIME=C date`"
434	@echo "--------------------------------------------------------------"
435.endfor
436
437#
438# installkernel
439#
440# Install the kernel defined by INSTALLKERNEL
441#
442installkernel:
443	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
444	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} install
445reinstallkernel:
446	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
447	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
448
449#
450# kernel
451#
452# Short hand for `make buildkernel installkernel'
453#
454kernel: buildkernel installkernel
455
456#
457# update
458#
459# Update the source tree, by running sup and/or running cvs to update to the
460# latest copy.
461#
462update:
463.if defined(SUP_UPDATE)
464	@echo "--------------------------------------------------------------"
465	@echo ">>> Running ${SUP}"
466	@echo "--------------------------------------------------------------"
467.if defined(SUPFILE)
468	@${SUP} ${SUPFLAGS} ${SUPFILE}
469.endif
470.if defined(SUPFILE1)
471	@${SUP} ${SUPFLAGS} ${SUPFILE1}
472.endif
473.if defined(SUPFILE2)
474	@${SUP} ${SUPFLAGS} ${SUPFILE2}
475.endif
476.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
477	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
478.endif
479.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
480	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
481.endif
482.endif
483.if defined(CVS_UPDATE)
484	@echo "--------------------------------------------------------------"
485	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
486	@echo "--------------------------------------------------------------"
487	cd ${.CURDIR}; cvs -q update -A -P -d
488.endif
489
490#
491# most
492#
493# Build most of the user binaries on the existing system libs and includes.
494#
495most:
496	@echo "--------------------------------------------------------------"
497	@echo ">>> Building programs only"
498	@echo "--------------------------------------------------------------"
499	cd ${.CURDIR}/bin;		${MAKE} all
500	cd ${.CURDIR}/sbin;		${MAKE} all
501	cd ${.CURDIR}/libexec;		${MAKE} all
502	cd ${.CURDIR}/usr.bin;		${MAKE} all
503	cd ${.CURDIR}/usr.sbin;		${MAKE} all
504	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
505	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
506	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
507
508#
509# installmost
510#
511# Install the binaries built by the 'most' target.  This does not include
512# libraries or include files.
513#
514installmost:
515	@echo "--------------------------------------------------------------"
516	@echo ">>> Installing programs only"
517	@echo "--------------------------------------------------------------"
518	cd ${.CURDIR}/bin;		${MAKE} install
519	cd ${.CURDIR}/sbin;		${MAKE} install
520	cd ${.CURDIR}/libexec;		${MAKE} install
521	cd ${.CURDIR}/usr.bin;		${MAKE} install
522	cd ${.CURDIR}/usr.sbin;		${MAKE} install
523	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
524	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
525	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
526
527#
528# ------------------------------------------------------------------------
529#
530# From here onwards are utility targets used by the 'make world' and
531# related targets.  If your 'world' breaks, you may like to try to fix
532# the problem and manually run the following targets to attempt to
533# complete the build.  Beware, this is *not* guaranteed to work, you
534# need to have a pretty good grip on the current state of the system
535# to attempt to manually finish it.  If in doubt, 'make world' again.
536#
537
538#
539# bootstrap-tools: Build tools needed for compatibility
540#
541.if exists(${.CURDIR}/games) && !defined(NOGAMES)
542_strfile=	games/fortune/strfile
543.endif
544
545bootstrap-tools:
546.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.sbin/config \
547    gnu/usr.bin/gperf gnu/usr.bin/texinfo
548	cd ${.CURDIR}/${_tool}; \
549		${MAKE} obj; \
550		${MAKE} depend; \
551		${MAKE} all; \
552		${MAKE} install
553.endfor
554
555#
556# build-tools: Build special purpose build tools
557#
558.if exists(${.CURDIR}/games) && !defined(NOGAMES)
559_games=	games/adventure games/hack games/phantasia
560.endif
561
562.if exists(${.CURDIR}/share) && !defined(NOSHARE)
563_share=	share/syscons/scrnmaps
564.endif
565
566.if !defined(NO_FORTRAN)
567_fortran= gnu/usr.bin/cc/f771
568.endif
569
570.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
571    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
572_libroken4= kerberosIV/lib/libroken
573.endif
574
575.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
576    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
577_libkrb5= kerberos5/lib/libroken kerberos5/lib/libasn1 kerberos5/lib/libhdb \
578	kerberos5/lib/libsl
579.endif
580
581build-tools:
582.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
583    ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.sbin/sysinstall
584	cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
585.endfor
586
587#
588# cross-tools: Build cross-building tools
589#
590# WARNING: Because the bootstrap tools are expected to run on the
591# build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
592# target is being made. TARGET_ARCH is *always* set to reflect the
593# target-machine (which you can set by specifying MACHINE_ARCH on
594# make's command-line, get it?).
595# The reason is simple: we build these tools not to be run on the
596# architecture we're cross-building, but on the architecture we're
597# currently building on (ie the host-machine) and we expect these
598# tools to produce output for the architecture we're trying to
599# cross-build.
600#
601.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
602_elf2exe=	usr.sbin/elf2exe
603.endif
604
605.if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
606_btxld=	usr.sbin/btxld
607.endif
608
609.if !defined(NOPERL)
610_perl=	gnu/usr.bin/perl/libperl gnu/usr.bin/perl/miniperl
611.endif
612
613cross-tools:
614.for _tool in ${_btxld} ${_elf2exe} ${_perl} usr.bin/genassym \
615    usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
616	cd ${.CURDIR}/${_tool}; \
617		${MAKE} obj; \
618		${MAKE} depend; \
619		${MAKE} all; \
620		${MAKE} install
621.endfor
622
623#
624# hierarchy - ensure that all the needed directories are present
625#
626hierarchy:
627	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
628
629#
630# includes - possibly generate and install the include files.
631#
632includes:
633	cd ${.CURDIR}/include;			${MAKE} -B all install
634	cd ${.CURDIR}/gnu/include;		${MAKE} install
635	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
636	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
637	cd ${.CURDIR}/gnu/lib/libreadline/readline;	${MAKE} beforeinstall
638	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
639	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
640	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
641	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
642	cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;	${MAKE} beforeinstall
643.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
644.if exists(${.CURDIR}/secure/lib/libcrypto)
645	cd ${.CURDIR}/secure/lib/libcrypto;	${MAKE} beforeinstall
646.endif
647.if exists(${.CURDIR}/secure/lib/libssl)
648	cd ${.CURDIR}/secure/lib/libssl;	${MAKE} beforeinstall
649.endif
650.endif
651.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
652    defined(MAKE_KERBEROS4)
653	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
654	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
655	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
656	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
657	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
658	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
659.else
660	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
661.endif
662.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
663    defined(MAKE_KERBEROS5)
664	cd ${.CURDIR}/kerberos5/lib/libasn1;		${MAKE} beforeinstall
665	cd ${.CURDIR}/kerberos5/lib/libhdb;		${MAKE} beforeinstall
666	cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;	${MAKE} beforeinstall
667	cd ${.CURDIR}/kerberos5/lib/libkadm5srv;	${MAKE} beforeinstall
668	cd ${.CURDIR}/kerberos5/lib/libkafs5;		${MAKE} beforeinstall
669	cd ${.CURDIR}/kerberos5/lib/libkrb5;		${MAKE} beforeinstall
670	cd ${.CURDIR}/kerberos5/lib/libsl;		${MAKE} beforeinstall
671.endif
672.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
673	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
674.endif
675	cd ${.CURDIR}/gnu/lib/csu;		${MAKE} beforeinstall
676	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
677	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
678	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
679	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
680	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
681	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
682	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
683	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
684	cd ${.CURDIR}/lib/libfetch;		${MAKE} beforeinstall
685	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
686	cd ${.CURDIR}/lib/libkvm;		${MAKE} beforeinstall
687	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
688.if !defined(WANT_CSRG_LIBM)
689	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
690.endif
691	cd ${.CURDIR}/lib/libncp;		${MAKE} beforeinstall
692	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
693	cd ${.CURDIR}/lib/libnetgraph;		${MAKE} beforeinstall
694	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
695	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
696	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
697	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
698	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
699	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
700	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
701	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
702	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
703	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
704	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
705	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
706	cd ${.CURDIR}/lib/libwrap;		${MAKE} beforeinstall
707	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
708	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
709
710#
711# libraries - build all libraries, and install them under ${DESTDIR}.
712#
713# The following dependencies exist between the libraries:
714#
715# lib*: csu libgcc_pic
716# libatm: libmd
717# libcrypt: libmd
718# libdialog: libncurses
719# libedit: libncurses
720# libg++: libm
721# libkrb: libcrypt
722# libopie: libmd
723# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
724#	  libskey libtacplus libutil libz libssh
725# libradius: libmd
726# libreadline: libncurses
727# libskey: libcrypt libmd
728# libss: libcom_err
729# libstc++: libm
730# libtacplus: libmd
731#
732# Across directories this comes down to (rougly):
733#
734# gnu/lib: lib/libm lib/libncurses
735# kerberosIV/lib kerberos5/lib: lib/libcrypt
736# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
737#             secure/lib/libssh lib/libz
738# secure/lib: lib/libmd
739#
740.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
741_csu=	lib/csu/${MACHINE_ARCH}.pcc
742.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
743_csu=	lib/csu/i386-elf
744.else
745_csu=	lib/csu/${MACHINE_ARCH}
746.endif
747
748.if !defined(NOSECURE) && !defined(NOCRYPT)
749_secure_lib=	secure/lib
750.endif
751
752.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
753_kerberosIV_lib=	kerberosIV/lib
754.endif
755
756.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
757_kerberos5_lib=	kerberos5/lib
758.endif
759
760.if defined(WANT_CSRG_LIBM)
761_libm=	lib/libm
762.else
763_libm=	lib/msun
764.endif
765
766.if ${MACHINE_ARCH} == "i386"
767_libkeycap=	usr.sbin/pcvt/keycap
768.endif
769
770.if !defined(NOPERL)
771_libperl=	gnu/usr.bin/perl/libperl
772.endif
773
774libraries:
775.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
776    ${_secure_lib} ${_kerberosIV_lib} \
777    ${_kerberos5_lib} lib/libcom_err ${_libm} lib/libncurses \
778    lib/libopie lib/libradius lib/libskey lib/libtacplus lib/libutil \
779    lib/libz lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
780.if exists(${.CURDIR}/${_lib})
781	cd ${.CURDIR}/${_lib}; \
782		${MAKE} depend; \
783		${MAKE} all; \
784		${MAKE} install
785.endif
786.endfor
787
788.for __target in clean cleandepend cleandir depend obj
789.for entry in ${SUBDIR}
790${entry}.${__target}__D: .PHONY
791	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
792		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
793		edir=${entry}.${MACHINE_ARCH}; \
794		cd ${.CURDIR}/$${edir}; \
795	else \
796		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
797		edir=${entry}; \
798		cd ${.CURDIR}/$${edir}; \
799	fi; \
800	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
801.endfor
802par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
803.endfor
804
805.include <bsd.subdir.mk>
806