Makefile revision 25399
1#
2#	$Id: Makefile,v 1.122 1997/04/30 16:02:03 bde 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
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(MAKE_LOCAL) & exists(local) & exists(local/Makefile)
101SUBDIR+= local
102.endif
103.if defined(MAKE_PORTS) & exists(ports) & exists(ports/Makefile)
104SUBDIR+= ports
105.endif
106
107# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
108.if defined(NOOBJDIR)
109OBJDIR=
110.else
111OBJDIR=		obj
112.endif
113
114.if defined(NOCLEAN)
115CLEANDIR=
116.else
117.if defined(NOCLEANDIR)
118CLEANDIR=	clean
119.else
120CLEANDIR=	cleandir
121.endif
122.endif
123
124SUP?=           sup
125SUPFLAGS?=      -v
126
127#
128# While building tools for bootstrapping, we dont need to waste time on
129# profiled libraries or man pages.  This speeds things up somewhat.
130#
131MK_FLAGS=	-DNOINFO -DNOMAN -DNOPROFILE
132
133#
134# world
135#
136# Attempt to rebuild and reinstall *everything*, with reasonable chance of
137# success, regardless of how old your existing system is.
138#
139# >> Beware, it overwrites the local build environment! <<
140#
141world:
142	@echo "--------------------------------------------------------------"
143	@echo "make world started on `LC_TIME=C date`"
144	@echo "--------------------------------------------------------------"
145.if target(pre-world)
146	@echo "--------------------------------------------------------------"
147	@echo " Making 'pre-world' target"
148	@echo "--------------------------------------------------------------"
149	cd ${.CURDIR} && ${MAKE} pre-world
150	@echo
151.endif
152	@echo "--------------------------------------------------------------"
153	@echo " Making hierarchy"
154	@echo "--------------------------------------------------------------"
155	cd ${.CURDIR} && ${MAKE} hierarchy
156	@echo
157	@echo "--------------------------------------------------------------"
158	@echo " Rebuilding /usr/share/mk"
159	@echo "--------------------------------------------------------------"
160	cd ${.CURDIR} && ${MAKE} mk
161	@echo
162	@echo "--------------------------------------------------------------"
163	@echo " Cleaning up the source tree"
164	@echo "--------------------------------------------------------------"
165.if defined(NOCLEAN)
166	@echo "Not cleaning anything! I sure hope you know what you are doing!"
167.else
168	cd ${.CURDIR} && ${MAKE} ${CLEANDIR}
169.endif
170	@echo
171.if !defined(NOOBJDIR)
172	@echo "--------------------------------------------------------------"
173	@echo " Rebuilding the obj tree"
174	@echo "--------------------------------------------------------------"
175	cd ${.CURDIR} && ${MAKE} obj
176	@echo
177.endif
178	@echo "--------------------------------------------------------------"
179	@echo " Rebuilding bootstrap tools"
180	@echo "--------------------------------------------------------------"
181	cd ${.CURDIR} && ${MAKE} bootstrap
182	@echo
183	@echo "--------------------------------------------------------------"
184	@echo " Rebuilding tools necessary to build the include files"
185	@echo "--------------------------------------------------------------"
186	cd ${.CURDIR} && ${MAKE} include-tools
187	@echo
188	@echo "--------------------------------------------------------------"
189	@echo " Rebuilding /usr/include"
190	@echo "--------------------------------------------------------------"
191	cd ${.CURDIR} && ${MAKE} includes
192	@echo
193	@echo "--------------------------------------------------------------"
194	@echo " Rebuilding tools needed to build the libraries"
195	@echo "--------------------------------------------------------------"
196	cd ${.CURDIR} && ${MAKE} lib-tools
197	@echo
198	@echo "--------------------------------------------------------------"
199	@echo " Rebuilding /usr/lib"
200	@echo "--------------------------------------------------------------"
201	cd ${.CURDIR} && ${MAKE} libraries
202	@echo
203	@echo "--------------------------------------------------------------"
204	@echo " Rebuilding sgml tools, symorder, groff and zic(8)"
205	@echo "--------------------------------------------------------------"
206	cd ${.CURDIR} && ${MAKE} build-tools
207	@echo
208	@echo "--------------------------------------------------------------"
209	@echo " Rebuilding dependencies"
210	@echo "--------------------------------------------------------------"
211	cd ${.CURDIR} && ${MAKE} depend
212	@echo
213	@echo "--------------------------------------------------------------"
214	@echo " Building everything.."
215	@echo "--------------------------------------------------------------"
216	cd ${.CURDIR} && ${MAKE} all
217	@echo
218	@echo "--------------------------------------------------------------"
219	@echo " Installing everything.."
220	@echo "--------------------------------------------------------------"
221	cd ${.CURDIR} && ${MAKE} install
222	@echo
223	@echo "--------------------------------------------------------------"
224	@echo " Rebuilding man page indexes"
225	@echo "--------------------------------------------------------------"
226	cd ${.CURDIR}/share/man && ${MAKE} makedb
227.if target(post-world)
228	@echo
229	@echo "--------------------------------------------------------------"
230	@echo " Making 'post-world' target"
231	@echo "--------------------------------------------------------------"
232	cd ${.CURDIR} && ${MAKE} post-world
233.endif
234	@echo
235	@echo "--------------------------------------------------------------"
236	@echo "make world completed on `LC_TIME=C date`"
237	@echo "--------------------------------------------------------------"
238
239#
240# reinstall
241#
242# If you have a build server, you can NFS mount the source and obj directories
243# and do a 'make reinstall' on the *client* to install new binaries from the
244# most recent server build.
245#
246reinstall:
247	@echo "--------------------------------------------------------------"
248	@echo " Making hierarchy"
249	@echo "--------------------------------------------------------------"
250	cd ${.CURDIR} && ${MAKE} hierarchy
251	@echo
252	@echo "--------------------------------------------------------------"
253	@echo " Rebuilding /usr/share/mk"
254	@echo "--------------------------------------------------------------"
255	cd ${.CURDIR} && ${MAKE} mk
256	@echo
257	@echo "--------------------------------------------------------------"
258	@echo " Installing everything.."
259	@echo "--------------------------------------------------------------"
260	cd ${.CURDIR} && ${MAKE} install
261	@echo
262	@echo "--------------------------------------------------------------"
263	@echo " Rebuilding man page indexes"
264	@echo "--------------------------------------------------------------"
265	cd ${.CURDIR}/share/man && ${MAKE} makedb
266
267
268#
269# update
270#
271# Update the source tree, by running sup and/or running cvs to update to the
272# latest copy.
273#
274update:
275.if defined(SUP_UPDATE)
276	@echo "--------------------------------------------------------------"
277	@echo "Running sup"
278	@echo "--------------------------------------------------------------"
279	@${SUP} ${SUPFLAGS} ${SUPFILE}
280.if defined(SUPFILE1)
281	@${SUP} ${SUPFLAGS} ${SUPFILE1}
282.endif
283.if defined(SUPFILE2)
284	@${SUP} ${SUPFLAGS} ${SUPFILE2}
285.endif
286.endif
287.if defined(CVS_UPDATE)
288	@echo "--------------------------------------------------------------"
289	@echo "Updating /usr/src from cvs repository" ${CVSROOT}
290	@echo "--------------------------------------------------------------"
291	cd ${.CURDIR} &&  cvs -q update -P -d
292.endif
293
294
295#
296# most
297#
298# Build most of the user binaries on the existing system libs and includes.
299#
300most:
301	@echo "--------------------------------------------------------------"
302	@echo " Building programs only"
303	@echo "--------------------------------------------------------------"
304	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} all
305	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} all
306	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} all
307	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} all
308	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} all
309	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} all
310	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} all
311	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} all
312#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
313#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} most
314#.endif
315#.if !defined(NOSECURE) && !defined(NOCRYPT)
316#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} most
317#.endif
318
319#
320# installmost
321#
322# Install the binaries built by the 'most' target.  This does not include
323# libraries or include files.
324#
325installmost:
326	@echo "--------------------------------------------------------------"
327	@echo " Installing programs only"
328	@echo "--------------------------------------------------------------"
329	cd ${.CURDIR}/bin	&&	${MAKE} ${.MAKEFLAGS} install
330	cd ${.CURDIR}/sbin	&&	${MAKE} ${.MAKEFLAGS} install
331	cd ${.CURDIR}/libexec	&&	${MAKE} ${.MAKEFLAGS} install
332	cd ${.CURDIR}/usr.bin	&&	${MAKE} ${.MAKEFLAGS} install
333	cd ${.CURDIR}/usr.sbin	&&	${MAKE} ${.MAKEFLAGS} install
334	cd ${.CURDIR}/gnu/libexec &&	${MAKE} ${.MAKEFLAGS} install
335	cd ${.CURDIR}/gnu/usr.bin &&	${MAKE} ${.MAKEFLAGS} install
336	cd ${.CURDIR}/gnu/usr.sbin &&	${MAKE} ${.MAKEFLAGS} install
337#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
338#	cd ${.CURDIR}/eBones	&&	${MAKE} ${.MAKEFLAGS} installmost
339#.endif
340#.if !defined(NOSECURE) && !defined(NOCRYPT)
341#	cd ${.CURDIR}/secure	&&	${MAKE} ${.MAKEFLAGS} installmost
342#.endif
343
344#
345# ------------------------------------------------------------------------
346#
347# From here onwards are utility targets used by the 'make world' and
348# related targets.  If your 'world' breaks, you may like to try to fix
349# the problem and manually run the following targets to attempt to
350# complete the build.  Beware, this is *not* guaranteed to work, you
351# need to have a pretty good grip on the current state of the system
352# to attempt to manually finish it.  If in doubt, 'make world' again.
353#
354
355#
356# heirarchy - ensure that all the needed directories are present
357#
358hierarchy:
359	cd ${.CURDIR}/etc &&		${MAKE} distrib-dirs
360
361#
362# mk - update the /usr/share/mk makefiles.
363#
364mk:
365	cd ${.CURDIR}/share/mk &&	${MAKE} install
366
367#
368# bootstrap - [re]build tools needed to run the actual build, this includes
369# tools needed by 'make depend', as some tools are needed to generate source
370# for the dependency information to be gathered from.
371#
372bootstrap:
373	cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
374		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
375	cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
376		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
377	cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
378		${MAKE} ${MK_FLAGS} -DNOLIB all install ${CLEANDIR} ${OBJDIR}
379
380#
381# include-tools - generally the same as 'bootstrap', except that it's for
382# things that are specifically needed to generate include files.
383#
384# XXX should be merged with bootstrap, it's not worth keeeping them seperate
385#
386include-tools:
387	cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} depend && \
388		${MAKE} ${MK_FLAGS} depend all install ${CLEANDIR} ${OBJDIR}
389
390#
391# includes - possibly generate and install the include files.
392#
393includes:
394.if defined(CLOBBER)
395	rm -rf ${DESTDIR}/usr/include/*
396	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
397		-p ${DESTDIR}/usr/include
398.endif
399	cd ${.CURDIR}/include/rpcsvc &&		${MAKE} all
400	cd ${.CURDIR}/include &&		${MAKE} install
401	cd ${.CURDIR}/gnu/include &&		${MAKE} install
402	cd ${.CURDIR}/gnu/lib/libreadline &&	${MAKE} beforeinstall
403	cd ${.CURDIR}/gnu/lib/libregex &&	${MAKE} beforeinstall
404	cd ${.CURDIR}/gnu/lib/libstdc++ &&      ${MAKE} beforeinstall
405	cd ${.CURDIR}/gnu/lib/libg++ &&         ${MAKE} beforeinstall
406	cd ${.CURDIR}/gnu/lib/libdialog &&      ${MAKE} beforeinstall
407.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
408	cd ${.CURDIR}/eBones/include &&		${MAKE} beforeinstall
409	cd ${.CURDIR}/eBones/lib/libkrb &&	${MAKE} beforeinstall
410	cd ${.CURDIR}/eBones/lib/libkadm &&	${MAKE} beforeinstall
411.endif
412	cd ${.CURDIR}/lib/csu/i386 &&		${MAKE} beforeinstall
413	cd ${.CURDIR}/lib/libc &&		${MAKE} beforeinstall
414	cd ${.CURDIR}/lib/libcurses &&		${MAKE} beforeinstall
415	cd ${.CURDIR}/lib/libedit &&		${MAKE} beforeinstall
416	cd ${.CURDIR}/lib/libftpio &&		${MAKE} beforeinstall
417	cd ${.CURDIR}/lib/libmd &&		${MAKE} beforeinstall
418	cd ${.CURDIR}/lib/libmytinfo &&         ${MAKE} beforeinstall
419	cd ${.CURDIR}/lib/libncurses &&		${MAKE} beforeinstall
420.if !defined(WANT_CSRG_LIBM)
421	cd ${.CURDIR}/lib/msun &&		${MAKE} beforeinstall
422.endif
423	cd ${.CURDIR}/lib/libpcap &&		${MAKE} beforeinstall
424	cd ${.CURDIR}/lib/librpcsvc &&		${MAKE} beforeinstall
425	cd ${.CURDIR}/lib/libskey &&		${MAKE} beforeinstall
426	cd ${.CURDIR}/lib/libtcl &&		${MAKE} beforeinstall
427	cd ${.CURDIR}/lib/libtermcap &&		${MAKE} beforeinstall
428	cd ${.CURDIR}/lib/libcom_err &&		${MAKE} beforeinstall
429	cd ${.CURDIR}/lib/libss &&		${MAKE} beforeinstall
430	cd ${.CURDIR}/lib/libscsi &&		${MAKE} beforeinstall
431	cd ${.CURDIR}/lib/libutil &&		${MAKE} beforeinstall
432
433#
434# lib-tools - build tools to compile and install the libraries.
435#
436lib-tools:
437	cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \
438		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
439	cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \
440		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
441	cd ${.CURDIR}/gnu/usr.bin/as && ${MAKE} depend && \
442		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
443	cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \
444		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
445	cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \
446		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
447	cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \
448		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
449	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
450		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
451	cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \
452		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \
453		rm -f /usr/sbin/compile_et
454	cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \
455		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
456	cd ${.CURDIR}/usr.bin/uudecode && ${MAKE} depend && \
457		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
458	cd ${.CURDIR}/gnu/usr.bin/bison && ${MAKE} depend && \
459		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
460	cd ${.CURDIR}/gnu/usr.bin/gperf && ${MAKE} depend && \
461		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
462	cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \
463		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
464
465#
466# libraries - build and install the libraries
467#
468libraries:
469.if exists(lib/csu/i386)
470	cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
471		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
472.endif
473.if exists(lib/libcompat)
474	cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
475		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
476.endif
477.if exists(lib/libncurses)
478	cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
479		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
480.endif
481.if exists(lib/libtermcap)
482	cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
483		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
484.endif
485.if exists(gnu)
486	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
487		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
488.endif
489.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
490	cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
491		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
492.endif
493.if exists(lib)
494	cd ${.CURDIR}/lib && ${MAKE} depend && \
495		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
496.endif
497.if exists(usr.bin/lex/lib)
498	cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
499		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
500.endif
501.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
502	cd ${.CURDIR}/eBones/lib && ${MAKE} depend && \
503		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
504.endif
505.if exists(usr.sbin/pcvt/keycap)
506	cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
507		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
508.endif
509
510#
511# build-tools - build and install any other tools needed to complete the
512# compile and install.
513#
514build-tools:
515.for d in				\
516		share/info		\
517		gnu/usr.bin/texinfo     \
518		usr.bin/symorder	\
519		usr.bin/sgmls		\
520		usr.bin/sgmlfmt		\
521		share/sgml		\
522		usr.sbin/zic		\
523		gnu/usr.bin/awk		\
524		gnu/usr.bin/groff
525	cd ${.CURDIR}/$d && ${MAKE} depend && \
526		${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR}
527.endfor
528
529.include <bsd.subdir.mk>
530