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