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