Makefile.inc1 revision 45852
1#
2#	$Id: Makefile.inc1,v 1.73 1999/04/11 21:48:09 des Exp $
3#
4# Make command line options:
5#	-DCLOBBER will remove /usr/include
6#	-DMAKE_KERBEROS4 to build KerberosIV
7#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8#	-DNOCLEAN do not clean at all
9#	-DNOTOOLS do not rebuild any tools first
10#	-DNOCRYPT will prevent building of crypt versions
11#	-DNOPROFILE do not build profiled libraries
12#	-DNOSECURE do not go into secure subdir
13#	-DNOGAMES do not go into games subdir
14#	-DNOSHARE do not go into share subdir
15#	-DNOINFO do not make or install info files
16#	-DNOLIBC_R do not build libc_r.
17#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
18
19#
20# The intended user-driven targets are:
21# buildworld  - rebuild *everything*, including glue to help do upgrades
22# installworld- install everything built by "buildworld"
23# update      - convenient way to update your source tree (eg: sup/cvs)
24# most        - build user commands, no libraries or include files
25# installmost - install user commands, no libraries or include files
26#
27# Standard targets (not defined here) are documented in the makefiles in
28# /usr/share/mk.  These include:
29#		obj depend all install clean cleandepend cleanobj
30
31# Put initial settings here.
32SUBDIR=
33
34# We must do share/info early so that installation of info `dir'
35# entries works correctly.  Do it first since it is less likely to
36# grow dependencies on include and lib than vice versa.
37.if exists(${.CURDIR}/share/info)
38SUBDIR+= share/info
39.endif
40
41# We must do include and lib early so that the perl *.ph generation
42# works correctly as it uses the header files installed by this.
43.if exists(${.CURDIR}/include)
44SUBDIR+= include
45.endif
46.if exists(${.CURDIR}/lib)
47SUBDIR+= lib
48.endif
49
50.if exists(${.CURDIR}/bin)
51SUBDIR+= bin
52.endif
53.if exists(${.CURDIR}/games) && !defined(NOGAMES)
54SUBDIR+= games
55.endif
56.if exists(${.CURDIR}/gnu)
57SUBDIR+= gnu
58.endif
59.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
60    !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
61SUBDIR+= kerberosIV
62.endif
63.if exists(${.CURDIR}/libexec)
64SUBDIR+= libexec
65.endif
66.if exists(${.CURDIR}/sbin)
67SUBDIR+= sbin
68.endif
69.if exists(${.CURDIR}/share) && !defined(NOSHARE)
70SUBDIR+= share
71.endif
72.if exists(${.CURDIR}/sys)
73SUBDIR+= sys
74.endif
75.if exists(${.CURDIR}/usr.bin)
76SUBDIR+= usr.bin
77.endif
78.if exists(${.CURDIR}/usr.sbin)
79SUBDIR+= usr.sbin
80.endif
81.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
82SUBDIR+= secure
83.endif
84
85# etc must be last for "distribute" to work
86.if exists(${.CURDIR}/etc)
87SUBDIR+= etc
88.endif
89
90# These are last, since it is nice to at least get the base system
91# rebuilt before you do them.
92.if defined(LOCAL_DIRS)
93.for _DIR in ${LOCAL_DIRS}
94.if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
95SUBDIR+= ${_DIR}
96.endif
97.endfor
98.endif
99
100OBJDIR=		obj
101
102.if defined(NOCLEAN)
103CLEANDIR=
104.else
105.if defined(NOCLEANDIR)
106CLEANDIR=	clean cleandepend
107.else
108CLEANDIR=	cleandir
109.endif
110.endif
111
112.if !defined(NOCLEAN)
113_NODEPEND=	true
114.endif
115.if defined(_NODEPEND)
116_DEPEND=	cleandepend
117.else
118_DEPEND=	depend
119.endif
120
121SUP?=		cvsup
122SUPFLAGS?=	-g -L 2 -P -
123
124#
125# While building tools for bootstrapping, we don't need to waste time on
126# shared or profiled libraries, shared linkage, or documentation, except
127# when the tools won't get cleaned we must use the defaults for shared
128# libraries and shared linkage (and this doesn't waste time).
129# XXX actually, we do need to waste time building shared libraries.
130#
131.if defined(NOCLEAN)
132MK_FLAGS=	-DWORLD -DNOINFO -DNOMAN         -DNOPROFILE
133.else
134MK_FLAGS=	-DWORLD -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
135.endif
136
137#
138# Define the location of the temporary installation directory. Note that
139# MAKEOBJDIRPREFIX normally isn't defined so if the current directory is
140# /usr/src, then the world temporary directory is /usr/obj/usr/src/tmp.
141#
142# During the transition from aout to elf format on i386, MAKEOBJDIRPREFIX
143# is set by the parent makefile (Makefile.inc0) to be /usr/obj/${OBJFORMAT}
144# in order to keep aout and elf format files apart.
145#
146.if defined(MAKEOBJDIRPREFIX)
147WORLDTMP=	${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
148.else
149WORLDTMP=	/usr/obj${.CURDIR}/tmp
150.endif
151
152#
153# Define the PATH to the build tools.
154#
155# If not building tools, the PATH always points to the installed binaries.
156# The NOTOOLS option assumes that in installed tools are good enough and that
157# the user's PATH will locate to appropriate tools. This option is required
158# for a cross-compiled build environment.
159#
160# If building tools, then the PATH includes the world temporary directories
161# so that the bootstrapped tools are used as soon as they are built. The
162# strict path is for use after all tools are supposed to have been
163# bootstrapped. It doesn't allow any of the installed tools to be used.
164#
165.if	defined(NOTOOLS)
166# Default root of the tool tree
167TOOLROOT?=	
168# Choose the PATH relative to the root of the tool tree
169PATH=		${TOOLROOT}/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/sbin:${TOOLROOT}/usr/bin
170.else
171TOOLROOT=	${WORLDTMP}
172.endif
173STRICTTMPPATH=	${TOOLROOT}/sbin:${TOOLROOT}/usr/sbin:${TOOLROOT}/bin:${TOOLROOT}/usr/bin
174TMPPATH=	${STRICTTMPPATH}:${PATH}
175
176# XXX COMPILER_PATH is needed for finding cc1, ld and as
177# XXX GCC_EXEC_PREFIX is for *crt.o.  It is probably unnecessary now
178#	that LIBRARY_PATH is set.  We still can't use -nostdlib, since gcc
179#	wouldn't link *crt.o or libgcc if it were used.
180# XXX LD_LIBRARY_PATH is for ld.so.  It is also used by ld, although we don't
181#	want that - all compile-time library paths should be resolved by gcc.
182#	It fails for set[ug]id executables (are any used?).
183COMPILER_ENV=	BISON_SIMPLE=${TOOLROOT}/usr/share/misc/bison.simple \
184		COMPILER_PATH=${TOOLROOT}/usr/libexec:${TOOLROOT}/usr/bin \
185		GCC_EXEC_PREFIX=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib/ \
186		LD_LIBRARY_PATH=${TOOLROOT}${SHLIBDIR} \
187		LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
188
189BMAKEENV=	PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t \
190		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec:/usr/libexec
191XMAKEENV=	PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
192		PERL5LIB=${DESTDIR}/usr/libdata/perl/5.00502 \
193		OBJFORMAT_PATH=${TOOLROOT}/usr/libexec \
194		CFLAGS="-nostdinc ${CFLAGS}"	# XXX -nostdlib
195
196# used to compile and install 'make' in temporary build tree
197MAKETMP=	${WORLDTMP}/make
198IBMAKE=	${BMAKEENV} MAKEOBJDIR=${MAKETMP} ${MAKE} DESTDIR=${WORLDTMP}
199
200.if	defined(NOTOOLS)
201# bootstrap make
202BMAKE=	${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
203# cross make used for compilation
204XMAKE=	${XMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
205# cross make used for final installation
206IXMAKE=	${XMAKEENV} ${MAKE}
207.else
208# bootstrap make
209BMAKE=	${BMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
210# cross make used for compilation
211XMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make DESTDIR=${WORLDTMP}
212# cross make used for final installation
213IXMAKE=	${XMAKEENV} ${WORLDTMP}/usr/bin/make
214.endif
215
216#
217# buildworld
218#
219# Attempt to rebuild the entire system, with reasonable chance of
220# success, regardless of how old your existing system is.
221#
222buildworld: check-objformat
223.if !defined(NOCLEAN)
224	@echo
225	@echo "--------------------------------------------------------------"
226	@echo ">>> Cleaning up the temporary ${OBJFORMAT} build tree"
227	@echo "--------------------------------------------------------------"
228	mkdir -p ${WORLDTMP}
229	-chflags -R noschg ${WORLDTMP}/
230	rm -rf ${WORLDTMP}
231.endif
232.if !defined(NOTOOLS)
233	@echo
234	@echo "--------------------------------------------------------------"
235	@echo ">>> Making make"
236	@echo "--------------------------------------------------------------"
237	mkdir -p ${WORLDTMP}/usr/bin ${MAKETMP}
238	( \
239	cd ${.CURDIR}/usr.bin/make; \
240		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
241		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all; \
242		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install; \
243		${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean \
244	)
245	@echo
246	@echo "--------------------------------------------------------------"
247	@echo ">>> Making mtree"
248	@echo "--------------------------------------------------------------"
249	mkdir -p ${WORLDTMP}/usr/sbin ${WORLDTMP}/mtree
250	( \
251	cd ${.CURDIR}/usr.sbin/mtree; \
252		MAKEOBJDIRPREFIX=""; unset MAKEOBJDIRPREFIX; \
253		export MAKEOBJDIR=${WORLDTMP}/mtree; \
254		${BMAKE} ${MK_FLAGS} all; \
255		${BMAKE} ${MK_FLAGS} -B install clean \
256	)
257.endif
258	@echo
259	@echo "--------------------------------------------------------------"
260	@echo ">>> Making hierarchy"
261	@echo "--------------------------------------------------------------"
262	mkdir -p ${WORLDTMP}
263	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 hierarchy
264.if !defined(NOCLEAN)
265	@echo
266	@echo "--------------------------------------------------------------"
267	@echo ">>> Cleaning up the ${OBJFORMAT} obj tree"
268	@echo "--------------------------------------------------------------"
269	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
270.endif
271	@echo
272	@echo "--------------------------------------------------------------"
273	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
274	@echo "--------------------------------------------------------------"
275	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 par-${OBJDIR}
276.if !defined(NOTOOLS)
277	@echo
278	@echo "--------------------------------------------------------------"
279	@echo ">>> Rebuilding ${OBJFORMAT} bootstrap tools"
280	@echo "--------------------------------------------------------------"
281	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap
282	@echo
283	@echo "--------------------------------------------------------------"
284	@echo ">>> Rebuilding tools necessary to build the include files"
285	@echo "--------------------------------------------------------------"
286	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 include-tools
287.endif
288	@echo
289	@echo "--------------------------------------------------------------"
290	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
291	@echo "--------------------------------------------------------------"
292	cd ${.CURDIR}; SHARED=copies ${BMAKE} -f Makefile.inc1 includes
293	@echo
294	@echo "--------------------------------------------------------------"
295	@echo ">>> Rebuilding bootstrap libraries"
296	@echo "--------------------------------------------------------------"
297	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 bootstrap-libraries
298.if !defined(NOTOOLS)
299	@echo
300	@echo "--------------------------------------------------------------"
301	@echo ">>> Rebuilding tools needed to build libraries"
302	@echo "--------------------------------------------------------------"
303	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 lib-tools
304.endif
305.if !defined(NOTOOLS)
306	@echo
307	@echo "--------------------------------------------------------------"
308	@echo ">>> Rebuilding all other tools needed to build the ${OBJFORMAT} world"
309	@echo "--------------------------------------------------------------"
310	cd ${.CURDIR}; ${BMAKE} -f Makefile.inc1 build-tools
311.endif
312.if !defined(_NODEPEND)
313	@echo
314	@echo "--------------------------------------------------------------"
315	@echo ">>> Rebuilding dependencies"
316	@echo "--------------------------------------------------------------"
317	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-depend
318.endif
319	@echo
320	@echo "--------------------------------------------------------------"
321	@echo ">>> Building ${OBJFORMAT} libraries"
322	@echo "--------------------------------------------------------------"
323	cd ${.CURDIR}; ${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
324	@echo
325	@echo "--------------------------------------------------------------"
326	@echo ">>> Building everything.."
327	@echo "--------------------------------------------------------------"
328	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
329
330everything:
331	@echo "--------------------------------------------------------------"
332	@echo ">>> Building everything.."
333	@echo "--------------------------------------------------------------"
334	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 all
335
336#
337# installworld
338#
339# Installs everything compiled by a 'buildworld'.
340#
341installworld:
342	cd ${.CURDIR}; ${IXMAKE} -f Makefile.inc1 reinstall
343
344#
345# reinstall
346#
347# If you have a build server, you can NFS mount the source and obj directories
348# and do a 'make reinstall' on the *client* to install new binaries from the
349# most recent server build.
350#
351reinstall:
352	@echo "--------------------------------------------------------------"
353	@echo ">>> Making hierarchy"
354	@echo "--------------------------------------------------------------"
355	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
356	@echo
357	@echo "--------------------------------------------------------------"
358	@echo ">>> Installing everything.."
359	@echo "--------------------------------------------------------------"
360	cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
361.if ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout" && !defined(DESTDIR)
362	@echo
363	@echo "--------------------------------------------------------------"
364	@echo ">>> Re-scanning the shared libraries.."
365	@echo "--------------------------------------------------------------"
366	-cd ${.CURDIR}; /sbin/ldconfig -R
367.endif
368.if !defined(NOMAN)
369	@echo
370	@echo "--------------------------------------------------------------"
371	@echo ">>> Rebuilding man page indices"
372	@echo "--------------------------------------------------------------"
373	cd ${.CURDIR}/share/man; ${MAKE} makedb
374.endif
375
376#
377# update
378#
379# Update the source tree, by running sup and/or running cvs to update to the
380# latest copy.
381#
382update:
383.if defined(SUP_UPDATE)
384	@echo "--------------------------------------------------------------"
385	@echo ">>> Running ${SUP}"
386	@echo "--------------------------------------------------------------"
387	@${SUP} ${SUPFLAGS} ${SUPFILE}
388.if defined(SUPFILE1)
389	@${SUP} ${SUPFLAGS} ${SUPFILE1}
390.endif
391.if defined(SUPFILE2)
392	@${SUP} ${SUPFLAGS} ${SUPFILE2}
393.endif
394.endif
395.if defined(CVS_UPDATE)
396	@echo "--------------------------------------------------------------"
397	@echo ">>> Updating /usr/src from cvs repository" ${CVSROOT}
398	@echo "--------------------------------------------------------------"
399	cd ${.CURDIR}; cvs -q update -P -d
400.endif
401
402#
403# most
404#
405# Build most of the user binaries on the existing system libs and includes.
406#
407most:
408	@echo "--------------------------------------------------------------"
409	@echo ">>> Building programs only"
410	@echo "--------------------------------------------------------------"
411	cd ${.CURDIR}/bin;		${MAKE} all
412	cd ${.CURDIR}/sbin;		${MAKE} all
413	cd ${.CURDIR}/libexec;		${MAKE} all
414	cd ${.CURDIR}/usr.bin;		${MAKE} all
415	cd ${.CURDIR}/usr.sbin;		${MAKE} all
416	cd ${.CURDIR}/gnu/libexec;	${MAKE} all
417	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} all
418	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} all
419#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
420#	cd ${.CURDIR}/kerberosIV;	${MAKE} most
421#.endif
422#.if !defined(NOSECURE) && !defined(NOCRYPT)
423#	cd ${.CURDIR}/secure;		${MAKE} most
424#.endif
425
426#
427# installmost
428#
429# Install the binaries built by the 'most' target.  This does not include
430# libraries or include files.
431#
432installmost:
433	@echo "--------------------------------------------------------------"
434	@echo ">>> Installing programs only"
435	@echo "--------------------------------------------------------------"
436	cd ${.CURDIR}/bin;		${MAKE} install
437	cd ${.CURDIR}/sbin;		${MAKE} install
438	cd ${.CURDIR}/libexec;		${MAKE} install
439	cd ${.CURDIR}/usr.bin;		${MAKE} install
440	cd ${.CURDIR}/usr.sbin;		${MAKE} install
441	cd ${.CURDIR}/gnu/libexec;	${MAKE} install
442	cd ${.CURDIR}/gnu/usr.bin;	${MAKE} install
443	cd ${.CURDIR}/gnu/usr.sbin;	${MAKE} install
444#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
445#	cd ${.CURDIR}/kerberosIV;	${MAKE} installmost
446#.endif
447#.if !defined(NOSECURE) && !defined(NOCRYPT)
448#	cd ${.CURDIR}/secure;		${MAKE} installmost
449#.endif
450
451#
452# ------------------------------------------------------------------------
453#
454# From here onwards are utility targets used by the 'make world' and
455# related targets.  If your 'world' breaks, you may like to try to fix
456# the problem and manually run the following targets to attempt to
457# complete the build.  Beware, this is *not* guaranteed to work, you
458# need to have a pretty good grip on the current state of the system
459# to attempt to manually finish it.  If in doubt, 'make world' again.
460#
461
462#
463# hierarchy - ensure that all the needed directories are present
464#
465hierarchy:
466	cd ${.CURDIR}/etc;		${MAKE} distrib-dirs
467
468#
469# bootstrap - [re]build tools needed to run the actual build, this includes
470# tools needed by 'make depend', as some tools are needed to generate source
471# for the dependency information to be gathered from.
472#
473bootstrap:
474	cd ${.CURDIR}/usr.bin/make; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
475		${MAKE} ${MK_FLAGS} all; \
476		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
477	cd ${.CURDIR}/usr.bin/xinstall; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
478		${MAKE} ${MK_FLAGS} all; \
479		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
480	cd ${.CURDIR}/usr.bin/yacc; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
481		${MAKE} ${MK_FLAGS} all; \
482		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
483	cd ${.CURDIR}/usr.bin/lex; ${MAKE} bootstrap; \
484		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
485		${MAKE} ${MK_FLAGS} -DNOLIB all; \
486		${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
487	cd ${.CURDIR}/usr.bin/lex; ${MAKE} ${OBJDIR}
488	cd ${.CURDIR}/usr.sbin/mtree; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
489		${MAKE} ${MK_FLAGS} all; \
490		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
491
492#
493# include-tools - generally the same as 'bootstrap', except that it's for
494# things that are specifically needed to generate include files.
495#
496# XXX should be merged with bootstrap, it's not worth keeeping them separate.
497# Well, maybe it is now.  We force 'cleandepend' here to avoid dependencies
498# on cleaned away headers in ${WORLDTMP}.
499#
500include-tools:
501.for d in usr.bin/compile_et usr.bin/rpcgen
502	cd ${.CURDIR}/$d; ${MAKE} cleandepend; \
503		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
504		${MAKE} ${MK_FLAGS} all; \
505		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
506.endfor
507
508#
509# includes - possibly generate and install the include files.
510#
511includes:
512.if defined(CLOBBER)
513	rm -rf ${DESTDIR}/usr/include/*
514	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
515		-p ${DESTDIR}/usr/include
516.endif
517	cd ${.CURDIR}/include;			${MAKE} -B all install
518	cd ${.CURDIR}/gnu/include;		${MAKE} install
519	cd ${.CURDIR}/gnu/lib/libmp;		${MAKE} beforeinstall
520	cd ${.CURDIR}/gnu/lib/libobjc;		${MAKE} beforeinstall
521	cd ${.CURDIR}/gnu/lib/libreadline;	${MAKE} beforeinstall
522	cd ${.CURDIR}/gnu/lib/libregex;		${MAKE} beforeinstall
523	cd ${.CURDIR}/gnu/lib/libstdc++;	${MAKE} beforeinstall
524	cd ${.CURDIR}/gnu/lib/libdialog;	${MAKE} beforeinstall
525	cd ${.CURDIR}/gnu/lib/libgmp;		${MAKE} beforeinstall
526	cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;	${MAKE} beforeinstall
527.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
528	cd ${.CURDIR}/secure/lib/libdes;	${MAKE} beforeinstall
529.endif
530.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
531    defined(MAKE_KERBEROS4)
532	cd ${.CURDIR}/kerberosIV/lib/libacl;	${MAKE} beforeinstall
533	cd ${.CURDIR}/kerberosIV/lib/libkadm;	${MAKE} beforeinstall
534	cd ${.CURDIR}/kerberosIV/lib/libkafs;	${MAKE} beforeinstall
535	cd ${.CURDIR}/kerberosIV/lib/libkdb;	${MAKE} beforeinstall
536	cd ${.CURDIR}/kerberosIV/lib/libkrb;	${MAKE} beforeinstall
537	cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
538.else
539	cd ${.CURDIR}/lib/libtelnet;		${MAKE} beforeinstall
540.endif
541.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
542	cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};	${MAKE} beforeinstall
543.endif
544	cd ${.CURDIR}/lib/libalias;		${MAKE} beforeinstall
545	cd ${.CURDIR}/lib/libatm;		${MAKE} beforeinstall
546	cd ${.CURDIR}/lib/libdevstat;		${MAKE} beforeinstall
547	cd ${.CURDIR}/lib/libc;			${MAKE} beforeinstall
548	cd ${.CURDIR}/lib/libcalendar;		${MAKE} beforeinstall
549	cd ${.CURDIR}/lib/libcam;		${MAKE} beforeinstall
550	cd ${.CURDIR}/lib/libcurses;		${MAKE} beforeinstall
551	cd ${.CURDIR}/lib/libdisk;		${MAKE} beforeinstall
552	cd ${.CURDIR}/lib/libedit;		${MAKE} beforeinstall
553	cd ${.CURDIR}/lib/libftpio;		${MAKE} beforeinstall
554	cd ${.CURDIR}/lib/libmd;		${MAKE} beforeinstall
555	cd ${.CURDIR}/lib/libmytinfo;		${MAKE} beforeinstall
556	cd ${.CURDIR}/lib/libncurses;		${MAKE} beforeinstall
557.if !defined(WANT_CSRG_LIBM)
558	cd ${.CURDIR}/lib/msun;			${MAKE} beforeinstall
559.endif
560	cd ${.CURDIR}/lib/libopie;		${MAKE} beforeinstall
561	cd ${.CURDIR}/lib/libpam/libpam;	${MAKE} beforeinstall
562	cd ${.CURDIR}/lib/libpcap;		${MAKE} beforeinstall
563	cd ${.CURDIR}/lib/libradius;		${MAKE} beforeinstall
564	cd ${.CURDIR}/lib/librpcsvc;		${MAKE} beforeinstall
565	cd ${.CURDIR}/lib/libskey;		${MAKE} beforeinstall
566	cd ${.CURDIR}/lib/libstand;		${MAKE} beforeinstall
567	cd ${.CURDIR}/lib/libtacplus;		${MAKE} beforeinstall
568	cd ${.CURDIR}/lib/libtermcap;		${MAKE} beforeinstall
569	cd ${.CURDIR}/lib/libcom_err;		${MAKE} beforeinstall
570	cd ${.CURDIR}/lib/libss;		${MAKE} -B hdrs beforeinstall
571	cd ${.CURDIR}/lib/libutil;		${MAKE} beforeinstall
572	cd ${.CURDIR}/lib/libvgl;		${MAKE} beforeinstall
573	cd ${.CURDIR}/lib/libwrap;		${MAKE} beforeinstall
574	cd ${.CURDIR}/lib/libz;			${MAKE} beforeinstall
575	cd ${.CURDIR}/usr.bin/f2c;		${MAKE} beforeinstall
576	cd ${.CURDIR}/usr.bin/lex;		${MAKE} beforeinstall
577
578#
579# Declare tools if they are not required on all architectures.
580#
581.if ${MACHINE_ARCH} == "i386"
582# aout tools:
583_aout_ar	= usr.bin/ar
584_aout_as	= gnu/usr.bin/as
585_aout_ld	= gnu/usr.bin/ld
586_aout_nm	= usr.bin/nm
587_aout_ranlib	= usr.bin/ranlib
588_aout_size	= usr.bin/size
589_aout_strip	= usr.bin/strip
590# boot block/loader tools:
591_btxld		= usr.sbin/btxld
592.endif
593
594#
595# lib-tools - build tools to compile and install the libraries.
596#
597# XXX gperf is required for cc
598# XXX a new ld and tsort is required for cc
599lib-tools:
600.for d in				\
601		gnu/usr.bin/gperf	\
602		${_aout_ld}		\
603		usr.bin/tsort		\
604		${_aout_as}		\
605		gnu/usr.bin/bison	\
606		gnu/usr.bin/cc		\
607		gnu/lib/libgcc		\
608		${_aout_ar}		\
609		usr.bin/env		\
610		usr.bin/lex/lib		\
611		usr.bin/mk_cmds		\
612		${_aout_nm}		\
613		${_aout_ranlib}		\
614		${_aout_strip}		\
615		gnu/usr.bin/binutils	\
616		usr.bin/uudecode	\
617		usr.bin/objformat
618	cd ${.CURDIR}/$d; ${MAKE} ${MK_FLAGS} ${_DEPEND}; \
619		${MAKE} ${MK_FLAGS} all; \
620		${MAKE} ${MK_FLAGS} -B install; \
621		${MAKE} ${MK_FLAGS:S/-DNOPIC//} -B ${CLEANDIR} ${OBJDIR}
622.endfor
623
624#
625# We have to know too much about ordering and subdirs in the lib trees:
626#
627# To satisfy shared library linkage when only the libraries being built
628# are visible:
629#
630# csu must be built before all shared libaries for ELF.
631# libcom_err must be built before libss.
632# libcrypt must be built before libskey and libkrb.
633# libdes must be built before libpam.
634# libkrb must be built before libpam.
635# libm must be built before libf2c and libstdc++.
636# libmd must be built before libatm, libopie, libradius, libskey,
637# and libtacplus.
638# libmytinfo must be built before libdialog and libncurses.
639# libncurses must be built before libdialog.
640# libradius must be built before libpam.
641# libskey must be built before libpam.
642# libtacplus must be built before libpam.
643# libtermcap must be built before libcurses, libedit and libreadline.
644#
645# Some libraries are built conditionally and/or are in inconsistently
646# named directories:
647#
648.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
649_csu=lib/csu/${MACHINE_ARCH}.pcc
650.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
651_csu=lib/csu/i386-elf
652.else
653_csu=lib/csu/${MACHINE_ARCH}
654.endif
655
656.if !defined(NOSECURE) && !defined(NOCRYPT)
657_libcrypt=	secure/lib/libcrypt lib/libcrypt
658_secure_lib=	secure/lib
659.else
660_libcrypt=	lib/libcrypt
661.endif
662
663.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
664_kerberosIV_lib=kerberosIV/lib
665.endif
666
667.if defined(WANT_CSRG_LIBM)
668_libm=	lib/libm
669.else
670_libm=	lib/msun
671.endif
672
673.if !defined(NOPERL)
674_libperl=		gnu/usr.bin/perl/libperl
675.endif
676
677#
678# bootstrap-libraries - build just enough libraries for the bootstrap
679# tools, and install them under ${WORLDTMP}.
680#
681# Build csu early so that some tools get linked to the new
682# version (too late for the main tools, however).  Then build the
683# necessary prerequisite libraries (libtermcap just needs to be before
684# libcurses, and this only matters for the NOCLEAN case when NOPIC is
685# not set).
686#
687# This is mostly wrong.  The build tools must run on the host system,
688# so they should use host libraries.  We depend on the target being
689# similar enough to the host for new target libraries to work on the
690# host.
691#
692bootstrap-libraries:
693.for _lib in ${_csu} lib/libtermcap \
694    gnu/lib/libregex gnu/lib/libreadline lib/libc \
695    lib/libcrypt lib/libcurses lib/libedit ${_libm} \
696    lib/libmd lib/libutil lib/libz usr.bin/lex/lib \
697    ${_libperl}
698.if exists(${.CURDIR}/${_lib})
699	cd ${.CURDIR}/${_lib}; \
700		${MAKE} ${MK_FLAGS} ${_DEPEND}; \
701		${MAKE} ${MK_FLAGS} all; \
702		${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
703.endif
704.endfor
705
706#
707# libraries - build all libraries, and install them under ${DESTDIR}.
708#
709# The ordering is not as special as for bootstrap-libraries.  Build
710# the prerequisites first, then build almost everything else in
711# alphabetical order.
712#
713libraries:
714.for _lib in ${_csu} lib/libcom_err ${_libcrypt} ${_libm} lib/libmd \
715    lib/libmytinfo lib/libncurses lib/libtermcap \
716    lib/libradius lib/libskey lib/libtacplus \
717    ${_secure_lib} ${_kerberosIV_lib} \
718    gnu/lib ${_libperl} lib usr.bin/lex/lib \
719    usr.sbin/pcvt/keycap
720.if exists(${.CURDIR}/${_lib})
721	cd ${.CURDIR}/${_lib}; ${MAKE} all; ${MAKE} -B install
722.endif
723.endfor
724
725#
726# Exclude unused tools from build-tools.
727#
728.if !defined(NOGAMES) && exists(${.CURDIR}/games)
729_adventure=	games/adventure
730_caesar=	games/caesar
731_hack=		games/hack
732_phantasia=	games/phantasia
733_strfile=	games/fortune/strfile
734.endif
735.if !defined(NOPERL)
736_perl=		gnu/usr.bin/perl/miniperl
737.endif
738.if !defined(NOSHARE) && exists(${.CURDIR}/share)
739_scrnmaps=	share/syscons/scrnmaps
740.endif
741.if ${MACHINE_ARCH} == i386
742_kldlinux=	sys/modules/linux
743.endif
744.if ${OBJFORMAT} == "aout"
745_netboot=	sys/${MACHINE}/boot/netboot
746.endif
747
748BTMAKEFLAGS=	${MK_FLAGS} -D_BUILD_TOOLS
749
750#
751# build-tools - build and install any other tools needed to complete the
752# compile and install.
753# ifdef stale
754# bc and cpp are required to build groff.  Otherwise, the order here is
755# mostly historical, i.e., bogus.
756# chmod is used to build gcc's tmpmultilib[2] at obscure times.
757# endif stale
758# XXX uname is a bug - the target should not depend on the host.
759#
760build-tools:
761.for d in				\
762		bin/cat 		\
763		bin/chmod		\
764		bin/cp 			\
765		bin/date		\
766		bin/dd			\
767		bin/echo		\
768		bin/expr		\
769		bin/hostname		\
770		bin/ln			\
771		bin/ls			\
772		bin/mkdir		\
773		bin/mv			\
774		bin/rm			\
775		bin/test		\
776		${_caesar}		\
777		${_strfile}		\
778		gnu/usr.bin/awk		\
779		gnu/usr.bin/bc		\
780		gnu/usr.bin/grep	\
781		gnu/usr.bin/groff	\
782		gnu/usr.bin/gzip	\
783		gnu/usr.bin/man/makewhatis	\
784		gnu/usr.bin/patch	\
785		${_perl}		\
786		gnu/usr.bin/sort	\
787		gnu/usr.bin/texinfo	\
788		usr.bin/basename	\
789		usr.bin/cap_mkdb	\
790		usr.bin/chflags		\
791		usr.bin/cmp		\
792		usr.bin/col		\
793		usr.bin/colldef		\
794		usr.bin/cpp		\
795		usr.bin/expand		\
796		usr.bin/file2c		\
797		usr.bin/find		\
798		usr.bin/gencat		\
799		usr.bin/gensetdefs	\
800		usr.bin/id		\
801		usr.bin/join		\
802		usr.bin/lorder		\
803		usr.bin/m4		\
804		usr.bin/mkdep		\
805		usr.bin/mklocale	\
806		usr.bin/paste		\
807		usr.bin/printf		\
808		usr.bin/sed		\
809		${_aout_size}		\
810		usr.bin/soelim		\
811		usr.bin/symorder	\
812		usr.bin/touch		\
813		usr.bin/tr		\
814		usr.bin/true		\
815		usr.bin/uname		\
816		usr.bin/uuencode	\
817		usr.bin/vgrind		\
818		usr.bin/vi		\
819		usr.bin/wc		\
820		usr.bin/xargs		\
821		usr.bin/yacc		\
822		${_btxld}		\
823		usr.sbin/chown		\
824		usr.sbin/mtree		\
825		usr.sbin/zic		\
826		bin/sh
827	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} ${_DEPEND}; \
828		${MAKE} ${BTMAKEFLAGS} all; \
829		${MAKE} ${BTMAKEFLAGS} -B install ${CLEANDIR} ${OBJDIR}
830.endfor
831.if !defined(NOGAMES) && exists(${.CURDIR}/games)
832	cd ${DESTDIR}/usr/games; cp -p caesar strfile ${DESTDIR}/usr/bin
833.endif
834.for d in				\
835		bin/sh			\
836		${_adventure}		\
837		${_hack}		\
838		${_phantasia}		\
839		gnu/usr.bin/cc/cc_tools	\
840		lib/libmytinfo		\
841		${_linux}		\
842		${_kldlinux}		\
843		${_scrnmaps}		\
844		${_netboot}
845	cd ${.CURDIR}/$d; ${MAKE} ${BTMAKEFLAGS} build-tools
846.endfor
847	cd ${.CURDIR}/usr.bin/tn3270/tools; ${MAKE} ${BTMAKEFLAGS} all
848
849#
850# Build aout versions of things that provide legacy support when all the
851# rest of the world is elf.
852#
853legacy-build:
854.if	${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "aout"
855	@echo
856	@echo "--------------------------------------------------------------"
857	@echo ">>> Making hierarchy"
858	@echo "--------------------------------------------------------------"
859	mkdir -p ${WORLDTMP}
860	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 hierarchy
861	@echo
862	@echo "--------------------------------------------------------------"
863	@echo ">>> Rebuilding the ${OBJFORMAT} obj tree"
864	@echo "--------------------------------------------------------------"
865	cd ${.CURDIR}; ${XMAKE} -f Makefile.inc1 par-${OBJDIR}
866	@echo
867	@echo "--------------------------------------------------------------"
868	@echo ">>> Rebuilding ${DESTDIR}/usr/include"
869	@echo "--------------------------------------------------------------"
870	cd ${.CURDIR}; SHARED=copies ${XMAKE} -f Makefile.inc1 includes
871	@echo
872	@echo "--------------------------------------------------------------"
873	@echo ">>> Building legacy libraries"
874	@echo "--------------------------------------------------------------"
875	cd ${.CURDIR}; \
876		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 bootstrap-libraries
877	cd ${.CURDIR}; \
878		${XMAKE} -DNOINFO -DNOMAN -f Makefile.inc1 libraries
879	@echo
880	@echo "--------------------------------------------------------------"
881	@echo ">>> Building legacy rtld"
882	@echo "--------------------------------------------------------------"
883	cd ${.CURDIR}/libexec/rtld-aout; \
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 -B obj 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/lib/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.if ${MACHINE_ARCH} == "i386"
925	@echo "--------------------------------------------------------------"
926	@echo ">>> Installing legacy boot"
927	@echo "--------------------------------------------------------------"
928	cd ${.CURDIR}/sys/${MACHINE}/boot && ${MAKE} -DNOMAN install
929.endif
930.endif
931
932
933# Get the object format that the tools see.
934#
935#
936.if exists(/usr/bin/objformat)
937__OBJFORMAT!=	objformat
938.else
939__OBJFORMAT=	${OBJFORMAT}
940.endif
941
942#
943# Check if the local /etc/make.conf or /etc/make.conf.local have attempted
944# to override the OBJFORMAT without updating the environment for the tools
945# to see.
946#
947check-objformat	:
948.if	${__OBJFORMAT} != ${OBJFORMAT}
949	@/bin/sh -c "echo \"It looks like you set OBJFORMAT=${OBJFORMAT} in /etc/make.conf. Don't do that!\" "
950	@/bin/sh -c "echo \"If you want to override the installed object format, you must set OBJFORMAT\" "
951	@/bin/sh -c "echo \"in your environment.\" "
952	@exit 1
953.endif
954.if	!defined(REALLY_WANT_DEPRECIATED_AOUT) && ${OBJFORMAT} == "aout"
955	@echo "==== NOTICE: a.out buildworld is depreciated and disabled! ====="
956	@echo "Read: http://www.freebsd.org/~peter/elfday.html for information."
957	@echo "You need to complete a 'make aout-to-elf' to bring your system"
958	@echo "up to date with ELF tools.  This requires a fair amount of disk"
959	@echo "space to complete.  Alternatively, you can do a binary upgrade"
960	@echo "using the 3.0-RELEASE binaries from CD or ftp.freebsd.org in"
961	@echo "/pub/FreeBSD/3.0-RELEASE/bin/ to convert your userland to ELF."
962	@exit 1
963.endif
964
965
966.for __target in clean cleandepend cleandir depend obj
967.for entry in ${SUBDIR}
968${entry}.${__target}__D: .PHONY
969	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
970		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
971		edir=${entry}.${MACHINE_ARCH}; \
972		cd ${.CURDIR}/$${edir}; \
973	else \
974		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
975		edir=${entry}; \
976		cd ${.CURDIR}/$${edir}; \
977	fi; \
978	${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
979.endfor
980par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
981.endfor
982
983.include <bsd.subdir.mk>
984