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