Makefile revision 20710
1#
2#	$Id: Makefile,v 1.110 1996/11/26 03:26:31 ache 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
22#
23# The intended user-driven targets are:
24# world       - rebuild *everything*, including glue to help do upgrades.
25# reinstall   - use an existing (eg: NFS mounted) build to do an update.
26# update      - convenient way to update your source tree (eg: sup/cvs)
27# most        - build user commands, no libraries or include files
28# installmost - install user commands, no libraries or include files
29#
30# Standard targets (not defined here) are documented in the makefiles in
31# /usr/share/mk.  These include:
32#		obj depend all install clean cleandepend cleanobj
33
34
35# Put initial settings here.
36SUBDIR=
37
38# We must do include and lib first so that the perl *.ph generation
39# works correctly as it uses the header files installed by this.
40.if exists(include)
41SUBDIR+= include
42.endif
43.if exists(lib)
44SUBDIR+= lib
45.endif
46
47.if exists(bin)
48SUBDIR+= bin
49.endif
50.if exists(games) && !defined(NOGAMES)
51SUBDIR+= games
52.endif
53.if exists(gnu)
54SUBDIR+= gnu
55.endif
56.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
57SUBDIR+= eBones
58.endif
59.if exists(libexec)
60SUBDIR+= libexec
61.endif
62.if exists(sbin)
63SUBDIR+= sbin
64.endif
65.if exists(share) && !defined(NOSHARE)
66SUBDIR+= share
67.endif
68.if exists(sys)
69SUBDIR+= sys
70.endif
71.if exists(usr.bin)
72SUBDIR+= usr.bin
73.endif
74.if exists(usr.sbin)
75SUBDIR+= usr.sbin
76.endif
77.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
78SUBDIR+= secure
79.endif
80.if exists(lkm) && !defined(NOLKM)
81SUBDIR+= lkm
82.endif
83
84# etc must be last for "distribute" to work
85.if exists(etc) && make(distribute)
86SUBDIR+= etc
87.endif
88
89# These are last, since it is nice to at least get the base system
90# rebuilt before you do them.
91.if defined(MAKE_LOCAL) & exists(local) & exists(local/Makefile)
92SUBDIR+= local
93.endif
94.if defined(MAKE_PORTS) & exists(ports) & exists(ports/Makefile)
95SUBDIR+= ports
96.endif
97
98# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
99.if defined(NOOBJDIR)
100OBJDIR=
101.else
102OBJDIR=		obj
103.endif
104
105.if defined(NOCLEAN)
106CLEANDIR=
107.else
108.if defined(NOCLEANDIR)
109CLEANDIR=	clean
110.else
111CLEANDIR=	cleandir
112.endif
113.endif
114
115SUP?=           sup
116SUPFLAGS?=      -v
117
118#
119# While building tools for bootstrapping, we dont need to waste time on
120# profiled libraries or man pages.  This speeds things up somewhat.
121#
122MK_FLAGS=	-DNOMAN -DNOPROFILE
123
124#
125# world
126#
127# Attempt to rebuild and reinstall *everything*, with reasonable chance of
128# success, regardless of how old your existing system is.
129#
130# >> Beware, it overwrites the local build environment! <<
131#
132world:
133	@echo "--------------------------------------------------------------"
134	@echo "make world started on `LC_TIME=C date`"
135	@echo "--------------------------------------------------------------"
136.if target(pre-world)
137	@echo "--------------------------------------------------------------"
138	@echo " Making 'pre-world' target"
139	@echo "--------------------------------------------------------------"
140	cd ${.CURDIR} && ${MAKE} pre-world
141	@echo
142.endif
143	@echo "--------------------------------------------------------------"
144	@echo " Making hierarchy"
145	@echo "--------------------------------------------------------------"
146	cd ${.CURDIR} && ${MAKE} hierarchy
147	@echo
148	@echo "--------------------------------------------------------------"
149	@echo " Rebuilding /usr/share/mk"
150	@echo "--------------------------------------------------------------"
151	cd ${.CURDIR} && ${MAKE} mk
152	@echo
153	@echo "--------------------------------------------------------------"
154	@echo " Cleaning up the source tree"
155	@echo "--------------------------------------------------------------"
156.if defined(NOCLEAN)
157	@echo "Not cleaning anything! I sure hope you know what you are doing!"
158.else
159	cd ${.CURDIR} && ${MAKE} ${CLEANDIR}
160.endif
161	@echo
162.if !defined(NOOBJDIR)
163	@echo "--------------------------------------------------------------"
164	@echo " Rebuilding the obj tree"
165	@echo "--------------------------------------------------------------"
166	cd ${.CURDIR} && ${MAKE} obj
167	@echo
168.endif
169	@echo "--------------------------------------------------------------"
170	@echo " Rebuilding bootstrap tools"
171	@echo "--------------------------------------------------------------"
172	cd ${.CURDIR} && ${MAKE} bootstrap
173	@echo
174	@echo "--------------------------------------------------------------"
175	@echo " Rebuilding tools necessary to build the include files"
176	@echo "--------------------------------------------------------------"
177	cd ${.CURDIR} && ${MAKE} include-tools
178	@echo
179	@echo "--------------------------------------------------------------"
180	@echo " Rebuilding /usr/include"
181	@echo "--------------------------------------------------------------"
182	cd ${.CURDIR} && ${MAKE} includes
183	@echo
184	@echo "--------------------------------------------------------------"
185	@echo " Rebuilding tools needed to build the libraries"
186	@echo "--------------------------------------------------------------"
187	cd ${.CURDIR} && ${MAKE} lib-tools
188	@echo
189	@echo "--------------------------------------------------------------"
190	@echo " Rebuilding /usr/lib"
191	@echo "--------------------------------------------------------------"
192	cd ${.CURDIR} && ${MAKE} libraries
193	@echo
194	@echo "--------------------------------------------------------------"
195	@echo " Rebuilding sgml tools, symorder, groff and zic(8)"
196	@echo "--------------------------------------------------------------"
197	cd ${.CURDIR} && ${MAKE} build-tools
198	@echo
199	@echo "--------------------------------------------------------------"
200	@echo " Rebuilding dependencies"
201	@echo "--------------------------------------------------------------"
202	cd ${.CURDIR} && ${MAKE} depend
203	@echo
204	@echo "--------------------------------------------------------------"
205	@echo " Building everything.."
206	@echo "--------------------------------------------------------------"
207	cd ${.CURDIR} && ${MAKE} all
208	@echo
209	@echo "--------------------------------------------------------------"
210	@echo " Installing everything.."
211	@echo "--------------------------------------------------------------"
212	cd ${.CURDIR} && ${MAKE} install
213	@echo
214	@echo "--------------------------------------------------------------"
215	@echo " Rebuilding man page indexes"
216	@echo "--------------------------------------------------------------"
217	cd ${.CURDIR}/share/man && ${MAKE} makedb
218.if target(post-world)
219	@echo
220	@echo "--------------------------------------------------------------"
221	@echo " Making 'post-world' target"
222	@echo "--------------------------------------------------------------"
223	cd ${.CURDIR} && ${MAKE} post-world
224.endif
225	@echo
226	@echo "--------------------------------------------------------------"
227	@echo "make world completed on `LC_TIME=C date`"
228	@echo "--------------------------------------------------------------"
229
230#
231# reinstall
232#
233# If you have a build server, you can NFS mount the source and obj directories
234# and do a 'make reinstall' on the *client* to install new binaries from the
235# most recent server build.
236#
237reinstall:
238	@echo "--------------------------------------------------------------"
239	@echo " Making hierarchy"
240	@echo "--------------------------------------------------------------"
241	cd ${.CURDIR} && ${MAKE} hierarchy
242	@echo
243	@echo "--------------------------------------------------------------"
244	@echo " Rebuilding /usr/share/mk"
245	@echo "--------------------------------------------------------------"
246	cd ${.CURDIR} && ${MAKE} mk
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# mk - update the /usr/share/mk makefiles.
354#
355mk:
356	cd ${.CURDIR}/share/mk &&	${MAKE} install
357
358#
359# bootstrap - [re]build tools needed to run the actual build, this includes
360# tools needed by 'make depend', as some tools are needed to generate source
361# for the dependency information to be gathered from.
362#
363bootstrap:
364	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
365		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
366	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
367		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
368	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
369		${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
370
371#
372# include-tools - generally the same as 'bootstrap', except that it's for
373# things that are specifically needed to generate include files.
374#
375# XXX should be merged with bootstrap, it's not worth keeeping them seperate
376#
377include-tools:
378	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} depend && \
379		${MAKE} ${MK_FLAGS} depend all install ${CLEANDIR} ${OBJDIR}
380
381#
382# includes - possibly generate and install the include files.
383#
384includes:
385.if defined(CLOBBER)
386	rm -rf ${DESTDIR}/usr/include/*
387	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
388		-p ${DESTDIR}/usr/include
389.endif
390	cd ${.CURDIR}/include/rpcsvc &&		${MAKE} all
391	cd ${.CURDIR}/include &&		${MAKE} install
392	cd ${.CURDIR}/gnu/include &&		${MAKE} install
393	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
394	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
395	cd ${.CURDIR}/gnu/lib/libstdc++ &&      ${MAKE} beforeinstall
396	cd ${.CURDIR}/gnu/lib/libg++ &&         ${MAKE} beforeinstall
397	cd ${.CURDIR}/gnu/lib/libdialog &&      ${MAKE} beforeinstall
398.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
399	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
400	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
401	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
402.endif
403	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
404	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
405	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
406	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
407	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
408	cd ${.CURDIR}/lib/libmytinfo &&         ${MAKE} beforeinstall
409	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
410.if !defined(WANT_CSRG_LIBM)
411	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
412.endif
413	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
414	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
415	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
416	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
417	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
418	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
419	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
420	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
421	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
422
423#
424# lib-tools - build tools to compile and install the libraries.
425#
426lib-tools:
427	cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \
428		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
429	cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \
430		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
431	cd ${.CURDIR}/gnu/usr.bin/as && ${MAKE} depend && \
432		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
433	cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \
434		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
435	cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \
436		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
437	cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \
438		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
439	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
440		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
441	cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \
442		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \
443		rm -f /usr/sbin/compile_et
444	cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \
445		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
446	cd ${.CURDIR}/gnu/usr.bin/bison && ${MAKE} depend && \
447		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
448	cd ${.CURDIR}/gnu/usr.bin/gperf && ${MAKE} depend && \
449		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
450	cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \
451		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
452
453#
454# libraries - build and install the libraries
455#
456libraries:
457.if exists(lib/libcompat)
458	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
459		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
460.endif
461.if exists(lib/libncurses)
462	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
463		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
464.endif
465.if exists(lib/libtermcap)
466	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
467		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
468.endif
469.if exists(lib)
470	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
471		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
472.endif
473.if exists(gnu)
474	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
475		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
476.endif
477.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
478	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
479		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
480.endif
481.if exists(lib)
482	cd ${.CURDIR}/lib && ${MAKE} depend && \
483		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
484.endif
485.if exists(usr.bin/lex/lib)
486	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
487		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
488.endif
489.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
490	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
491		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
492.endif
493.if exists(usr.sbin/pcvt/keycap)
494	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
495		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
496.endif
497
498#
499# build-tools - build and install any other tools needed to complete the
500# compile and install.
501#
502build-tools:
503.for d in				\
504		usr.bin/symorder	\
505		usr.bin/sgmls		\
506		usr.bin/sgmlfmt		\
507		share/sgml		\
508		usr.sbin/zic		\
509		gnu/usr.bin/awk		\
510		gnu/usr.bin/groff
511	cd ${.CURDIR}/$d && ${MAKE} depend && \
512		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
513.endfor
514
515.include <bsd.subdir.mk>
516