Makefile revision 36419
1181905Sed#
2181905Sed#	$Id: Makefile,v 1.182 1998/05/27 07:59:31 sos Exp $
3181905Sed#
4181905Sed# While porting to the another architecture include the bootstrap instead
5181905Sed# of the normal build.
6181905Sed#
7181905Sed.if exists(${.CURDIR}/Makefile.${MACHINE}) && defined(BOOTSTRAP_WORLD)
8181905Sed.include "${.CURDIR}/Makefile.${MACHINE}"
9181905Sed.else
10181905Sed#
11181905Sed# Make command line options:
12181905Sed#	-DCLOBBER will remove /usr/include
13181905Sed#	-DMAKE_KERBEROS4 to build KerberosIV
14181905Sed#	-DALLLANG to build documentation for all languages
15181905Sed#	  (where available -- see share/doc/Makefile)
16181905Sed#
17181905Sed#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
18181905Sed#	-DNOCLEAN do not clean at all
19181905Sed#	-DNOTOOLS do not rebuild any tools first
20181905Sed#	-DNOCRYPT will prevent building of crypt versions
21181905Sed#	-DNOLKM do not build loadable kernel modules
22181905Sed#	-DNOOBJDIR do not run ``${MAKE} obj''
23181905Sed#	-DNOPROFILE do not build profiled libraries
24181905Sed#	-DNOSECURE do not go into secure subdir
25181905Sed#	-DNOGAMES do not go into games subdir
26181905Sed#	-DNOSHARE do not go into share subdir
27181905Sed#	-DNOINFO do not make or install info files
28181905Sed#	-DNOLIBC_R do not build libc_r.
29181905Sed#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
30181905Sed
31181905Sed#
32181905Sed# The intended user-driven targets are:
33181905Sed# buildworld  - rebuild *everything*, including glue to help do upgrades
34181905Sed# installworld- install everything built by "buildworld"
35181905Sed# world       - buildworld + installworld
36181905Sed# update      - convenient way to update your source tree (eg: sup/cvs)
37181905Sed# most        - build user commands, no libraries or include files
38181905Sed# installmost - install user commands, no libraries or include files
39181905Sed#
40181905Sed# Standard targets (not defined here) are documented in the makefiles in
41181905Sed# /usr/share/mk.  These include:
42181905Sed#		obj depend all install clean cleandepend cleanobj
43181905Sed
44181905Sed.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
45181905Sed.MAKEFLAGS:=	-m ${.CURDIR}/share/mk ${.MAKEFLAGS}
46181905Sed.endif
47181905Sed
48181905Sed# Put initial settings here.
49181905SedSUBDIR=
50181905Sed
51181905Sed# We must do share/info early so that installation of info `dir'
52181905Sed# entries works correctly.  Do it first since it is less likely to
53181905Sed# grow dependencies on include and lib than vice versa.
54181905Sed.if exists(share/info)
55181905SedSUBDIR+= share/info
56181905Sed.endif
57181905Sed
58181905Sed# We must do include and lib early so that the perl *.ph generation
59181905Sed# works correctly as it uses the header files installed by this.
60181905Sed.if exists(include)
61181905SedSUBDIR+= include
62181905Sed.endif
63181905Sed.if exists(lib)
64192546SedSUBDIR+= lib
65192544Sed.endif
66192544Sed
67181905Sed.if exists(bin)
68181905SedSUBDIR+= bin
69181905Sed.endif
70181905Sed.if exists(games) && !defined(NOGAMES)
71181905SedSUBDIR+= games
72181905Sed.endif
73181905Sed.if exists(gnu)
74181905SedSUBDIR+= gnu
75181905Sed.endif
76181905Sed.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && \
77181905Sed    defined(MAKE_KERBEROS4)
78188096SedSUBDIR+= kerberosIV
79188096Sed.endif
80188096Sed.if exists(libexec)
81188096SedSUBDIR+= libexec
82181905Sed.endif
83181905Sed.if exists(sbin)
84181905SedSUBDIR+= sbin
85181905Sed.endif
86188096Sed.if exists(share) && !defined(NOSHARE)
87188096SedSUBDIR+= share
88188096Sed.endif
89188096Sed.if exists(sys)
90188096SedSUBDIR+= sys
91188096Sed.endif
92188096Sed.if exists(usr.bin)
93188096SedSUBDIR+= usr.bin
94188096Sed.endif
95188096Sed.if exists(usr.sbin)
96188096SedSUBDIR+= usr.sbin
97188096Sed.endif
98188096Sed.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
99188096SedSUBDIR+= secure
100188096Sed.endif
101188096Sed.if exists(lkm) && !defined(NOLKM)
102188096SedSUBDIR+= lkm
103188096Sed.endif
104188096Sed
105188096Sed# etc must be last for "distribute" to work
106188096Sed.if exists(etc) && make(distribute)
107188096SedSUBDIR+= etc
108188096Sed.endif
109188096Sed
110188096Sed# These are last, since it is nice to at least get the base system
111188096Sed# rebuilt before you do them.
112188096Sed.if defined(LOCAL_DIRS)
113188096Sed.for _DIR in ${LOCAL_DIRS}
114188096Sed.if exists(${_DIR}) & exists(${_DIR}/Makefile)
115181905SedSUBDIR+= ${_DIR}
116181905Sed.endif
117181905Sed.endfor
118181905Sed.endif
119181905Sed
120182471Sed# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
121181905Sed.if defined(NOOBJDIR)
122182471SedOBJDIR=
123181905Sed.else
124181905SedOBJDIR=		obj
125181905Sed.endif
126181905Sed
127181905Sed.if defined(NOCLEAN)
128181905SedCLEANDIR=
129181905Sed.else
130181905Sed.if defined(NOCLEANDIR)
131181905SedCLEANDIR=	clean cleandepend
132181905Sed.else
133181905SedCLEANDIR=	cleandir
134181905Sed.endif
135181905Sed.endif
136181905Sed
137188096Sed.if !defined(NOCLEAN) && ${.MAKEFLAGS:M-j} == ""
138181905Sed_NODEPEND=	true
139182471Sed.endif
140181905Sed.if defined(_NODEPEND)
141182471Sed_DEPEND=	cleandepend
142182471Sed.else
143182471Sed_DEPEND=	depend
144182471Sed.endif
145223575Sed
146182471SedSUP?=		cvsup
147182471SedSUPFLAGS?=	-g -L 2 -P -
148181905Sed
149188096Sed#
150188096Sed# While building tools for bootstrapping, we don't need to waste time on
151181905Sed# shared or profiled libraries, shared linkage, or documentation, except
152181905Sed# when the tools won't get cleaned we must use the defaults for shared
153182471Sed# libraries and shared linkage (and this doesn't waste time).
154182471Sed# XXX actually, we do need to waste time building shared libraries.
155181905Sed#
156181905Sed.if defined(NOCLEAN)
157181905SedMK_FLAGS=	-DNOINFO -DNOMAN         -DNOPROFILE
158181905Sed.else
159181905SedMK_FLAGS=	-DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
160181905Sed.endif
161181905Sed
162181905Sed#
163181905Sed# world
164181905Sed#
165181905Sed# Attempt to rebuild and reinstall *everything*, with reasonable chance of
166181905Sed# success, regardless of how old your existing system is.
167181905Sed#
168181905Sed# >> Beware, it overwrites the local build environment! <<
169181905Sed#
170181905Sedworld:
171181905Sed	@echo "--------------------------------------------------------------"
172188096Sed	@echo "make world started on `LC_TIME=C date`"
173181905Sed	@echo "--------------------------------------------------------------"
174181905Sed.if target(pre-world)
175181905Sed	@echo
176181905Sed	@echo "--------------------------------------------------------------"
177181905Sed	@echo " Making 'pre-world' target"
178181905Sed	@echo "--------------------------------------------------------------"
179181905Sed	cd ${.CURDIR}; ${MAKE} pre-world
180181905Sed.endif
181181905Sed	cd ${.CURDIR}; ${MAKE} buildworld
182181905Sed	cd ${.CURDIR}; ${MAKE} -B installworld
183181905Sed.if target(post-world)
184181905Sed	@echo
185181905Sed	@echo "--------------------------------------------------------------"
186181905Sed	@echo " Making 'post-world' target"
187181905Sed	@echo "--------------------------------------------------------------"
188181905Sed	cd ${.CURDIR}; ${MAKE} post-world
189181905Sed.endif
190181905Sed	@echo
191181905Sed	@echo "--------------------------------------------------------------"
192181905Sed	@echo "make world completed on `LC_TIME=C date`"
193181905Sed	@echo "--------------------------------------------------------------"
194181905Sed
195181905Sed.if defined(MAKEOBJDIRPREFIX)
196181905SedWORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
197181905Sed.else
198181905SedWORLDTMP=	/usr/obj${.CURDIR}/tmp
199181905Sed.endif
200181905SedSTRICTTMPPATH=	${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
201188096SedTMPPATH=	${STRICTTMPPATH}:${PATH}
202181905Sed
203181905Sed# XXX COMPILER_PATH is needed for finding cc1, ld and as
204181905Sed# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecssary now
205181905Sed#	tbat LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
206181905Sed#	wouldn't link *crt.o or libgcc if it were used.
207181905Sed# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
208181905Sed#	want that - all compile-time library paths should be resolved by gcc.
209188096Sed#	It fails for set[ug]id executables (are any used?).
210181905SedCOMPILER_ENV=	BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
211188096Sed		OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
212181905Sed		COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
213181905Sed		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
214181905Sed		LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
215181905Sed		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
216181905Sed
217181905SedBMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
218181905SedXMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
219181905Sed		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
220181905Sed
221181905Sed# used to compile and install 'make' in temporary build tree
222181905SedMAKETMP=	${WORLDTMP}/make
223181905SedIBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
224181905Sed# bootstrap make
225181905SedBMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
226181905Sed# cross make used for compilation
227181905SedXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
228181905Sed# cross make used for final installation
229182471SedIXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
230188096Sed
231181905Sed#
232181905Sed# buildworld
233181905Sed#
234181905Sed# Attempt to rebuild the entire system, with reasonable chance of
235181905Sed# success, regardless of how old your existing system is.
236181905Sed#
237181905Sedbuildworld:
238181905Sed.if !defined(NOCLEAN)
239181905Sed	@echo
240181905Sed	@echo "--------------------------------------------------------------"
241181905Sed	@echo " Cleaning up the temporary build tree"
242181905Sed	@echo "--------------------------------------------------------------"
243181905Sed	mkdir -p ${WORLDTMP}
244181905Sed	chflags -R noschg ${WORLDTMP}/
245182471Sed	rm -rf ${WORLDTMP}
246181905Sed.endif
247182471Sed.if !defined(NOTOOLS)
248182471Sed	@echo
249182471Sed	@echo "--------------------------------------------------------------"
250182471Sed	@echo " Making make"
251181905Sed	@echo "--------------------------------------------------------------"
252181905Sed	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
253181905Sed	( \
254181905Sed	cd ${.CURDIR}/usr.bin/make; \
255181905Sed		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
256181905Sed		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
257181905Sed		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
258181905Sed		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
259181905Sed	)
260181905Sed.endif
261181905Sed	@echo
262181905Sed	@echo "--------------------------------------------------------------"
263181905Sed	@echo " Making hierarchy"
264181905Sed	@echo "--------------------------------------------------------------"
265181905Sed	cd ${.CURDIR}; ${BMAKE} hierarchy
266181905Sed.if !defined(NOCLEAN)
267181905Sed	@echo
268181905Sed	@echo "--------------------------------------------------------------"
269181905Sed	@echo " Cleaning up the obj tree"
270181905Sed	@echo "--------------------------------------------------------------"
271181905Sed	cd ${.CURDIR}; ${BMAKE} ${CLEANDIR:S/^/par-/}
272181905Sed.endif
273181905Sed.if !defined(NOOBJDIR)
274181905Sed	@echo
275181905Sed	@echo "--------------------------------------------------------------"
276181905Sed	@echo " Rebuilding the obj tree"
277181905Sed	@echo "--------------------------------------------------------------"
278181905Sed	cd ${.CURDIR}; ${BMAKE} par-${OBJDIR}
279223575Sed.endif
280181905Sed.if !defined(NOTOOLS)
281181905Sed	@echo
282181905Sed	@echo "--------------------------------------------------------------"
283181905Sed	@echo " Rebuilding bootstrap tools"
284181905Sed	@echo "--------------------------------------------------------------"
285181905Sed	cd ${.CURDIR}; ${BMAKE} bootstrap
286188096Sed	@echo
287181905Sed	@echo "--------------------------------------------------------------"
288181905Sed	@echo " Rebuilding tools necessary to build the include files"
289181905Sed	@echo "--------------------------------------------------------------"
290181905Sed	cd ${.CURDIR}; ${BMAKE} include-tools
291188096Sed.endif
292181905Sed	@echo
293181905Sed	@echo "--------------------------------------------------------------"
294188096Sed	@echo " Rebuilding ${DESTDIR}/usr/include"
295181905Sed	@echo "--------------------------------------------------------------"
296181905Sed	cd ${.CURDIR}; SHARED=symlinks ${BMAKE} includes
297181905Sed	@echo
298181905Sed	@echo "--------------------------------------------------------------"
299181905Sed	@echo " Rebuilding bootstrap libraries"
300188096Sed	@echo "--------------------------------------------------------------"
301188096Sed	cd ${.CURDIR}; ${BMAKE} bootstrap-libraries
302181905Sed.if !defined(NOTOOLS)
303181905Sed	@echo
304181905Sed	@echo "--------------------------------------------------------------"
305181905Sed	@echo " Rebuilding tools needed to build libraries"
306181905Sed	@echo "--------------------------------------------------------------"
307181905Sed	cd ${.CURDIR}; ${BMAKE} lib-tools
308181905Sed.endif
309181905Sed.if !defined(NOTOOLS)
310181905Sed	@echo
311181905Sed	@echo "--------------------------------------------------------------"
312181905Sed	@echo " Rebuilding all other tools needed to build the world"
313181905Sed	@echo "--------------------------------------------------------------"
314181905Sed	cd ${.CURDIR}; ${BMAKE} build-tools
315181905Sed.endif
316223575Sed.if !defined(_NODEPEND)
317181905Sed	@echo
318181905Sed	@echo "--------------------------------------------------------------"
319181905Sed	@echo " Rebuilding dependencies"
320181905Sed	@echo "--------------------------------------------------------------"
321181905Sed	cd ${.CURDIR}; ${XMAKE} par-depend
322181905Sed.endif
323181905Sed	@echo
324181905Sed	@echo "--------------------------------------------------------------"
325181905Sed	@echo " Building libraries"
326181905Sed	@echo "--------------------------------------------------------------"
327181905Sed	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN libraries
328181905Sed	@echo
329181905Sed	@echo "--------------------------------------------------------------"
330181905Sed	@echo " Building everything.."
331181905Sed	@echo "--------------------------------------------------------------"
332181905Sed	cd ${.CURDIR}; ${XMAKE} all
333181905Sed
334181905Sed#
335181905Sed# installworld
336181905Sed#
337181905Sed# Installs everything compiled by a 'buildworld'.
338181905Sed#
339181905Sedinstallworld:
340181905Sed	cd ${.CURDIR}; ${IXMAKE} reinstall
341181905Sed
342181905Sed#
343181905Sed# reinstall
344181905Sed#
345181905Sed# If you have a build server, you can NFS mount the source and obj directories
346181905Sed# and do a 'make reinstall' on the *client* to install new binaries from the
347188096Sed# most recent server build.
348181905Sed#
349181905Sedreinstall:
350181905Sed	@echo "--------------------------------------------------------------"
351181905Sed	@echo " Making hierarchy"
352181905Sed	@echo "--------------------------------------------------------------"
353181905Sed	cd ${.CURDIR}; ${MAKE} hierarchy
354181905Sed	@echo
355181905Sed	@echo "--------------------------------------------------------------"
356181905Sed	@echo " Installing everything.."
357181905Sed	@echo "--------------------------------------------------------------"
358181905Sed	cd ${.CURDIR}; ${MAKE} install
359181905Sed	@echo
360181905Sed	@echo "--------------------------------------------------------------"
361181905Sed	@echo " Re-scanning the shared libraries.."
362181905Sed	@echo "--------------------------------------------------------------"
363181905Sed	cd ${.CURDIR}; ldconfig -R
364181905Sed	@echo
365181905Sed	@echo "--------------------------------------------------------------"
366181905Sed	@echo " Rebuilding man page indexes"
367181905Sed	@echo "--------------------------------------------------------------"
368181905Sed	cd ${.CURDIR}/share/man; ${MAKE} makedb
369181905Sed
370181905Sed#
371181905Sed# update
372202583Sed#
373181905Sed# Update the source tree, by running sup and/or running cvs to update to the
374181905Sed# latest copy.
375181905Sed#
376181905Sedupdate:
377181905Sed.if defined(SUP_UPDATE)
378181905Sed	@echo "--------------------------------------------------------------"
379192544Sed	@echo "Running ${SUP}"
380192544Sed	@echo "--------------------------------------------------------------"
381192544Sed	@${SUP} ${SUPFLAGS} ${SUPFILE}
382192544Sed.if defined(SUPFILE1)
383181905Sed	@${SUP} ${SUPFLAGS} ${SUPFILE1}
384181905Sed.endif
385181905Sed.if defined(SUPFILE2)
386181905Sed	@${SUP} ${SUPFLAGS} ${SUPFILE2}
387181905Sed.endif
388181905Sed.endif
389181905Sed.if defined(CVS_UPDATE)
390181905Sed	@echo "--------------------------------------------------------------"
391181905Sed	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
392181905Sed	@echo "--------------------------------------------------------------"
393181905Sed	cd ${.CURDIR}; cvs -q update -P -d
394181905Sed.endif
395181905Sed
396181905Sed#
397181905Sed# most
398181905Sed#
399181905Sed# Build most of the user binaries on the existing system libs and includes.
400223575Sed#
401181905Sedmost:
402181905Sed	@echo "--------------------------------------------------------------"
403181905Sed	@echo " Building programs only"
404181905Sed	@echo "--------------------------------------------------------------"
405181905Sed	cd ${.CURDIR}/bin;		${MAKE} all
406181905Sed	cd ${.CURDIR}/sbin;		${MAKE} all
407181905Sed	cd ${.CURDIR}/libexec;		${MAKE} all
408181905Sed	cd ${.CURDIR}/usr.bin;		${MAKE} all
409181905Sed	cd ${.CURDIR}/usr.sbin;		${MAKE} all
410181905Sed	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
411181905Sed	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
412188096Sed	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
413181905Sed#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
414181905Sed#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
415181905Sed#.endif
416181905Sed#.if !defined(NOSECURE) && !defined(NOCRYPT)
417181905Sed#	cd ${.CURDIR}/secure;		${MAKE} most
418181905Sed#.endif
419181905Sed
420181905Sed#
421181905Sed# installmost
422181905Sed#
423181905Sed# Install the binaries built by the 'most' target.  This does not include
424181905Sed# libraries or include files.
425181905Sed#
426181905Sedinstallmost:
427181905Sed	@echo "--------------------------------------------------------------"
428181905Sed	@echo " Installing programs only"
429181905Sed	@echo "--------------------------------------------------------------"
430181905Sed	cd ${.CURDIR}/bin;		${MAKE} install
431181905Sed	cd ${.CURDIR}/sbin;		${MAKE} install
432181905Sed	cd ${.CURDIR}/libexec;		${MAKE} install
433181905Sed	cd ${.CURDIR}/usr.bin;		${MAKE} install
434181905Sed	cd ${.CURDIR}/usr.sbin;		${MAKE} install
435181905Sed	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
436181905Sed	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
437181905Sed	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
438181905Sed#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
439181905Sed#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
440181905Sed#.endif
441181905Sed#.if !defined(NOSECURE) && !defined(NOCRYPT)
442181905Sed#	cd ${.CURDIR}/secure;		${MAKE} installmost
443181905Sed#.endif
444181905Sed
445181905Sed#
446188096Sed# ------------------------------------------------------------------------
447181905Sed#
448181905Sed# From here onwards are utility targets used by the 'make world' and
449181905Sed# related targets.  If your 'world' breaks, you may like to try to fix
450181905Sed# the problem and manually run the following targets to attempt to
451181905Sed# complete the build.  Beware, this is *not* guaranteed to work, you
452181905Sed# need to have a pretty good grip on the current state of the system
453181905Sed# to attempt to manually finish it.  If in doubt, 'make world' again.
454181905Sed#
455181905Sed
456181905Sed#
457181905Sed# heirarchy - ensure that all the needed directories are present
458188096Sed#
459181905Sedhierarchy:
460181905Sed	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
461181905Sed
462181905Sed#
463181905Sed# bootstrap - [re]build tools needed to run the actual build, this includes
464181905Sed# tools needed by 'make depend', as some tools are needed to generate source
465181905Sed# for the dependency information to be gathered from.
466181905Sed#
467181905Sedbootstrap:
468181905Sed.if defined(DESTDIR)
469181905Sed	rm -f ${DESTDIR}/usr/src/sys
470181905Sed	ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
471181905Sed	cd ${.CURDIR}/include; find -dx . | cpio -dump ${DESTDIR}/usr/include
472181905Sed	cd ${.CURDIR}/include; ${MAKE} symlinks
473181905Sed.endif
474181905Sed	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
475181905Sed		${MAKE} ${MK_FLAGS} all; \
476181905Sed		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
477181905Sed	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
478181905Sed		${MAKE} ${MK_FLAGS} all; \
479181905Sed		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
480181905Sed	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
481181905Sed		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
482181905Sed		${MAKE} ${MK_FLAGS} -DNOLIB all; \
483181905Sed		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
484181905Sed.if !defined(NOOBJDIR)
485181905Sed	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
486181905Sed.endif
487181905Sed
488181905Sed#
489181905Sed# include-tools - generally the same as 'bootstrap', except that it's for
490# things that are specifically needed to generate include files.
491#
492# XXX should be merged with bootstrap, it's not worth keeeping them separate.
493# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
494# on cleaned away headers in ${WORLDTMP}.
495#
496include-tools:
497.for d in usr.bin/compile_et usr.bin/rpcgen
498	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
499		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
500		${MAKE} ${MK_FLAGS} all; \
501		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
502.endfor
503
504#
505# includes - possibly generate and install the include files.
506#
507includes:
508.if defined(CLOBBER)
509	rm -rf ${DESTDIR}/usr/include/*
510	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
511		-p ${DESTDIR}/usr/include
512.endif
513	cd ${.CURDIR}/include;			${MAKE} -B all install
514	cd ${.CURDIR}/gnu/include;		${MAKE} install
515	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
516	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
517	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
518	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
519	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
520	cd ${.CURDIR}/gnu/lib/libg++;		${MAKE} beforeinstall
521	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
522	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
523.if exists(secure) && !defined(NOCRYPT)
524	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
525.endif
526.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
527	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
528	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
529	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
530	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
531	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
532	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
533.else
534	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
535.endif
536.if exists(${.CURDIR}/lib/csu/${MACHINE})
537	cd ${.CURDIR}/lib/csu/${MACHINE};	${MAKE} beforeinstall
538.endif
539	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
540	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
541	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
542	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
543	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
544	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
545	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
546	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
547	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
548	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
549.if !defined(WANT_CSRG_LIBM)
550	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
551.endif
552	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
553	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
554	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
555	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
556.if !defined(NOTCL) && exists (${.CURDIR}/contrib/tcl) && \
557	exists(${.CURDIR}/usr.bin/tclsh) && exists (${.CURDIR}/lib/libtcl)
558	cd ${.CURDIR}/lib/libtcl;		${MAKE} installhdrs
559.endif
560	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
561	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
562	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
563	cd ${.CURDIR}/lib/libscsi;		${MAKE} beforeinstall
564	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
565	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
566	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
567	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
568	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
569
570#
571# lib-tools - build tools to compile and install the libraries.
572#
573# XXX gperf is required for cc
574# XXX a new ld and tsort is required for cc
575lib-tools:
576.for d in				\
577		gnu/usr.bin/gperf	\
578		gnu/usr.bin/ld		\
579		usr.bin/tsort		\
580		gnu/usr.bin/as		\
581		gnu/usr.bin/bison	\
582		gnu/usr.bin/cc		\
583		usr.bin/ar		\
584		usr.bin/lex/lib		\
585		usr.bin/mk_cmds		\
586		usr.bin/nm		\
587		usr.bin/ranlib		\
588		usr.bin/strip		\
589		usr.bin/env		\
590		gnu/usr.bin/binutils	\
591		usr.bin/uudecode	\
592		usr.bin/objformat
593	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
594		${MAKE} ${MK_FLAGS} all; \
595		${MAKE} ${MK_FLAGS} -B install; \
596		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
597.endfor
598
599#
600# We have to know too much about ordering and subdirs in the lib trees:
601#
602# To satisfy shared library linkage when only the libraries being built
603# are visible:
604#
605# libcom_err must be built before libss.
606# libcrypt and libmd must be built before libskey.
607# libm must be built before libtcl.
608# libmytinfo must be built before libdialog and libncurses.
609# libncurses must be built before libdialog.
610# libtermcap must be built before libcurses, libedit and libreadline.
611#
612# Some libraries are built conditionally and/or are in inconsistently
613# named directories:
614#
615.if exists(lib/csu/${MACHINE}.pcc)
616_csu=lib/csu/${MACHINE}.pcc
617.else
618_csu=lib/csu/${MACHINE}
619.endif
620
621_libcrypt=	lib/libcrypt
622.if !defined(NOSECURE) && !defined(NOCRYPT)
623_libcrypt+=	secure/lib/libcrypt
624.endif
625
626.if defined(WANT_CSRG_LIBM)
627_libm=	lib/libm
628.else
629_libm=	lib/msun
630.endif
631
632#
633# bootstrap-libraries - build just enough libraries for the bootstrap
634# tools, and install them under ${WORLDTMP}.
635#
636# Build csu and libgcc early so that some tools get linked to the new
637# versions (too late for the main tools, however).  Then build the
638# necessary prerequisite libraries (libtermcap just needs to be before
639# libcurses, and this only matters for the NOCLEAN case when NOPIC is
640# not set).
641#
642# This is mostly wrong.  The build tools must run on the host system,
643# so they should use host libraries.  We depend on the target being
644# similar enough to the host for new target libraries to work on the
645# host.
646#
647bootstrap-libraries:
648.for _lib in ${_csu} gnu/usr.bin/cc/libgcc lib/libtermcap \
649    gnu/lib/libregex gnu/lib/libreadline lib/libc \
650    lib/libcrypt lib/libcurses lib/libedit ${_libm} \
651    lib/libmd lib/libutil lib/libz usr.bin/lex/lib
652.if exists(${.CURDIR}/${_lib})
653	cd ${.CURDIR}/${_lib}; \
654		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
655		${MAKE} ${MK_FLAGS} all; \
656		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
657.endif
658.endfor
659
660#
661# libraries - build all libraries, and install them under ${DESTDIR}.
662#
663# The ordering is not as special as for bootstrap-libraries.  Build
664# the prerequisites first, then build almost everything else in
665# alphabetical order.
666#
667libraries:
668.for _lib in lib/libcom_err ${_libcrypt} ${_libm} lib/libmytinfo \
669    lib/libncurses lib/libtermcap \
670    gnu/lib gnu/usr.bin/cc/libgcc lib usr.bin/lex/lib usr.sbin/pcvt/keycap
671.if exists(${.CURDIR}/${_lib})
672	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
673.endif
674.endfor
675.if exists(${.CURDIR}/secure/lib) && !defined(NOCRYPT) && !defined(NOSECURE)
676	cd ${.CURDIR}/secure/lib; ${MAKE} all; ${MAKE} -B install
677.endif
678.if exists(${.CURDIR}/kerberosIV/lib) && !defined(NOCRYPT) && \
679    defined(MAKE_KERBEROS4)
680	cd ${.CURDIR}/kerberosIV/lib; ${MAKE} all; ${MAKE} -B install
681.endif
682
683#
684# build-tools - build and install any other tools needed to complete the
685# compile and install.
686# ifdef stale
687# bc and cpp are required to build groff.  Otherwise, the order here is
688# mostly historical, i.e., bogus.
689# chmod is used to build gcc's tmpmultilib[2] at obscure times.
690# endif stale
691# XXX uname is a bug - the target should not depend on the host.
692#
693build-tools:
694.for d in				\
695		bin/cat 		\
696		bin/chmod		\
697		bin/cp 			\
698		bin/date		\
699		bin/dd			\
700		bin/echo		\
701		bin/expr		\
702		bin/hostname		\
703		bin/ln			\
704		bin/ls			\
705		bin/mkdir		\
706		bin/mv			\
707		bin/rm			\
708		bin/sh			\
709		bin/test		\
710		gnu/usr.bin/awk		\
711		gnu/usr.bin/bc		\
712		gnu/usr.bin/grep	\
713		gnu/usr.bin/groff	\
714		gnu/usr.bin/gzip	\
715		gnu/usr.bin/man/makewhatis	\
716		gnu/usr.bin/patch	\
717		gnu/usr.bin/perl/perl	\
718		gnu/usr.bin/sort	\
719		gnu/usr.bin/texinfo	\
720		usr.bin/basename	\
721		usr.bin/cap_mkdb	\
722		usr.bin/chflags		\
723		usr.bin/cmp		\
724		usr.bin/col		\
725		usr.bin/cpp		\
726		usr.bin/expand		\
727		usr.bin/file2c		\
728		usr.bin/find		\
729		usr.bin/gencat		\
730		usr.bin/lorder		\
731		usr.bin/m4		\
732		usr.bin/mkdep		\
733		usr.bin/paste		\
734		usr.bin/sed		\
735		usr.bin/size		\
736		usr.bin/soelim		\
737		usr.bin/strip		\
738		usr.bin/symorder	\
739		usr.bin/touch		\
740		usr.bin/tr		\
741		usr.bin/true		\
742		usr.bin/uname		\
743		usr.bin/uuencode	\
744		usr.bin/vgrind		\
745		usr.bin/vi		\
746		usr.bin/wc		\
747		usr.bin/xargs		\
748		usr.bin/yacc		\
749		usr.sbin/chown		\
750		usr.sbin/mtree		\
751		usr.sbin/zic
752	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
753		${MAKE} ${MK_FLAGS} all; \
754		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
755.endfor
756
757.for __target in clean cleandepend cleandir depend obj
758.for entry in ${SUBDIR}
759${entry}.${__target}__D: .PHONY
760	@if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
761		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
762		edir=${entry}.${MACHINE}; \
763		cd ${.CURDIR}/$${edir}; \
764	else \
765		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
766		edir=${entry}; \
767		cd ${.CURDIR}/$${edir}; \
768	fi; \
769	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
770.endfor
771par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
772.endfor
773
774.endif
775
776.include <bsd.subdir.mk>
777