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