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