Makefile revision 27788
1#
2#	$Id: Makefile,v 1.130 1997/06/08 15:04:06 jfieber Exp $
3#
4# Make command line options:
5#	-DCLOBBER will remove /usr/include
6#	-DMAKE_EBONES to build eBones (KerberosIV)
7#	-DALLLANG to build documentation for all languages
8#	  (where available -- see share/doc/Makefile)
9#
10#	-DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
11#	-DNOCLEAN do not clean at all
12#	-DNOCRYPT will prevent building of crypt versions
13#	-DNOLKM do not build loadable kernel modules
14#	-DNOOBJDIR do not run ``${MAKE} obj''
15#	-DNOPROFILE do not build profiled libraries
16#	-DNOSECURE do not go into secure subdir
17#	-DNOGAMES do not go into games subdir
18#	-DNOSHARE do not go into share subdir
19#	-DNOINFO do not make or install info files
20#	-DNOLIBC_R do not build libc_r.
21#	LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
22
23#
24# The intended user-driven targets are:
25# world       - rebuild *everything*, including glue to help do upgrades.
26# reinstall   - use an existing (eg: NFS mounted) build to do an update.
27# update      - convenient way to update your source tree (eg: sup/cvs)
28# most        - build user commands, no libraries or include files
29# installmost - install user commands, no libraries or include files
30#
31# Standard targets (not defined here) are documented in the makefiles in
32# /usr/share/mk.  These include:
33#		obj depend all install clean cleandepend cleanobj
34
35.MAKEFLAGS:=	${.MAKEFLAGS} -m ${.CURDIR}/share/mk
36
37# Put initial settings here.
38SUBDIR=
39
40# We must do share/info early so that installation of info `dir'
41# entries works correctly.  Do it first since it is less likely to
42# grow dependencies on include and lib than vice versa.
43.if exists(share/info)
44SUBDIR+= share/info
45.endif
46
47# We must do include and lib early so that the perl *.ph generation
48# works correctly as it uses the header files installed by this.
49.if exists(include)
50SUBDIR+= include
51.endif
52.if exists(lib)
53SUBDIR+= lib
54.endif
55
56.if exists(bin)
57SUBDIR+= bin
58.endif
59.if exists(games) && !defined(NOGAMES)
60SUBDIR+= games
61.endif
62.if exists(gnu)
63SUBDIR+= gnu
64.endif
65.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
66SUBDIR+= eBones
67.endif
68.if exists(libexec)
69SUBDIR+= libexec
70.endif
71.if exists(sbin)
72SUBDIR+= sbin
73.endif
74.if exists(share) && !defined(NOSHARE)
75SUBDIR+= share
76.endif
77.if exists(sys)
78SUBDIR+= sys
79.endif
80.if exists(usr.bin)
81SUBDIR+= usr.bin
82.endif
83.if exists(usr.sbin)
84SUBDIR+= usr.sbin
85.endif
86.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
87SUBDIR+= secure
88.endif
89.if exists(lkm) && !defined(NOLKM)
90SUBDIR+= lkm
91.endif
92
93# etc must be last for "distribute" to work
94.if exists(etc) && make(distribute)
95SUBDIR+= etc
96.endif
97
98# These are last, since it is nice to at least get the base system
99# rebuilt before you do them.
100.if defined(LOCAL_DIRS)
101.for _DIR in ${LOCAL_DIRS}
102.if exists(${_DIR}) & exists(${_DIR}/Makefile)
103SUBDIR+= ${_DIR}
104.endif
105.endfor
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 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 &&		${MAKE} all install
385	cd ${.CURDIR}/gnu/include &&		${MAKE} install
386	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
387	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
388	cd ${.CURDIR}/gnu/lib/libstdc++ &&      ${MAKE} beforeinstall
389	cd ${.CURDIR}/gnu/lib/libg++ &&         ${MAKE} beforeinstall
390	cd ${.CURDIR}/gnu/lib/libdialog &&      ${MAKE} beforeinstall
391	cd ${.CURDIR}/gnu/lib/libmp &&		${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/libalias &&		${MAKE} beforeinstall
399	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
400	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
401	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
402	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
403	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
404	cd ${.CURDIR}/lib/libmytinfo &&         ${MAKE} beforeinstall
405	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
406.if !defined(WANT_CSRG_LIBM)
407	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
408.endif
409	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
410	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
411	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
412	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
413	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
414	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
415	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
416	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
417	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
418	cd ${.CURDIR}/lib/libz &&		${MAKE} beforeinstall
419
420#
421# lib-tools - build tools to compile and install the libraries.
422#
423lib-tools:
424	cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \
425		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
426	cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \
427		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
428	cd ${.CURDIR}/gnu/usr.bin/as && ${MAKE} depend && \
429		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
430	cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \
431		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
432	cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \
433		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
434	cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \
435		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
436	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
437		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
438	cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \
439		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \
440		rm -f /usr/sbin/compile_et
441	cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \
442		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
443	cd ${.CURDIR}/usr.bin/uudecode && ${MAKE} depend && \
444		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
445	cd ${.CURDIR}/gnu/usr.bin/bison && ${MAKE} depend && \
446		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
447	cd ${.CURDIR}/gnu/usr.bin/gperf && ${MAKE} depend && \
448		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
449	cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \
450		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
451
452#
453# libraries - build and install the libraries
454#
455libraries:
456.if exists(lib/csu/i386)
457	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
458		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
459.endif
460.if exists(lib/libcompat)
461	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
462		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
463.endif
464.if exists(lib/libncurses)
465	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
466		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
467.endif
468.if exists(lib/libtermcap)
469	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
470		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
471.endif
472.if exists(gnu)
473	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
474		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
475.endif
476.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
477	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
478		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
479.endif
480.if exists(lib)
481	cd ${.CURDIR}/lib && ${MAKE} depend && \
482		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
483.endif
484.if exists(usr.bin/lex/lib)
485	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
486		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
487.endif
488.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
489	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
490		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
491.endif
492.if exists(usr.sbin/pcvt/keycap)
493	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
494		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
495.endif
496
497#
498# build-tools - build and install any other tools needed to complete the
499# compile and install.
500#
501build-tools:
502.for d in				\
503		share/info		\
504		gnu/usr.bin/texinfo     \
505		usr.bin/symorder	\
506		usr.sbin/zic		\
507		gnu/usr.bin/awk		\
508		gnu/usr.bin/groff
509	cd ${.CURDIR}/$d && ${MAKE} depend && \
510		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
511.endfor
512
513.include <bsd.subdir.mk>
514