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