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