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