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