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