Makefile revision 25647
1#
2#	$Id: Makefile,v 1.123 1997/05/03 02:51:58 jb Exp $
3#
4# Make command line options:
5#	-DCLOBBER will remove /usr/include
6#	-DMAKE_LOCAL to add ./local to the SUBDIR list
7#	-DMAKE_PORTS to add ./ports to the SUBDIR list
8#	-DMAKE_EBONES to build eBones (KerberosIV)
9#	-DALLLANG to build documentation for all languages
10#	  (where available -- see share/doc/Makefile)
11#
12#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
13#	-DNOCLEAN do not clean at all
14#	-DNOCRYPT will prevent building of crypt versions
15#	-DNOLKM do not build loadable kernel modules
16#	-DNOOBJDIR do not run ``${MAKE} obj''
17#	-DNOPROFILE do not build profiled libraries
18#	-DNOSECURE do not go into secure subdir
19#	-DNOGAMES do not go into games subdir
20#	-DNOSHARE do not go into share subdir
21#       -DNOINFO do not make or install info files
22#       -DNOLIBC_R do not build libc_r.
23
24#
25# The intended user-driven targets are:
26# world       - rebuild *everything*, including glue to help do upgrades.
27# reinstall   - use an existing (eg: NFS mounted) build to do an update.
28# update      - convenient way to update your source tree (eg: sup/cvs)
29# most        - build user commands, no libraries or include files
30# installmost - install user commands, no libraries or include files
31#
32# Standard targets (not defined here) are documented in the makefiles in
33# /usr/share/mk.  These include:
34#		obj depend all install clean cleandepend cleanobj
35
36.MAKEFLAGS:=	${.MAKEFLAGS} -m ${.CURDIR}/share/mk
37
38# Put initial settings here.
39SUBDIR=
40
41# We must do share/info early so that installation of info `dir'
42# entries works correctly.  Do it first since it is less likely to
43# grow dependencies on include and lib than vice versa.
44.if exists(share/info)
45SUBDIR+= share/info
46.endif
47
48# We must do include and lib early so that the perl *.ph generation
49# works correctly as it uses the header files installed by this.
50.if exists(include)
51SUBDIR+= include
52.endif
53.if exists(lib)
54SUBDIR+= lib
55.endif
56
57.if exists(bin)
58SUBDIR+= bin
59.endif
60.if exists(games) && !defined(NOGAMES)
61SUBDIR+= games
62.endif
63.if exists(gnu)
64SUBDIR+= gnu
65.endif
66.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
67SUBDIR+= eBones
68.endif
69.if exists(libexec)
70SUBDIR+= libexec
71.endif
72.if exists(sbin)
73SUBDIR+= sbin
74.endif
75.if exists(share) && !defined(NOSHARE)
76SUBDIR+= share
77.endif
78.if exists(sys)
79SUBDIR+= sys
80.endif
81.if exists(usr.bin)
82SUBDIR+= usr.bin
83.endif
84.if exists(usr.sbin)
85SUBDIR+= usr.sbin
86.endif
87.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
88SUBDIR+= secure
89.endif
90.if exists(lkm) && !defined(NOLKM)
91SUBDIR+= lkm
92.endif
93
94# etc must be last for "distribute" to work
95.if exists(etc) && make(distribute)
96SUBDIR+= etc
97.endif
98
99# These are last, since it is nice to at least get the base system
100# rebuilt before you do them.
101.if defined(MAKE_LOCAL) & exists(local) & exists(local/Makefile)
102SUBDIR+= local
103.endif
104.if defined(MAKE_PORTS) & exists(ports) & exists(ports/Makefile)
105SUBDIR+= ports
106.endif
107
108# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
109.if defined(NOOBJDIR)
110OBJDIR=
111.else
112OBJDIR=		obj
113.endif
114
115.if defined(NOCLEAN)
116CLEANDIR=
117.else
118.if defined(NOCLEANDIR)
119CLEANDIR=	clean
120.else
121CLEANDIR=	cleandir
122.endif
123.endif
124
125SUP?=           sup
126SUPFLAGS?=      -v
127
128#
129# While building tools for bootstrapping, we dont need to waste time on
130# profiled libraries or man pages.  This speeds things up somewhat.
131#
132MK_FLAGS=	-DNOINFO -DNOMAN -DNOPROFILE
133
134#
135# world
136#
137# Attempt to rebuild and reinstall *everything*, with reasonable chance of
138# success, regardless of how old your existing system is.
139#
140# >> Beware, it overwrites the local build environment! <<
141#
142world:
143	@echo "--------------------------------------------------------------"
144	@echo "make world started on `LC_TIME=C date`"
145	@echo "--------------------------------------------------------------"
146.if target(pre-world)
147	@echo "--------------------------------------------------------------"
148	@echo " Making 'pre-world' target"
149	@echo "--------------------------------------------------------------"
150	cd ${.CURDIR} && ${MAKE} pre-world
151	@echo
152.endif
153	@echo "--------------------------------------------------------------"
154	@echo " Making hierarchy"
155	@echo "--------------------------------------------------------------"
156	cd ${.CURDIR} && ${MAKE} hierarchy
157	@echo
158	@echo "--------------------------------------------------------------"
159	@echo " Cleaning up the source tree"
160	@echo "--------------------------------------------------------------"
161.if defined(NOCLEAN)
162	@echo "Not cleaning anything! I sure hope you know what you are doing!"
163.else
164	cd ${.CURDIR} && ${MAKE} ${CLEANDIR}
165.endif
166	@echo
167.if !defined(NOOBJDIR)
168	@echo "--------------------------------------------------------------"
169	@echo " Rebuilding the obj tree"
170	@echo "--------------------------------------------------------------"
171	cd ${.CURDIR} && ${MAKE} obj
172	@echo
173.endif
174	@echo "--------------------------------------------------------------"
175	@echo " Rebuilding bootstrap tools"
176	@echo "--------------------------------------------------------------"
177	cd ${.CURDIR} && ${MAKE} bootstrap
178	@echo
179	@echo "--------------------------------------------------------------"
180	@echo " Rebuilding tools necessary to build the include files"
181	@echo "--------------------------------------------------------------"
182	cd ${.CURDIR} && ${MAKE} include-tools
183	@echo
184	@echo "--------------------------------------------------------------"
185	@echo " Rebuilding /usr/include"
186	@echo "--------------------------------------------------------------"
187	cd ${.CURDIR} && ${MAKE} includes
188	@echo
189	@echo "--------------------------------------------------------------"
190	@echo " Rebuilding tools needed to build the libraries"
191	@echo "--------------------------------------------------------------"
192	cd ${.CURDIR} && ${MAKE} lib-tools
193	@echo
194	@echo "--------------------------------------------------------------"
195	@echo " Rebuilding /usr/lib"
196	@echo "--------------------------------------------------------------"
197	cd ${.CURDIR} && ${MAKE} libraries
198	@echo
199	@echo "--------------------------------------------------------------"
200	@echo " Rebuilding sgml tools, symorder, groff and zic(8)"
201	@echo "--------------------------------------------------------------"
202	cd ${.CURDIR} && ${MAKE} build-tools
203	@echo
204	@echo "--------------------------------------------------------------"
205	@echo " Rebuilding dependencies"
206	@echo "--------------------------------------------------------------"
207	cd ${.CURDIR} && ${MAKE} depend
208	@echo
209	@echo "--------------------------------------------------------------"
210	@echo " Building everything.."
211	@echo "--------------------------------------------------------------"
212	cd ${.CURDIR} && ${MAKE} all
213	@echo
214	@echo "--------------------------------------------------------------"
215	@echo " Installing everything.."
216	@echo "--------------------------------------------------------------"
217	cd ${.CURDIR} && ${MAKE} install
218	@echo
219	@echo "--------------------------------------------------------------"
220	@echo " Rebuilding man page indexes"
221	@echo "--------------------------------------------------------------"
222	cd ${.CURDIR}/share/man && ${MAKE} makedb
223.if target(post-world)
224	@echo
225	@echo "--------------------------------------------------------------"
226	@echo " Making 'post-world' target"
227	@echo "--------------------------------------------------------------"
228	cd ${.CURDIR} && ${MAKE} post-world
229.endif
230	@echo
231	@echo "--------------------------------------------------------------"
232	@echo "make world completed on `LC_TIME=C date`"
233	@echo "--------------------------------------------------------------"
234
235#
236# reinstall
237#
238# If you have a build server, you can NFS mount the source and obj directories
239# and do a 'make reinstall' on the *client* to install new binaries from the
240# most recent server build.
241#
242reinstall:
243	@echo "--------------------------------------------------------------"
244	@echo " Making hierarchy"
245	@echo "--------------------------------------------------------------"
246	cd ${.CURDIR} && ${MAKE} hierarchy
247	@echo
248	@echo "--------------------------------------------------------------"
249	@echo " Installing everything.."
250	@echo "--------------------------------------------------------------"
251	cd ${.CURDIR} && ${MAKE} install
252	@echo
253	@echo "--------------------------------------------------------------"
254	@echo " Rebuilding man page indexes"
255	@echo "--------------------------------------------------------------"
256	cd ${.CURDIR}/share/man && ${MAKE} makedb
257
258
259#
260# update
261#
262# Update the source tree, by running sup and/or running cvs to update to the
263# latest copy.
264#
265update:
266.if defined(SUP_UPDATE)
267	@echo "--------------------------------------------------------------"
268	@echo "Running sup"
269	@echo "--------------------------------------------------------------"
270	@${SUP} ${SUPFLAGS} ${SUPFILE}
271.if defined(SUPFILE1)
272	@${SUP} ${SUPFLAGS} ${SUPFILE1}
273.endif
274.if defined(SUPFILE2)
275	@${SUP} ${SUPFLAGS} ${SUPFILE2}
276.endif
277.endif
278.if defined(CVS_UPDATE)
279	@echo "--------------------------------------------------------------"
280	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
281	@echo "--------------------------------------------------------------"
282	cd ${.CURDIR} &&  cvs -q update -P -d
283.endif
284
285
286#
287# most
288#
289# Build most of the user binaries on the existing system libs and includes.
290#
291most:
292	@echo "--------------------------------------------------------------"
293	@echo " Building programs only"
294	@echo "--------------------------------------------------------------"
295	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} all
296	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} all
297	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} all
298	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} all
299	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} all
300	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} all
301	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} all
302	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} all
303#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
304#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} most
305#.endif
306#.if !defined(NOSECURE) && !defined(NOCRYPT)
307#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} most
308#.endif
309
310#
311# installmost
312#
313# Install the binaries built by the 'most' target.  This does not include
314# libraries or include files.
315#
316installmost:
317	@echo "--------------------------------------------------------------"
318	@echo " Installing programs only"
319	@echo "--------------------------------------------------------------"
320	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} install
321	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} install
322	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} install
323	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} install
324	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} install
325	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} install
326	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} install
327	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} install
328#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
329#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} installmost
330#.endif
331#.if !defined(NOSECURE) && !defined(NOCRYPT)
332#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} installmost
333#.endif
334
335#
336# ------------------------------------------------------------------------
337#
338# From here onwards are utility targets used by the 'make world' and
339# related targets.  If your 'world' breaks, you may like to try to fix
340# the problem and manually run the following targets to attempt to
341# complete the build.  Beware, this is *not* guaranteed to work, you
342# need to have a pretty good grip on the current state of the system
343# to attempt to manually finish it.  If in doubt, 'make world' again.
344#
345
346#
347# heirarchy - ensure that all the needed directories are present
348#
349hierarchy:
350	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
351
352#
353# bootstrap - [re]build tools needed to run the actual build, this includes
354# tools needed by 'make depend', as some tools are needed to generate source
355# for the dependency information to be gathered from.
356#
357bootstrap:
358	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
359		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
360	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
361		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
362	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
363		${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
364
365#
366# include-tools - generally the same as 'bootstrap', except that it's for
367# things that are specifically needed to generate include files.
368#
369# XXX should be merged with bootstrap, it's not worth keeeping them seperate
370#
371include-tools:
372	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} depend && \
373		${MAKE} ${MK_FLAGS} depend all install ${CLEANDIR} ${OBJDIR}
374
375#
376# includes - possibly generate and install the include files.
377#
378includes:
379.if defined(CLOBBER)
380	rm -rf ${DESTDIR}/usr/include/*
381	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
382		-p ${DESTDIR}/usr/include
383.endif
384	cd ${.CURDIR}/include/rpcsvc &&		${MAKE} all
385	cd ${.CURDIR}/include &&		${MAKE} install
386	cd ${.CURDIR}/gnu/include &&		${MAKE} install
387	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
388	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
389	cd ${.CURDIR}/gnu/lib/libstdc++ &&      ${MAKE} beforeinstall
390	cd ${.CURDIR}/gnu/lib/libg++ &&         ${MAKE} beforeinstall
391	cd ${.CURDIR}/gnu/lib/libdialog &&      ${MAKE} beforeinstall
392.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
393	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
394	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
395	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
396.endif
397	cd ${.CURDIR}/lib/csu/i386 &&		${MAKE} beforeinstall
398	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
399	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
400	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
401	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
402	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
403	cd ${.CURDIR}/lib/libmytinfo &&         ${MAKE} beforeinstall
404	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
405.if !defined(WANT_CSRG_LIBM)
406	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
407.endif
408	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
409	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
410	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
411	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
412	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
413	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
414	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
415	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
416	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
417
418#
419# lib-tools - build tools to compile and install the libraries.
420#
421lib-tools:
422	cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \
423		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
424	cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \
425		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
426	cd ${.CURDIR}/gnu/usr.bin/as && ${MAKE} depend && \
427		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
428	cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \
429		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
430	cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \
431		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
432	cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \
433		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
434	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
435		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
436	cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \
437		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \
438		rm -f /usr/sbin/compile_et
439	cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \
440		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
441	cd ${.CURDIR}/usr.bin/uudecode && ${MAKE} depend && \
442		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
443	cd ${.CURDIR}/gnu/usr.bin/bison && ${MAKE} depend && \
444		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
445	cd ${.CURDIR}/gnu/usr.bin/gperf && ${MAKE} depend && \
446		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
447	cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \
448		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
449
450#
451# libraries - build and install the libraries
452#
453libraries:
454.if exists(lib/csu/i386)
455	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
456		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
457.endif
458.if exists(lib/libcompat)
459	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
460		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
461.endif
462.if exists(lib/libncurses)
463	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
464		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
465.endif
466.if exists(lib/libtermcap)
467	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
468		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
469.endif
470.if exists(gnu)
471	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
472		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
473.endif
474.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
475	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
476		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
477.endif
478.if exists(lib)
479	cd ${.CURDIR}/lib && ${MAKE} depend && \
480		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
481.endif
482.if exists(usr.bin/lex/lib)
483	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
484		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
485.endif
486.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
487	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
488		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
489.endif
490.if exists(usr.sbin/pcvt/keycap)
491	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
492		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
493.endif
494
495#
496# build-tools - build and install any other tools needed to complete the
497# compile and install.
498#
499build-tools:
500.for d in				\
501		share/info		\
502		gnu/usr.bin/texinfo     \
503		usr.bin/symorder	\
504		usr.bin/sgmls		\
505		usr.bin/sgmlfmt		\
506		share/sgml		\
507		usr.sbin/zic		\
508		gnu/usr.bin/awk		\
509		gnu/usr.bin/groff
510	cd ${.CURDIR}/$d && ${MAKE} depend && \
511		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
512.endfor
513
514.include <bsd.subdir.mk>
515