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