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