Makefile.inc1 revision 39542
169039Sben#
269039Sben#	$Id: Makefile.inc1,v 1.17 1998/09/17 16:32:00 andreas Exp $
369039Sben#
469039Sben# Make command line options:
569039Sben#	-DCLOBBER will remove /usr/include
669039Sben#	-DMAKE_KERBEROS4 to build KerberosIV
769039Sben#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
869039Sben#	-DNOCLEAN do not clean at all
969039Sben#	-DNOTOOLS do not rebuild any tools first
1069039Sben#	-DNOCRYPT will prevent building of crypt versions
1169039Sben#	-DNOLKM do not build loadable kernel modules
1269039Sben#	-DNOPROFILE do not build profiled libraries
1369039Sben#	-DNOSECURE do not go into secure subdir
1469039Sben#	-DNOGAMES do not go into games subdir
1569039Sben#	-DNOSHARE do not go into share subdir
1669039Sben#	-DNOINFO do not make or install info files
1769039Sben#	-DNOLIBC_R do not build libc_r.
1869039Sben#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
1969039Sben
2069039Sben#
2169039Sben# The intended user-driven targets are:
2269039Sben# buildworld  - rebuild *everything*, including glue to help do upgrades
2369039Sben# installworld- install everything built by "buildworld"
2469039Sben# update      - convenient way to update your source tree (eg: sup/cvs)
2569039Sben# most        - build user commands, no libraries or include files
2669039Sben# installmost - install user commands, no libraries or include files
27276675Sngie#
2869039Sben# Standard targets (not defined here) are documented in the makefiles in
2979538Sru# /usr/share/mk.  These include:
3069039Sben#		obj depend all install clean cleandepend cleanobj
3169039Sben
3275670Sru# Put initial settings here.
3369039SbenSUBDIR=
34153116Sjkoshy
3570017Sru# We must do share/info early so that installation of info `dir'
36153116Sjkoshy# entries works correctly.  Do it first since it is less likely to
3769039Sben# grow dependencies on include and lib than vice versa.
3869039Sben.if exists(share/info)
3969039SbenSUBDIR+= share/info
4069039Sben.endif
4169039Sben
42237655Swblock# We must do include and lib early so that the perl *.ph generation
43268759Sgavin# works correctly as it uses the header files installed by this.
44237655Swblock.if exists(include)
45238008SwblockSUBDIR+= include
46153116Sjkoshy.endif
4769039Sben.if exists(lib)
4869039SbenSUBDIR+= lib
4969039Sben.endif
5069039Sben
5169039Sben.if exists(bin)
52153116SjkoshySUBDIR+= bin
5369039Sben.endif
5469039Sben.if exists(games) && !defined(NOGAMES)
5569039SbenSUBDIR+= games
56153116Sjkoshy.endif
5769039Sben.if exists(gnu)
58153116SjkoshySUBDIR+= gnu
5969039Sben.endif
60153116Sjkoshy.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
61153116Sjkoshy    defined(MAKE_KERBEROS4)
6269039SbenSUBDIR+= kerberosIV
6369039Sben.endif
6469039Sben.if exists(libexec)
6569039SbenSUBDIR+= libexec
6692798Sru.endif
6792798Sru.if exists(sbin)
6892798SruSUBDIR+= sbin
6992798Sru.endif
7069039Sben.if exists(share) && !defined(NOSHARE)
7192798SruSUBDIR+= share
7292798Sru.endif
73153116Sjkoshy.if exists(sys)
74153116SjkoshySUBDIR+= sys
75153116Sjkoshy.endif
76153116Sjkoshy.if exists(usr.bin)
77153116SjkoshySUBDIR+= usr.bin
78153116Sjkoshy.endif
79153116Sjkoshy.if exists(usr.sbin)
80153116SjkoshySUBDIR+= usr.sbin
81153116Sjkoshy.endif
82153116Sjkoshy.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
83153116SjkoshySUBDIR+= secure
84153116Sjkoshy.endif
85153116Sjkoshy.if exists(lkm) && !defined(NOLKM) && ${OBJFORMAT} == "aout"
86153116SjkoshySUBDIR+= lkm
87153116Sjkoshy.endif
88153116Sjkoshy
89153116Sjkoshy# etc must be last for "distribute" to work
90153116Sjkoshy.if exists(etc)
91153116SjkoshySUBDIR+= etc
92153116Sjkoshy.endif
93153116Sjkoshy
94153116Sjkoshy# These are last, since it is nice to at least get the base system
95153116Sjkoshy# rebuilt before you do them.
96153116Sjkoshy.if defined(LOCAL_DIRS)
97153116Sjkoshy.for _DIR in ${LOCAL_DIRS}
98153116Sjkoshy.if exists(${_DIR}) & exists(${_DIR}/Makefile)
99153116SjkoshySUBDIR+= ${_DIR}
100153116Sjkoshy.endif
101153116Sjkoshy.endfor
102153116Sjkoshy.endif
103153116Sjkoshy
104153116SjkoshyOBJDIR=		obj
105153116Sjkoshy
106153116Sjkoshy.if defined(NOCLEAN)
107153116SjkoshyCLEANDIR=
108153116Sjkoshy.else
109153116Sjkoshy.if defined(NOCLEANDIR)
11092798SruCLEANDIR=	clean cleandepend
111153116Sjkoshy.else
112153116SjkoshyCLEANDIR=	cleandir
113153116Sjkoshy.endif
114153116Sjkoshy.endif
115153116Sjkoshy
116153116Sjkoshy.if !defined(NOCLEAN)
117153116Sjkoshy_NODEPEND=	true
118153116Sjkoshy.endif
119153116Sjkoshy.if defined(_NODEPEND)
120153116Sjkoshy_DEPEND=	cleandepend
121153116Sjkoshy.else
122153116Sjkoshy_DEPEND=	depend
123153116Sjkoshy.endif
124153116Sjkoshy
125153116SjkoshySUP?=		cvsup
126153116SjkoshySUPFLAGS?=	-g -L 2 -P -
127153116Sjkoshy
128153116Sjkoshy#
129153116Sjkoshy# While building tools for bootstrapping, we don't need to waste time on
130153116Sjkoshy# shared or profiled libraries, shared linkage, or documentation, except
131153116Sjkoshy# when the tools won't get cleaned we must use the defaults for shared
132153116Sjkoshy# libraries and shared linkage (and this doesn't waste time).
133153116Sjkoshy# XXX actually, we do need to waste time building shared libraries.
134153116Sjkoshy#
135153116Sjkoshy.if defined(NOCLEAN)
136153116SjkoshyMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
13792798Sru.else
138153116SjkoshyMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
139153116Sjkoshy.endif
140153116Sjkoshy
141153116Sjkoshy#
142153116Sjkoshy# Define the location of the temporary installation directory. Note that
143153116Sjkoshy# MAKEOBJDIRPREFIX normally isn't defined so if the current directory is
144153116Sjkoshy# /usr/src, then the world temporary directory is /usr/obj/usr/src/tmp.
145153116Sjkoshy#
146153116Sjkoshy# During the transition from aout to elf format on i386, MAKEOBJDIRPREFIX
147153116Sjkoshy# is set by the parent makefile (Makefile.inc0) to be /usr/obj/${OBJFORMAT}
148153116Sjkoshy# in order to keep aout and elf format files apart.
149153116Sjkoshy#
150153116Sjkoshy.if defined(MAKEOBJDIRPREFIX)
151153116SjkoshyWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
152153116Sjkoshy.else
153153116SjkoshyWORLDTMP=	/usr/obj${.CURDIR}/tmp
154153116Sjkoshy.endif
155153116Sjkoshy
156153116Sjkoshy#
157153116Sjkoshy# Define the PATH to the build tools.
158153116Sjkoshy#
159153116Sjkoshy# If not building tools, the PATH always points to the installed binaries.
160153116Sjkoshy# The NOTOOLS option assumes that in installed tools are good enough and that
161153116Sjkoshy# the user's PATH will locate to appropriate tools. This option is required
162153116Sjkoshy# for a cross-compiled build environment.
163153116Sjkoshy#
164153116Sjkoshy# If building tools, then the PATH includes the world temporary directories
165153116Sjkoshy# so that the bootstrapped tools are used as soon as they are built. The
166153116Sjkoshy# strict path is for use after all tools are supposed to have been
167153116Sjkoshy# bootstrapped. It doesn't allow any of the installed tools to be used.
168153116Sjkoshy#
169153116Sjkoshy.if	defined(NOTOOLS)
170153116Sjkoshy# Default root of the tool tree
171153116SjkoshyTOOLROOT?=	
172153116Sjkoshy# Choose the PATH relative to the root of the tool tree
173153116SjkoshyPATH=		${TOOLROOT}/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/sbin:${TOOLROOT}/usr/bin:${TOOLROOT}/usr/games
174153116Sjkoshy.else
175153116SjkoshyTOOLROOT=	${WORLDTMP}
176153116Sjkoshy.endif
177153116SjkoshySTRICTTMPPATH=	${TOOLROOT}/sbin:${TOOLROOT}/usr/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/bin:${TOOLROOT}/usr/games
178153116SjkoshyTMPPATH=	${STRICTTMPPATH}:${PATH}:/usr/games
179153116Sjkoshy
180153116Sjkoshy# XXX COMPILER_PATH is needed for finding cc1, ld and as
181153116Sjkoshy# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecessary now
182153116Sjkoshy#	that LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
183153116Sjkoshy#	wouldn't link *crt.o or libgcc if it were used.
184153116Sjkoshy# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
185153116Sjkoshy#	want that - all compile-time library paths should be resolved by gcc.
186153116Sjkoshy#	It fails for set[ug]id executables (are any used?).
187153116SjkoshyCOMPILER_ENV=	BISON_SIMPLE=${TOOLROOT}/usr/share/misc/bison.simple \
188153116Sjkoshy		COMPILER_PATH=${TOOLROOT}/usr/libexec:${TOOLROOT}/usr/bin \
189153116Sjkoshy		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
190153116Sjkoshy		LD_LIBRARY_PATH=${TOOLROOT}${SHLIBDIR} \
191153116Sjkoshy		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
192153116Sjkoshy
193153116SjkoshyBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t \
194153116Sjkoshy		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec:/usr/libexec
195153116SjkoshyXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
196153116Sjkoshy		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec \
197153116Sjkoshy		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
198153116Sjkoshy
199153116Sjkoshy# used to compile and install 'make' in temporary build tree
200153116SjkoshyMAKETMP=	${WORLDTMP}/make
201153116SjkoshyIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
202153116Sjkoshy
203219857Snwhitehorn.if	defined(NOTOOLS)
204219857Snwhitehorn# bootstrap make
205219857SnwhitehornBMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
206219857Snwhitehorn# cross make used for compilation
207219857SnwhitehornXMAKE=	${XMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
208219857Snwhitehorn# cross make used for final installation
209219857SnwhitehornIXMAKE=	${XMAKEENV} ${MAKE}
210153116Sjkoshy.else
211153116Sjkoshy# bootstrap make
212153116SjkoshyBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
213153116Sjkoshy# cross make used for compilation
214153116SjkoshyXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
215153116Sjkoshy# cross make used for final installation
216153116SjkoshyIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
217156903Sru.endif
218162898Sru
219162901Sru#
220162901Sru# buildworld
221162898Sru#
222162898Sru# Attempt to rebuild the entire system, with reasonable chance of
223156903Sru# success, regardless of how old your existing system is.
224156903Sru#
225156903Srubuildworld: check-objformat
226156903Sru.if !defined(NOCLEAN)
227156903Sru	@echo
228153116Sjkoshy	@echo "--------------------------------------------------------------"
229153116Sjkoshy	@echo ">>> Cleaning up the temporary ${OBJFORMAT} build tree"
230153116Sjkoshy	@echo "--------------------------------------------------------------"
231153116Sjkoshy	mkdir -p ${WORLDTMP}
232218524Sjhb	chflags -R noschg ${WORLDTMP}/
233218524Sjhb	rm -rf ${WORLDTMP}
234153116Sjkoshy.endif
235218524Sjhb.if !defined(NOTOOLS)
236153116Sjkoshy	@echo
237218524Sjhb	@echo "--------------------------------------------------------------"
238218524Sjhb	@echo ">>> Making make"
239218524Sjhb	@echo "--------------------------------------------------------------"
240153116Sjkoshy	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
24192798Sru	( \
242153116Sjkoshy	cd ${.CURDIR}/usr.bin/make; \
243151202Syar		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
244217815Sbz		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
245225859Sgjb		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
246217815Sbz		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
247217815Sbz	)
248217815Sbz	@echo
249217815Sbz	@echo "--------------------------------------------------------------"
250217733Sbz	@echo ">>> Making mtree"
251217733Sbz	@echo "--------------------------------------------------------------"
252217733Sbz	mkdir -p ${WORLDTMP}/usr/sbin ${WORLDTMP}/mtree
253217733Sbz	( \
254217733Sbz	cd ${.CURDIR}/usr.sbin/mtree; \
255218524Sjhb		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
256218524Sjhb		export MAKEOBJDIR=${WORLDTMP}/mtree; \
25769039Sben		${BMAKE} ${MK_FLAGS} all; \
25869039Sben		${BMAKE} ${MK_FLAGS} -B install clean \
259153116Sjkoshy	)
26069039Sben.endif
261153116Sjkoshy	@echo
262219857Snwhitehorn	@echo "--------------------------------------------------------------"
26392798Sru	@echo ">>> Making hierarchy"
26492798Sru	@echo "--------------------------------------------------------------"
26592798Sru	mkdir -p ${WORLDTMP}
266153116Sjkoshy	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 hierarchy
267153116Sjkoshy.if !defined(NOCLEAN)
268153116Sjkoshy	@echo
269153116Sjkoshy	@echo "--------------------------------------------------------------"
270153116Sjkoshy	@echo ">>> Cleaning up the ${OBJFORMAT} obj tree"
271153116Sjkoshy	@echo "--------------------------------------------------------------"
272153116Sjkoshy	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
273153116Sjkoshy.endif
274153116Sjkoshy	@echo
275153116Sjkoshy	@echo "--------------------------------------------------------------"
276153116Sjkoshy	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
277153116Sjkoshy	@echo "--------------------------------------------------------------"
278153116Sjkoshy	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 par-${OBJDIR}
279219857Snwhitehorn.if !defined(NOTOOLS)
280219857Snwhitehorn	@echo
281219857Snwhitehorn	@echo "--------------------------------------------------------------"
282219857Snwhitehorn	@echo ">>> Rebuilding ${OBJFORMAT} bootstrap tools"
283219857Snwhitehorn	@echo "--------------------------------------------------------------"
284219857Snwhitehorn	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap
285219857Snwhitehorn	@echo
286219857Snwhitehorn	@echo "--------------------------------------------------------------"
287219857Snwhitehorn	@echo ">>> Rebuilding tools necessary to build the include files"
288219857Snwhitehorn	@echo "--------------------------------------------------------------"
289219857Snwhitehorn	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 include-tools
290219857Snwhitehorn.endif
291142360Strhodes	@echo
292142360Strhodes	@echo "--------------------------------------------------------------"
293142360Strhodes	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
294142360Strhodes	@echo "--------------------------------------------------------------"
295142360Strhodes	cd ${.CURDIR}; SHARED=copies ${BMAKE} -f Makefile.inc1 includes
296153116Sjkoshy	@echo
297153116Sjkoshy	@echo "--------------------------------------------------------------"
298153116Sjkoshy	@echo ">>> Rebuilding bootstrap libraries"
299153116Sjkoshy	@echo "--------------------------------------------------------------"
300153116Sjkoshy	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap-libraries
301153116Sjkoshy.if !defined(NOTOOLS)
302153116Sjkoshy	@echo
303153116Sjkoshy	@echo "--------------------------------------------------------------"
304153116Sjkoshy	@echo ">>> Rebuilding tools needed to build libraries"
305153116Sjkoshy	@echo "--------------------------------------------------------------"
306153116Sjkoshy	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 lib-tools
307153116Sjkoshy.endif
308153116Sjkoshy.if !defined(NOTOOLS)
309153116Sjkoshy	@echo
310153116Sjkoshy	@echo "--------------------------------------------------------------"
311153116Sjkoshy	@echo ">>> Rebuilding all other tools needed to build the ${OBJFORMAT} world"
312153116Sjkoshy	@echo "--------------------------------------------------------------"
313153116Sjkoshy	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 build-tools
314153116Sjkoshy.endif
315153116Sjkoshy.if !defined(_NODEPEND)
316153116Sjkoshy	@echo
317153116Sjkoshy	@echo "--------------------------------------------------------------"
318165208Smpp	@echo ">>> Rebuilding dependencies"
319148330Snetchild	@echo "--------------------------------------------------------------"
320148330Snetchild	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-depend
321152569Sru.endif
322152569Sru	@echo
323153116Sjkoshy	@echo "--------------------------------------------------------------"
324153116Sjkoshy	@echo ">>> Building ${OBJFORMAT} libraries"
325148683Sru	@echo "--------------------------------------------------------------"
326153116Sjkoshy	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
327153116Sjkoshy	@echo
328148683Sru	@echo "--------------------------------------------------------------"
329148683Sru	@echo ">>> Building everything.."
330148683Sru	@echo "--------------------------------------------------------------"
331148683Sru	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
332148330Snetchild
333148330Snetchildeverything:
334153116Sjkoshy	@echo "--------------------------------------------------------------"
335153116Sjkoshy	@echo ">>> Building everything.."
336152569Sru	@echo "--------------------------------------------------------------"
337152569Sru	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
338153116Sjkoshy
339153116Sjkoshy#
340148683Sru# installworld
341153116Sjkoshy#
342153116Sjkoshy# Installs everything compiled by a 'buildworld'.
343148683Sru#
344148683Sruinstallworld:
345148683Sru	cd ${.CURDIR}; ${IXMAKE} -f Makefile.inc1 reinstall
346148683Sru
34769039Sben#
348153116Sjkoshy# reinstall
349153116Sjkoshy#
350153116Sjkoshy# If you have a build server, you can NFS mount the source and obj directories
351205978Skeramida# and do a 'make reinstall' on the *client* to install new binaries from the
352205978Skeramida# most recent server build.
353205978Skeramida#
354205978Skeramidareinstall:
355205978Skeramida	@echo "--------------------------------------------------------------"
356205978Skeramida	@echo ">>> Making hierarchy"
357205978Skeramida	@echo "--------------------------------------------------------------"
358205978Skeramida	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
359205978Skeramida	@echo
360205978Skeramida	@echo "--------------------------------------------------------------"
361205978Skeramida	@echo ">>> Installing everything.."
362205978Skeramida	@echo "--------------------------------------------------------------"
363205978Skeramida	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
364205978Skeramida.if ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
365153116Sjkoshy	@echo
366153116Sjkoshy	@echo "--------------------------------------------------------------"
367153116Sjkoshy	@echo ">>> Re-scanning the shared libraries.."
368153116Sjkoshy	@echo "--------------------------------------------------------------"
369153116Sjkoshy	cd ${.CURDIR}; /sbin/ldconfig -R
370153116Sjkoshy.endif
371153116Sjkoshy	@echo
372153116Sjkoshy	@echo "--------------------------------------------------------------"
373153116Sjkoshy	@echo ">>> Rebuilding man page indexes"
374153116Sjkoshy	@echo "--------------------------------------------------------------"
375153116Sjkoshy	cd ${.CURDIR}/share/man; ${MAKE} makedb
376153116Sjkoshy
377153116Sjkoshy#
378153116Sjkoshy# update
379153116Sjkoshy#
380153116Sjkoshy# Update the source tree, by running sup and/or running cvs to update to the
381206082Snetchild# latest copy.
382206082Snetchild#
383206082Snetchildupdate:
384153116Sjkoshy.if defined(SUP_UPDATE)
38569039Sben	@echo "--------------------------------------------------------------"
386153116Sjkoshy	@echo ">>> Running ${SUP}"
387153116Sjkoshy	@echo "--------------------------------------------------------------"
388153116Sjkoshy	@${SUP} ${SUPFLAGS} ${SUPFILE}
389153116Sjkoshy.if defined(SUPFILE1)
390153116Sjkoshy	@${SUP} ${SUPFLAGS} ${SUPFILE1}
391153116Sjkoshy.endif
392187638Simp.if defined(SUPFILE2)
393187638Simp	@${SUP} ${SUPFLAGS} ${SUPFILE2}
394187638Simp.endif
395187638Simp.endif
396187638Simp.if defined(CVS_UPDATE)
397187638Simp	@echo "--------------------------------------------------------------"
398187638Simp	@echo ">>> Updating /usr/src from cvs repository" ${CVSROOT}
399187638Simp	@echo "--------------------------------------------------------------"
400225859Sgjb	cd ${.CURDIR}; cvs -q update -P -d
401187638Simp.endif
402200597Simp
403225859Sgjb#
404187638Simp# most
405200597Simp#
406187638Simp# Build most of the user binaries on the existing system libs and includes.
407187638Simp#
408225859Sgjbmost:
409225859Sgjb	@echo "--------------------------------------------------------------"
410225859Sgjb	@echo ">>> Building programs only"
411187638Simp	@echo "--------------------------------------------------------------"
412153116Sjkoshy	cd ${.CURDIR}/bin;		${MAKE} all
413264075Sbdrewery	cd ${.CURDIR}/sbin;		${MAKE} all
414264075Sbdrewery	cd ${.CURDIR}/libexec;		${MAKE} all
415264075Sbdrewery	cd ${.CURDIR}/usr.bin;		${MAKE} all
416264075Sbdrewery	cd ${.CURDIR}/usr.sbin;		${MAKE} all
417267823Sbdrewery	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
418267823Sbdrewery	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
419267823Sbdrewery	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
420267823Sbdrewery#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
421267823Sbdrewery#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
422267823Sbdrewery#.endif
423264075Sbdrewery#.if !defined(NOSECURE) && !defined(NOCRYPT)
424264075Sbdrewery#	cd ${.CURDIR}/secure;		${MAKE} most
425264075Sbdrewery#.endif
426264075Sbdrewery
427264075Sbdrewery#
428264075Sbdrewery# installmost
429264075Sbdrewery#
430264075Sbdrewery# Install the binaries built by the 'most' target.  This does not include
431264075Sbdrewery# libraries or include files.
432264075Sbdrewery#
433264075Sbdreweryinstallmost:
434264075Sbdrewery	@echo "--------------------------------------------------------------"
435264075Sbdrewery	@echo ">>> Installing programs only"
436264075Sbdrewery	@echo "--------------------------------------------------------------"
437264075Sbdrewery	cd ${.CURDIR}/bin;		${MAKE} install
438225858Sgjb	cd ${.CURDIR}/sbin;		${MAKE} install
439225858Sgjb	cd ${.CURDIR}/libexec;		${MAKE} install
440225858Sgjb	cd ${.CURDIR}/usr.bin;		${MAKE} install
441225858Sgjb	cd ${.CURDIR}/usr.sbin;		${MAKE} install
442225858Sgjb	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
443225858Sgjb	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
444225858Sgjb	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
445225858Sgjb#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
446225858Sgjb#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
447225858Sgjb#.endif
448276674Sngie#.if !defined(NOSECURE) && !defined(NOCRYPT)
449276310Sngie#	cd ${.CURDIR}/secure;		${MAKE} installmost
450276310Sngie#.endif
451276674Sngie
452276310Sngie#
453276310Sngie# ------------------------------------------------------------------------
454276310Sngie#
455276310Sngie# From here onwards are utility targets used by the 'make world' and
456276310Sngie# related targets.  If your 'world' breaks, you may like to try to fix
457276310Sngie# the problem and manually run the following targets to attempt to
458276310Sngie# complete the build.  Beware, this is *not* guaranteed to work, you
459276310Sngie# need to have a pretty good grip on the current state of the system
460276310Sngie# to attempt to manually finish it.  If in doubt, 'make world' again.
461276310Sngie#
462276310Sngie
463153116Sjkoshy#
464153116Sjkoshy# hierarchy - ensure that all the needed directories are present
465153116Sjkoshy#
466153116Sjkoshyhierarchy:
467153116Sjkoshy	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
468153116Sjkoshy
469153116Sjkoshy#
47092380Smurray# bootstrap - [re]build tools needed to run the actual build, this includes
47192379Smurray# tools needed by 'make depend', as some tools are needed to generate source
47292503Smurray# for the dependency information to be gathered from.
47392798Sru#
47492379Smurraybootstrap:
47592379Smurray.if defined(DESTDIR)
47692379Smurray	rm -f ${DESTDIR}/usr/src/sys
47792798Sru	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
47892379Smurray	cd ${.CURDIR}/include; find -dx . | cpio -dump ${DESTDIR}/usr/include
47992798Sru.for d in net netatm netinet posix4 sys vm machine
480153116Sjkoshy	if [ -h ${DESTDIR}/usr/include/$d ]; then \
481153116Sjkoshy		rm -f ${DESTDIR}/usr/include/$d ; \
482153116Sjkoshy	fi
483153116Sjkoshy.endfor
484153116Sjkoshy	cd ${.CURDIR}/sys; \
485153116Sjkoshy		find -dx net netatm netinet posix4 sys vm -name '*.h' -o -type d | \
486153116Sjkoshy		cpio -dump ${DESTDIR}/usr/include
487153116Sjkoshy	mkdir -p ${DESTDIR}/usr/include/machine
488153116Sjkoshy	cd ${.CURDIR}/sys/${MACHINE_ARCH}/include; find -dx . -name '*.h' -o -type d | \
489153116Sjkoshy		cpio -dump ${DESTDIR}/usr/include/machine
490153116Sjkoshy.endif
491225859Sgjb	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
492174542Simp		${MAKE} ${MK_FLAGS} all; \
493174542Simp		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
494174542Simp	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
495225859Sgjb		${MAKE} ${MK_FLAGS} all; \
496187637Simp		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
49792264Smurray	cd ${.CURDIR}/usr.bin/yacc; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
498153116Sjkoshy		${MAKE} ${MK_FLAGS} all; \
499153116Sjkoshy		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
500186783Skeramida	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
501214374Sgjb		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
502186783Skeramida		${MAKE} ${MK_FLAGS} -DNOLIB all; \
503186783Skeramida		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
504186783Skeramida	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
505186783Skeramida	cd ${.CURDIR}/usr.sbin/mtree; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
506186783Skeramida		${MAKE} ${MK_FLAGS} all; \
507186783Skeramida		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
508186783Skeramida.if defined(DESTDIR)
509186783Skeramida	cd ${.CURDIR}/include && ${MAKE} copies
510186783Skeramida.endif
511186783Skeramida
512186783Skeramida#
513186783Skeramida# include-tools - generally the same as 'bootstrap', except that it's for
514186783Skeramida# things that are specifically needed to generate include files.
515186783Skeramida#
516186783Skeramida# XXX should be merged with bootstrap, it's not worth keeeping them separate.
517186783Skeramida# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
518186783Skeramida# on cleaned away headers in ${WORLDTMP}.
519186783Skeramida#
520186783Skeramidainclude-tools:
521186783Skeramida.for d in usr.bin/compile_et usr.bin/rpcgen
522186783Skeramida	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
523186783Skeramida		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
524186783Skeramida		${MAKE} ${MK_FLAGS} all; \
525186783Skeramida		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
526186783Skeramida.endfor
527186783Skeramida
528237655Swblock#
529186783Skeramida# includes - possibly generate and install the include files.
530186783Skeramida#
531186783Skeramidaincludes:
532186783Skeramida.if defined(CLOBBER)
533186783Skeramida	rm -rf ${DESTDIR}/usr/include/*
534186783Skeramida	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
535186783Skeramida		-p ${DESTDIR}/usr/include
536186783Skeramida.endif
537186783Skeramida	cd ${.CURDIR}/include;			${MAKE} -B all install
538186783Skeramida	cd ${.CURDIR}/gnu/include;		${MAKE} install
539186783Skeramida	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
540186783Skeramida	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
541186783Skeramida	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
542186783Skeramida	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
543186783Skeramida	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
544186783Skeramida	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
545186783Skeramida	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
546186783Skeramida	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
547186783Skeramida.if exists(secure) && !defined(NOCRYPT)
548186783Skeramida	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
549186783Skeramida.endif
550200597Simp.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
551200597Simp	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
552200597Simp	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
553200597Simp	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
554200597Simp	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
555200597Simp	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
556186783Skeramida	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
557186783Skeramida.else
558186783Skeramida	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
559186783Skeramida.endif
560186783Skeramida.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
561186783Skeramida	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
562186783Skeramida.endif
563186783Skeramida	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
564186783Skeramida	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
565186783Skeramida	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
566223148Sru	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
567223148Sru	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
568223148Sru	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
569223148Sru	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
570186783Skeramida	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
571186783Skeramida	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
572186783Skeramida	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
573153116Sjkoshy	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
574153116Sjkoshy	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
575153116Sjkoshy	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
576153116Sjkoshy.if !defined(WANT_CSRG_LIBM)
577153116Sjkoshy	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
578153116Sjkoshy.endif
579153116Sjkoshy	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
580153116Sjkoshy	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
581153116Sjkoshy	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
582153116Sjkoshy	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
583218524Sjhb	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
584218524Sjhb	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
585218524Sjhb	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
586218524Sjhb	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
587218524Sjhb	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
588218524Sjhb	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
589218524Sjhb	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
590218524Sjhb	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
591218524Sjhb
592218524Sjhb#
593218524Sjhb# Declare tools if they are not required on all architectures.
594218524Sjhb#
595218524Sjhb.if ${MACHINE_ARCH} == "i386"
596218524Sjhb# aout tools:
597218524Sjhb_aout_ar	= usr.bin/ar
598218524Sjhb_aout_as	= gnu/usr.bin/as
599218524Sjhb_aout_ld	= gnu/usr.bin/ld
600218524Sjhb_aout_nm	= usr.bin/nm
601218524Sjhb_aout_ranlib	= usr.bin/ranlib
602218524Sjhb_aout_size	= usr.bin/size
603218524Sjhb_aout_strip	= usr.bin/strip
604218524Sjhb.endif
605218524Sjhb
60669039Sben#
60782953Sru# lib-tools - build tools to compile and install the libraries.
60869039Sben#
60969039Sben# XXX gperf is required for cc
61082953Sru# XXX a new ld and tsort is required for cc
61182953Srulib-tools:
61292798Sru.for d in				\
61369039Sben		gnu/usr.bin/gperf	\
61469039Sben		${_aout_ld}		\
61570466Sru		usr.bin/tsort		\
61669092Sben		${_aout_as}		\
617133648Sru		gnu/usr.bin/bison	\
61869092Sben		gnu/usr.bin/cc		\
619153116Sjkoshy		${_aout_ar}		\
620133648Sru		usr.bin/env		\
621133648Sru		usr.bin/lex/lib		\
622133648Sru		usr.bin/mk_cmds		\
62369092Sben		${_aout_nm}		\
62492264Smurray		${_aout_ranlib}		\
625158622Smaxim		${_aout_strip}		\
62692264Smurray		gnu/usr.bin/binutils	\
62792264Smurray		usr.bin/uudecode	\
628174542Simp		share/info		\
629174542Simp		usr.bin/objformat
63092264Smurray	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
63169039Sben		${MAKE} ${MK_FLAGS} all; \
63269094Sben		${MAKE} ${MK_FLAGS} -B install; \
63369039Sben		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
63469039Sben.endfor
635237655Swblock
63669039Sben#
637159501Sjkoshy# We have to know too much about ordering and subdirs in the lib trees:
63869093Sben#
63992215Smurray# To satisfy shared library linkage when only the libraries being built
640142412Strhodes# are visible:
64169111Sben#
642238008Swblock# libcom_err must be built before libss.
64369093Sben# libcrypt and libmd must be built before libskey.
64469093Sben# libmytinfo must be built before libdialog and libncurses.
64569039Sben# libncurses must be built before libdialog.
64669039Sben# libtermcap must be built before libcurses, libedit and libreadline.
647#
648# Some libraries are built conditionally and/or are in inconsistently
649# named directories:
650#
651.if exists(lib/csu/${MACHINE_ARCH}.pcc)
652_csu=lib/csu/${MACHINE_ARCH}.pcc
653.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
654_csu=lib/csu/i386-elf
655.else
656_csu=lib/csu/${MACHINE_ARCH}
657.endif
658
659.if !defined(NOSECURE) && !defined(NOCRYPT)
660_libcrypt=	secure/lib/libcrypt lib/libcrypt
661.else
662_libcrypt=	lib/libcrypt
663.endif
664
665.if defined(WANT_CSRG_LIBM)
666_libm=	lib/libm
667.else
668_libm=	lib/msun
669.endif
670
671#
672# bootstrap-libraries - build just enough libraries for the bootstrap
673# tools, and install them under ${WORLDTMP}.
674#
675# Build csu and libgcc early so that some tools get linked to the new
676# versions (too late for the main tools, however).  Then build the
677# necessary prerequisite libraries (libtermcap just needs to be before
678# libcurses, and this only matters for the NOCLEAN case when NOPIC is
679# not set).
680#
681# This is mostly wrong.  The build tools must run on the host system,
682# so they should use host libraries.  We depend on the target being
683# similar enough to the host for new target libraries to work on the
684# host.
685#
686bootstrap-libraries:
687.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
688    gnu/lib/libregex gnu/lib/libreadline lib/libc \
689    ${_libcrypt} lib/libcurses lib/libedit ${_libm} \
690    lib/libmd lib/libutil lib/libz usr.bin/lex/lib \
691    gnu/usr.bin/perl/libperl
692.if exists(${.CURDIR}/${_lib})
693	cd ${.CURDIR}/${_lib}; \
694		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
695		${MAKE} ${MK_FLAGS} all; \
696		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
697.endif
698.endfor
699
700#
701# libraries - build all libraries, and install them under ${DESTDIR}.
702#
703# The ordering is not as special as for bootstrap-libraries.  Build
704# the prerequisites first, then build almost everything else in
705# alphabetical order.
706#
707libraries:
708.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
709    lib/libncurses lib/libtermcap \
710    gnu/lib gnu/usr.bin/cc/libgcc lib usr.bin/lex/lib usr.sbin/pcvt/keycap
711.if exists(${.CURDIR}/${_lib})
712	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
713.endif
714.endfor
715.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
716	cd ${.CURDIR}/secure/lib; ${MAKE} all; ${MAKE} -B install
717.endif
718.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
719    defined(MAKE_KERBEROS4)
720	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} all; ${MAKE} -B install
721.endif
722
723#
724# Exclude unused tools from build-tools.
725#
726.if !defined(NOGAMES) && exists(${.CURDIR}/games)
727_adventure=	games/adventure
728_caesar=	games/caesar
729_hack=		games/hack
730_phantasia=	games/phantasia
731_strfile=	games/fortune/strfile
732.endif
733.if !defined(NOPERL)
734_perl=		gnu/usr.bin/perl/miniperl
735.endif
736.if !defined(NOSHARE) && exists(${.CURDIR}/share)
737_scrnmaps=	share/syscons/scrnmaps
738.endif
739.if !defined(NOLKM) && exists(${.CURDIR}/lkm) && ${OBJFORMAT} == "aout"
740_linux=		lkm/linux
741.endif
742.if ${OBJFORMAT} == "aout"
743_netboot=	sys/${MACHINE}/boot/netboot
744.endif
745
746BTMAKEFLAGS=	${MK_FLAGS} -D_BUILD_TOOLS
747
748#
749# build-tools - build and install any other tools needed to complete the
750# compile and install.
751# ifdef stale
752# bc and cpp are required to build groff.  Otherwise, the order here is
753# mostly historical, i.e., bogus.
754# chmod is used to build gcc's tmpmultilib[2] at obscure times.
755# endif stale
756# XXX uname is a bug - the target should not depend on the host.
757#
758build-tools:
759.for d in				\
760		bin/cat 		\
761		bin/chmod		\
762		bin/cp 			\
763		bin/date		\
764		bin/dd			\
765		bin/echo		\
766		bin/expr		\
767		bin/hostname		\
768		bin/ln			\
769		bin/ls			\
770		bin/mkdir		\
771		bin/mv			\
772		bin/rm			\
773		bin/test		\
774		${_caesar}		\
775		${_strfile}		\
776		gnu/usr.bin/awk		\
777		gnu/usr.bin/bc		\
778		gnu/usr.bin/grep	\
779		gnu/usr.bin/groff	\
780		gnu/usr.bin/gzip	\
781		gnu/usr.bin/man/makewhatis	\
782		gnu/usr.bin/patch	\
783		${_perl}		\
784		gnu/usr.bin/sort	\
785		gnu/usr.bin/texinfo	\
786		usr.bin/basename	\
787		usr.bin/cap_mkdb	\
788		usr.bin/chflags		\
789		usr.bin/cmp		\
790		usr.bin/col		\
791		usr.bin/colldef		\
792		usr.bin/cpp		\
793		usr.bin/expand		\
794		usr.bin/file2c		\
795		usr.bin/find		\
796		usr.bin/gencat		\
797		usr.bin/id		\
798		usr.bin/join		\
799		usr.bin/lorder		\
800		usr.bin/m4		\
801		usr.bin/mkdep		\
802		usr.bin/mklocale	\
803		usr.bin/paste		\
804		usr.bin/sed		\
805		${_aout_size}		\
806		usr.bin/soelim		\
807		usr.bin/symorder	\
808		usr.bin/touch		\
809		usr.bin/tr		\
810		usr.bin/true		\
811		usr.bin/uname		\
812		usr.bin/uuencode	\
813		usr.bin/vgrind		\
814		usr.bin/vi		\
815		usr.bin/wc		\
816		usr.bin/xargs		\
817		usr.bin/yacc		\
818		usr.sbin/chown		\
819		usr.sbin/mtree		\
820		usr.sbin/zic		\
821		bin/sh
822	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} ${_DEPEND}; \
823		${MAKE} ${BTMAKEFLAGS} all; \
824		${MAKE} ${BTMAKEFLAGS} -B install ${CLEANDIR} ${OBJDIR}
825.endfor
826.if !defined(NOGAMES) && exists(${.CURDIR}/games)
827	cd ${DESTDIR}/usr/games; cp -p caesar strfile ${DESTDIR}/usr/bin
828.endif
829.for d in				\
830		bin/sh			\
831		${_adventure}		\
832		${_hack}		\
833		${_phantasia}		\
834		gnu/usr.bin/cc/cc_tools	\
835		lib/libmytinfo		\
836		${_linux}		\
837		${_scrnmaps}		\
838		${_netboot}
839	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} build-tools
840.endfor
841	cd ${.CURDIR}/usr.bin/tn3270/tools; ${MAKE} ${BTMAKEFLAGS} all
842
843#
844# Build aout versions of things that provide legacy support when all the
845# rest of the world is elf.
846#
847legacy-build:
848.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
849	@echo
850	@echo "--------------------------------------------------------------"
851	@echo ">>> Making hierarchy"
852	@echo "--------------------------------------------------------------"
853	mkdir -p ${WORLDTMP}
854	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 hierarchy
855	@echo
856	@echo "--------------------------------------------------------------"
857	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
858	@echo "--------------------------------------------------------------"
859	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-${OBJDIR}
860	@echo
861	@echo "--------------------------------------------------------------"
862	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
863	@echo "--------------------------------------------------------------"
864	cd ${.CURDIR}; SHARED=copies ${XMAKE} -f Makefile.inc1 includes
865	@echo
866	@echo "--------------------------------------------------------------"
867	@echo ">>> Building legacy libraries"
868	@echo "--------------------------------------------------------------"
869	cd ${.CURDIR}; \
870		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 bootstrap-libraries
871	cd ${.CURDIR}; \
872		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
873	@echo
874	@echo "--------------------------------------------------------------"
875	@echo ">>> Building legacy rtld"
876	@echo "--------------------------------------------------------------"
877	cd ${.CURDIR}/libexec/rtld-aout; \
878		${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
879	@echo
880	@echo "--------------------------------------------------------------"
881	@echo ">>> Building legacy lkms"
882	@echo "--------------------------------------------------------------"
883	cd ${.CURDIR}/lkm; \
884		${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
885	@echo
886	@echo "--------------------------------------------------------------"
887	@echo ">>> Building legacy boot"
888	@echo "--------------------------------------------------------------"
889	cd ${.CURDIR}/sys/${MACHINE}/boot; \
890		${XMAKE} -DNOMAN depend; ${XMAKE} -DNOMAN all;
891.endif
892
893#
894# Install aout versions of things that provide legacy support when all the
895# rest of the world is elf.
896#
897legacy-install:
898.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
899	@echo
900	@echo "--------------------------------------------------------------"
901	@echo ">>> Installing legacy libraries"
902	@echo "--------------------------------------------------------------"
903	cd ${.CURDIR}/lib; ${MAKE} -B -DNOMAN -DNOINFO install
904	cd ${.CURDIR}/gnu/lib; ${MAKE} -B -DNOMAN -DNOINFO install
905	cd ${.CURDIR}/gnu/usr.bin/cc/libgcc; \
906		${MAKE} -B -DNOMAN -DNOINFO install
907	cd ${.CURDIR}/usr.bin/lex/lib; \
908		${MAKE} -B -DNOMAN -DNOINFO install
909	cd ${.CURDIR}/usr.sbin/pcvt/keycap; \
910		${MAKE} -B -DNOMAN -DNOINFO install
911.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
912	cd ${.CURDIR}/secure/lib; ${MAKE} -B -DNOMAN -DNOINFO install
913.endif
914.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
915    defined(MAKE_KERBEROS4)
916	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} -B -DNOMAN -DNOINFO install
917.endif
918	@echo
919	@echo "--------------------------------------------------------------"
920	@echo ">>> Installing legacy rtld"
921	@echo "--------------------------------------------------------------"
922	cd ${.CURDIR}/libexec/rtld-aout; ${MAKE} -DNOMAN install
923	@echo
924	@echo "--------------------------------------------------------------"
925	@echo ">>> Installing legacy lkms"
926	@echo "--------------------------------------------------------------"
927	cd ${.CURDIR}/lkm; ${MAKE} -DNOMAN install
928	@echo
929	@echo "--------------------------------------------------------------"
930	@echo ">>> Installing legacy boot"
931	@echo "--------------------------------------------------------------"
932	cd ${.CURDIR}/sys/${MACHINE}/boot; ${MAKE} -DNOMAN install
933.endif
934
935
936# Get the object format that the tools see.
937#
938#
939.if exists(/usr/bin/objformat)
940__OBJFORMAT!=	objformat
941.else
942__OBJFORMAT=	${OBJFORMAT}
943.endif
944
945#
946# Check if the local /etc/make.conf or /etc/make.conf.local have attempted
947# to override the OBJFORMAT without updating the environment for the tools
948# to see.
949#
950check-objformat	:
951.if	${__OBJFORMAT} != ${OBJFORMAT}
952	@/bin/sh -c "echo \"It looks like you set OBJFORMAT=${OBJFORMAT} in /etc/make.conf. Don't do that!\" "
953	@/bin/sh -c "echo \"If you want to override the installed object format, you must set OBJFORMAT\" "
954	@/bin/sh -c "echo \"in your environment.\" "
955	@exit 1
956.endif
957
958
959.for __target in clean cleandepend cleandir depend obj
960.for entry in ${SUBDIR}
961${entry}.${__target}__D: .PHONY
962	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
963		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
964		edir=${entry}.${MACHINE_ARCH}; \
965		cd ${.CURDIR}/$${edir}; \
966	else \
967		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
968		edir=${entry}; \
969		cd ${.CURDIR}/$${edir}; \
970	fi; \
971	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
972.endfor
973par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
974.endfor
975
976.include <bsd.subdir.mk>
977