Makefile.inc1 revision 72924
1#
2# $FreeBSD: head/Makefile.inc1 72924 2001-02-22 22:58:24Z jhb $
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#	MACHINE_ARCH="machine arch" to crossbuild world to a different arch
24
25#
26# The intended user-driven targets are:
27# buildworld  - rebuild *everything*, including glue to help do upgrades
28# installworld- install everything built by "buildworld"
29# update      - convenient way to update your source tree (eg: sup/cvs)
30# most        - build user commands, no libraries or include files
31# installmost - install user commands, no libraries or include files
32#
33# Standard targets (not defined here) are documented in the makefiles in
34# /usr/share/mk.  These include:
35#		obj depend all install clean cleandepend cleanobj
36
37# Put initial settings here.
38SUBDIR=
39
40# We must do share/info early so that installation of info `dir'
41# entries works correctly.  Do it first since it is less likely to
42# grow dependencies on include and lib than vice versa.
43.if exists(${.CURDIR}/share/info)
44SUBDIR+= share/info
45.endif
46
47# We must do include and lib early so that the perl *.ph generation
48# works correctly as it uses the header files installed by this.
49.if exists(${.CURDIR}/include)
50SUBDIR+= include
51.endif
52.if exists(${.CURDIR}/lib)
53SUBDIR+= lib
54.endif
55
56.if exists(${.CURDIR}/bin)
57SUBDIR+= bin
58.endif
59.if exists(${.CURDIR}/games) && !defined(NOGAMES)
60SUBDIR+= games
61.endif
62.if exists(${.CURDIR}/gnu)
63SUBDIR+= gnu
64.endif
65.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
66    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
67SUBDIR+= kerberosIV
68.endif
69.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
70    !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
71SUBDIR+= kerberos5
72.endif
73.if exists(${.CURDIR}/libexec)
74SUBDIR+= libexec
75.endif
76.if exists(${.CURDIR}/sbin)
77SUBDIR+= sbin
78.endif
79.if exists(${.CURDIR}/share) && !defined(NOSHARE)
80SUBDIR+= share
81.endif
82.if exists(${.CURDIR}/sys)
83SUBDIR+= sys
84.endif
85.if exists(${.CURDIR}/usr.bin)
86SUBDIR+= usr.bin
87.endif
88.if exists(${.CURDIR}/usr.sbin)
89SUBDIR+= usr.sbin
90.endif
91.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
92SUBDIR+= secure
93.endif
94
95# etc must be last for "distribute" to work
96.if exists(${.CURDIR}/etc)
97SUBDIR+= etc
98.endif
99
100# These are last, since it is nice to at least get the base system
101# rebuilt before you do them.
102.if defined(LOCAL_DIRS)
103.for _DIR in ${LOCAL_DIRS}
104.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
105SUBDIR+= ${_DIR}
106.endif
107.endfor
108.endif
109
110.if defined(NOCLEANDIR)
111CLEANDIR=	clean cleandepend
112.else
113CLEANDIR=	cleandir
114.endif
115
116SUP?=		cvsup
117SUPFLAGS?=	-g -L 2 -P -
118.if defined(SUPHOST)
119SUPFLAGS+=	-h ${SUPHOST}
120.endif
121
122MAKEOBJDIRPREFIX?=	/usr/obj
123TARGET_ARCH?=	${MACHINE_ARCH}
124BUILD_ARCH!=	sysctl -n hw.machine_arch
125.if ${BUILD_ARCH} == ${MACHINE_ARCH}
126OBJTREE=	${MAKEOBJDIRPREFIX}
127.else
128OBJTREE=	${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
129.endif
130WORLDTMP=	${OBJTREE}${.CURDIR}/${BUILD_ARCH}
131# /usr/games added for fortune which depend on strfile
132STRICTTMPPATH=	${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
133TMPPATH=	${STRICTTMPPATH}:${PATH}
134OBJFORMAT_PATH?=	/usr/libexec
135
136TMPDIR?=	/tmp
137TMPPID!=	echo $$$$
138INSTALLTMP=	${TMPDIR}/install.${TMPPID}
139
140#
141# Building a world goes through the following stages
142#
143# 1. bootstrap-tool stage [BMAKE]
144#	This stage is responsible for creating programs that
145#	are needed for backward compatibility reasons. They
146#	are not built as cross-tools.
147# 2. build-tool stage [TMAKE]
148#	This stage is responsible for creating the object
149#	tree and building any tools that are needed during
150#	the build process.
151# 3. cross-tool stage [XMAKE]
152#	This stage is responsible for creating any tools that
153#	are needed for cross-builds. A cross-compiler is one
154#	of them.
155# 4. world stage [WMAKE]
156#	This stage actually builds the world.
157# 5. install stage (optional) [IMAKE]
158#	This stage installs a previously built world.
159#
160
161# Common environment for bootstrap related stages
162BOOTSTRAPENV=	MAKEOBJDIRPREFIX=${WORLDTMP} \
163		DESTDIR=${WORLDTMP} \
164		INSTALL="sh ${.CURDIR}/tools/install.sh" \
165		MACHINE_ARCH=${BUILD_ARCH} \
166		TOOLS_PREFIX=${WORLDTMP} \
167		PATH=${TMPPATH}
168
169# Common environment for world related stages
170CROSSENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
171		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
172		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
173		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
174		PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.0
175
176# bootstrap-tool stage
177BMAKEENV=	${BOOTSTRAPENV}
178BMAKE=		${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOHTML -DNOINFO \
179			-DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
180
181# build-tool stage
182TMAKEENV=	MAKEOBJDIRPREFIX=${OBJTREE} \
183		INSTALL="sh ${.CURDIR}/tools/install.sh" \
184		PATH=${TMPPATH}
185TMAKE=		${TMAKEENV} ${MAKE} -f Makefile.inc1
186
187# cross-tool stage
188XMAKEENV=	${BOOTSTRAPENV} \
189		TARGET_ARCH=${MACHINE_ARCH}
190XMAKE=		${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
191			-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE \
192			-DNOSHARED
193
194# world stage
195WMAKEENV=	${CROSSENV} \
196		DESTDIR=${WORLDTMP} \
197		INSTALL="sh ${.CURDIR}/tools/install.sh" \
198		PATH=${TMPPATH}
199WMAKE=		${WMAKEENV} ${MAKE} -f Makefile.inc1
200
201# install stage
202IMAKEENV=	${CROSSENV} \
203		PATH=${STRICTTMPPATH}:${INSTALLTMP}
204IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
205
206# kernel stage
207KMAKEENV=	${WMAKEENV} \
208		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec:${OBJFORMAT_PATH}
209
210USRDIRS=	usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
211		usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc
212
213INCDIRS=	arpa g++/std objc protocols readline rpc rpcsvc openssl \
214		security ss
215
216#
217# buildworld
218#
219# Attempt to rebuild the entire system, with reasonable chance of
220# success, regardless of how old your existing system is.
221#
222buildworld:
223	@echo
224	@echo "--------------------------------------------------------------"
225	@echo ">>> Rebuilding the temporary build tree"
226	@echo "--------------------------------------------------------------"
227.if !defined(NOCLEAN)
228	rm -rf ${WORLDTMP}
229.else
230	for dir in bin games include lib sbin; do \
231		rm -rf ${WORLDTMP}/usr/$$dir; \
232	done
233	rm -f ${WORLDTMP}/sys
234	# XXX - Work-around for broken cc/cc_tools/Makefile.
235	# This is beyond dirty...
236	rm -f ${OBJTREE}${.CURDIR}/gnu/usr.bin/cc/cc_tools/.depend
237.endif
238.for _dir in ${USRDIRS}
239	mkdir -p ${WORLDTMP}/${_dir}
240.endfor
241.for _dir in ${INCDIRS}
242	mkdir -p ${WORLDTMP}/usr/include/${_dir}
243.endfor
244	ln -sf ${.CURDIR}/sys ${WORLDTMP}/sys
245	@echo
246	@echo "--------------------------------------------------------------"
247	@echo ">>> stage 1: bootstrap tools"
248	@echo "--------------------------------------------------------------"
249	cd ${.CURDIR}; ${BMAKE} bootstrap-tools
250.if !defined(NOCLEAN)
251	@echo
252	@echo "--------------------------------------------------------------"
253	@echo ">>> stage 2: cleaning up the object tree"
254	@echo "--------------------------------------------------------------"
255	cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
256.endif
257	@echo
258	@echo "--------------------------------------------------------------"
259	@echo ">>> stage 2: rebuilding the object tree"
260	@echo "--------------------------------------------------------------"
261	cd ${.CURDIR}; ${TMAKE} par-obj
262	@echo
263	@echo "--------------------------------------------------------------"
264	@echo ">>> stage 2: build tools"
265	@echo "--------------------------------------------------------------"
266	cd ${.CURDIR}; ${TMAKE} build-tools
267	@echo
268	@echo "--------------------------------------------------------------"
269	@echo ">>> stage 3: cross tools"
270	@echo "--------------------------------------------------------------"
271	cd ${.CURDIR}; ${XMAKE} cross-tools
272	@echo
273	@echo "--------------------------------------------------------------"
274	@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
275	@echo "--------------------------------------------------------------"
276	cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
277	@echo
278	@echo "--------------------------------------------------------------"
279	@echo ">>> stage 4: building libraries"
280	@echo "--------------------------------------------------------------"
281	cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
282	@echo
283	@echo "--------------------------------------------------------------"
284	@echo ">>> stage 4: make dependencies"
285	@echo "--------------------------------------------------------------"
286	cd ${.CURDIR}; ${WMAKE} par-depend
287	@echo
288	@echo "--------------------------------------------------------------"
289	@echo ">>> stage 4: building everything.."
290	@echo "--------------------------------------------------------------"
291	cd ${.CURDIR}; ${WMAKE} all
292
293everything:
294	@echo "--------------------------------------------------------------"
295	@echo ">>> Building everything.."
296	@echo "--------------------------------------------------------------"
297	cd ${.CURDIR}; ${WMAKE} all
298
299#
300# installworld
301#
302# Installs everything compiled by a 'buildworld'.
303#
304installworld:
305	mkdir -p ${INSTALLTMP}
306	for prog in [ awk cat chflags chmod chown date echo egrep find grep \
307	    install ln make makewhatis mtree mv perl rm sed sh sysctl \
308	    test true uname wc zic; do \
309		cp `which $$prog` ${INSTALLTMP}; \
310	done
311	cd ${.CURDIR}; ${IMAKE} reinstall
312	rm -rf ${INSTALLTMP}
313
314#
315# reinstall
316#
317# If you have a build server, you can NFS mount the source and obj directories
318# and do a 'make reinstall' on the *client* to install new binaries from the
319# most recent server build.
320#
321reinstall:
322	@echo "--------------------------------------------------------------"
323	@echo ">>> Making hierarchy"
324	@echo "--------------------------------------------------------------"
325	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
326	@echo
327	@echo "--------------------------------------------------------------"
328	@echo ">>> Installing everything.."
329	@echo "--------------------------------------------------------------"
330	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
331.if !defined(NOMAN)
332	@echo
333	@echo "--------------------------------------------------------------"
334	@echo ">>> Rebuilding man page indices"
335	@echo "--------------------------------------------------------------"
336	cd ${.CURDIR}/share/man; ${MAKE} makedb
337.endif
338
339#
340# distribworld
341#
342# Front-end to distribute to make sure the search path contains
343# the object directory. Needed for miniperl.
344#
345distribworld:
346	cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
347
348#
349# buildkernel and installkernel
350#
351# Which kernels to build and/or install is specified by setting
352# KERNCONF. If not defined a GENERIC kernel is built/installed.
353# Only the existing (depending MACHINE) config files are used
354# for building kernels and only the first of these is designated
355# as the one being installed.
356#
357# Note that we have to use MACHINE instead of MACHINE_ARCH when
358# we're in kernel-land. Since only MACHINE_ARCH is (expected) to
359# be set to cross-build, we have to make sure MACHINE is set
360# properly.
361
362.if !defined(KERNCONF) && defined(KERNEL)
363KERNCONF=	${KERNEL}
364KERNWARN=	yes
365.else
366KERNCONF?=	GENERIC
367.endif
368INSTKERNNAME?=	kernel
369
370# The only exotic MACHINE_ARCH/MACHINE combination valid at this
371# time is i386/pc98. In all other cases set MACHINE equal to
372# MACHINE_ARCH.
373.if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
374MACHINE=	${MACHINE_ARCH}
375.endif
376
377KRNLSRCDIR=	${.CURDIR}/sys
378KRNLCONFDIR=	${KRNLSRCDIR}/${MACHINE}/conf
379KRNLOBJDIR=	${OBJTREE}${KRNLSRCDIR}
380
381BUILDKERNELS=
382INSTALLKERNEL=
383.for _kernel in ${KERNCONF}
384.if exists(${KRNLCONFDIR}/${_kernel})
385BUILDKERNELS+=	${_kernel}
386.if empty(INSTALLKERNEL)
387INSTALLKERNEL= ${_kernel}
388.endif
389.endif
390.endfor
391
392#
393# buildkernel
394#
395# Builds all kernels defined by BUILDKERNELS.
396#
397buildkernel:
398.if empty(BUILDKERNELS)
399	@echo ">>> ERROR: Missing kernel configuration file(s) (${KERNCONF})."
400	@false
401.endif
402.if defined(KERNWARN)
403	@echo "--------------------------------------------------------------"
404	@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
405	@echo "--------------------------------------------------------------"
406	@sleep 3
407.endif
408	@echo
409.for _kernel in ${BUILDKERNELS}
410	@echo "--------------------------------------------------------------"
411	@echo ">>> Kernel build for ${_kernel} started on `LC_TIME=C date`"
412	@echo "--------------------------------------------------------------"
413	@echo "===> ${_kernel}"
414	mkdir -p ${KRNLOBJDIR}
415.if !defined(NO_KERNELCONFIG)
416	cd ${KRNLCONFDIR}; \
417		PATH=${TMPPATH} \
418		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
419.endif
420.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
421	cd ${KRNLOBJDIR}/${_kernel}; \
422	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} clean
423.endif
424	cd ${KRNLOBJDIR}/${_kernel}; \
425		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
426		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
427.if !defined(NO_KERNELDEPEND)
428	cd ${KRNLOBJDIR}/${_kernel}; \
429	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} depend
430.endif
431	cd ${KRNLOBJDIR}/${_kernel}; \
432	    ${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} all
433	@echo "--------------------------------------------------------------"
434	@echo ">>> Kernel build for ${_kernel} completed on `LC_TIME=C date`"
435	@echo "--------------------------------------------------------------"
436.endfor
437
438#
439# installkernel
440#
441# Install the kernel defined by INSTALLKERNEL
442#
443installkernel:
444	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
445	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} install
446reinstallkernel:
447	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
448	    ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
449
450#
451# kernel
452#
453# Short hand for `make buildkernel installkernel'
454#
455kernel: buildkernel installkernel
456
457#
458# update
459#
460# Update the source tree, by running sup and/or running cvs to update to the
461# latest copy.
462#
463update:
464.if defined(SUP_UPDATE)
465	@echo "--------------------------------------------------------------"
466	@echo ">>> Running ${SUP}"
467	@echo "--------------------------------------------------------------"
468.if defined(SUPFILE)
469	@${SUP} ${SUPFLAGS} ${SUPFILE}
470.endif
471.if defined(SUPFILE1)
472	@${SUP} ${SUPFLAGS} ${SUPFILE1}
473.endif
474.if defined(SUPFILE2)
475	@${SUP} ${SUPFLAGS} ${SUPFILE2}
476.endif
477.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
478	@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
479.endif
480.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
481	@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
482.endif
483.endif
484.if defined(CVS_UPDATE)
485	@echo "--------------------------------------------------------------"
486	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
487	@echo "--------------------------------------------------------------"
488	cd ${.CURDIR}; cvs -q update -A -P -d
489.endif
490
491#
492# most
493#
494# Build most of the user binaries on the existing system libs and includes.
495#
496most:
497	@echo "--------------------------------------------------------------"
498	@echo ">>> Building programs only"
499	@echo "--------------------------------------------------------------"
500	cd ${.CURDIR}/bin;		${MAKE} all
501	cd ${.CURDIR}/sbin;		${MAKE} all
502	cd ${.CURDIR}/libexec;		${MAKE} all
503	cd ${.CURDIR}/usr.bin;		${MAKE} all
504	cd ${.CURDIR}/usr.sbin;		${MAKE} all
505	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
506	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
507	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
508
509#
510# installmost
511#
512# Install the binaries built by the 'most' target.  This does not include
513# libraries or include files.
514#
515installmost:
516	@echo "--------------------------------------------------------------"
517	@echo ">>> Installing programs only"
518	@echo "--------------------------------------------------------------"
519	cd ${.CURDIR}/bin;		${MAKE} install
520	cd ${.CURDIR}/sbin;		${MAKE} install
521	cd ${.CURDIR}/libexec;		${MAKE} install
522	cd ${.CURDIR}/usr.bin;		${MAKE} install
523	cd ${.CURDIR}/usr.sbin;		${MAKE} install
524	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
525	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
526	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
527
528#
529# ------------------------------------------------------------------------
530#
531# From here onwards are utility targets used by the 'make world' and
532# related targets.  If your 'world' breaks, you may like to try to fix
533# the problem and manually run the following targets to attempt to
534# complete the build.  Beware, this is *not* guaranteed to work, you
535# need to have a pretty good grip on the current state of the system
536# to attempt to manually finish it.  If in doubt, 'make world' again.
537#
538
539#
540# bootstrap-tools: Build tools needed for compatibility
541#
542.if exists(${.CURDIR}/games) && !defined(NOGAMES)
543_strfile=	games/fortune/strfile
544.endif
545
546bootstrap-tools:
547.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.sbin/config \
548    gnu/usr.bin/gperf gnu/usr.bin/texinfo
549	cd ${.CURDIR}/${_tool}; \
550		${MAKE} obj; \
551		${MAKE} depend; \
552		${MAKE} all; \
553		${MAKE} install
554.endfor
555
556#
557# build-tools: Build special purpose build tools
558#
559.if exists(${.CURDIR}/games) && !defined(NOGAMES)
560_games=	games/adventure games/hack games/phantasia
561.endif
562
563.if exists(${.CURDIR}/share) && !defined(NOSHARE)
564_share=	share/syscons/scrnmaps
565.endif
566
567.if !defined(NO_FORTRAN)
568_fortran= gnu/usr.bin/cc/f771
569.endif
570
571.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
572    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
573_libroken4= kerberosIV/lib/libroken
574.endif
575
576.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
577    !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
578_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb 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} \
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