Makefile revision 1.96
1dbbd9e4bSmacallan#	$NetBSD: Makefile,v 1.96 1999/04/25 19:13:05 scottr Exp $
2dbbd9e4bSmacallan
3dbbd9e4bSmacallan# This is the top-level makefile for building NetBSD. For an outline of
4dbbd9e4bSmacallan# how to build a snapshot or release, as well as other release engineering
5dbbd9e4bSmacallan# information, see http://www.netbsd.org/developers/releng/index.html
6dbbd9e4bSmacallan#
7dbbd9e4bSmacallan# Not everything you can set or do is documented in this makefile. In
8dbbd9e4bSmacallan# particular, you should review the files in /usr/share/mk (especially
9dbbd9e4bSmacallan# bsd.README) for general information on building programs and writing
10dbbd9e4bSmacallan# Makefiles within this structure, and see the comments in src/etc/Makefile
11dbbd9e4bSmacallan# for further information on installation and release set options.
12dbbd9e4bSmacallan#
13dbbd9e4bSmacallan# Variables listed below can be set on the make command line (highest
14dbbd9e4bSmacallan# priority), in /etc/mk.conf (middle priority), or in the environment
15dbbd9e4bSmacallan# (lowest priority).
16dbbd9e4bSmacallan#
17dbbd9e4bSmacallan# Variables:
18dbbd9e4bSmacallan#   NBUILDJOBS is the number of jobs to start in parallel during a
19dbbd9e4bSmacallan#	'make build'. It defaults to 1.
20dbbd9e4bSmacallan#   MKMAN, if set to `no', will prevent building of manual pages.
21dbbd9e4bSmacallan#   MKSHARE, if set to `no', will prevent building and installing
22dbbd9e4bSmacallan#	anything in /usr/share.
23e96acad6Smrg#   UPDATE will avoid a `make cleandir' at the start of `make build',
24e96acad6Smrg#	as well as having the effects listed in /usr/share/mk/bsd.README.
25dbbd9e4bSmacallan#   DESTDIR is the target directory for installation of the compiled
26cfa76ccdSmrg#	software. It defaults to /. Note that programs are built against
27cfa76ccdSmrg#	libraries installed in DESTDIR.
28e96acad6Smrg#   EXPORTABLE_SYSTEM, when set, ensures that non-exportable crypto code
29dbbd9e4bSmacallan#	is not compiled or installed. EXPORTABLE_SYSTEM is ignored if
30e96acad6Smrg#	the `domestic' subtree does not exist.
31dbbd9e4bSmacallan#   FORCE_DOMESTIC, when set, forces a descent into the domestic tree
32dbbd9e4bSmacallan#	when handling the `all', `includes', and `install' targets. This
33e96acad6Smrg#	flag is incompatible with the `build' target. It's generally a
34cfa76ccdSmrg#	bad idea to use FORCE_DOMESTIC unless the ramifications are well
35dbbd9e4bSmacallan#	understood, and should never be enabled by default. FORCE_DOMESTIC
36dbbd9e4bSmacallan#	is ignored if the `domestic' subtree does not exist.
37e96acad6Smrg#
38e96acad6Smrg# Targets:
39e96acad6Smrg#   build: builds a full release of netbsd in DESTDIR.
40e96acad6Smrg#   release: does a `make build,' and then tars up the DESTDIR files
41e96acad6Smrg#	into RELEASEDIR, in release(7) format. (See etc/Makefile for
42e96acad6Smrg#	more information on this.)
43e96acad6Smrg#   snapshot: a synonym for release.
44dbbd9e4bSmacallan
45dbbd9e4bSmacallan.include <bsd.own.mk>			# for configuration variables.
46dbbd9e4bSmacallan
47dbbd9e4bSmacallan
48dbbd9e4bSmacallanHAVE_GCC28!=	${CXX} --version | egrep "^(2\.8|egcs)" ; echo
49dbbd9e4bSmacallan
50dbbd9e4bSmacallan.if defined(NBUILDJOBS)
51dbbd9e4bSmacallan_J= -j${NBUILDJOBS}
52dbbd9e4bSmacallan.endif
53dbbd9e4bSmacallan
54dbbd9e4bSmacallan# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
55e96acad6Smrg
56dbbd9e4bSmacallanSUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
57e96acad6Smrg
58dbbd9e4bSmacallan.if exists(games)
59dbbd9e4bSmacallanSUBDIR+= games
60dbbd9e4bSmacallan.endif
61dbbd9e4bSmacallan
62e96acad6SmrgSUBDIR+= gnu
63dbbd9e4bSmacallan# This is needed for libstdc++ and gen-params.
64dbbd9e4bSmacallanincludes-gnu: includes-include includes-sys
65dbbd9e4bSmacallan
66dbbd9e4bSmacallan# Descend into the domestic tree if it exists AND
67e96acad6Smrg#  1) the target is clean, cleandir, or obj, OR
68dbbd9e4bSmacallan#  2) the the target is install or includes AND
691c397cbaSmrg#     NOT compiling only "exportable" code AND
701c397cbaSmrg#     doing it as part of installing a distribution, OR
711c397cbaSmrg#  3) we Really Know what we're doing.  (Really!)
721c397cbaSmrg#
73dbbd9e4bSmacallan# NOTE:  due to the use of the make(foo) construct here, using the
74dbbd9e4bSmacallan# clean, cleandir, and obj targets on the command line in conjunction
75dbbd9e4bSmacallan# with any other target may produce unexpected results.
76e96acad6Smrg
77e96acad6Smrg.if exists(domestic) && \
78e96acad6Smrg    (make(clean) || make(cleandir) || make(obj) || \
79e96acad6Smrg    ((make(includes) || make(install)) && \
80e96acad6Smrg	!defined(EXPORTABLE_SYSTEM) && defined(_DISTRIB)) || \
81e96acad6Smrg    defined(FORCE_DOMESTIC))
82e96acad6SmrgSUBDIR+= domestic
83e96acad6Smrg.endif
84e96acad6Smrg
85e96acad6Smrg.if exists(regress)
86e96acad6Smrg.ifmake !(install)
87e96acad6SmrgSUBDIR+= regress
88e96acad6Smrg.endif
89e96acad6Smrg
90e96acad6Smrgregression-tests:
91e96acad6Smrg	@echo Running regression tests...
92e96acad6Smrg	@(cd ${.CURDIR}/regress && ${MAKE} regress)
93dbbd9e4bSmacallan.endif
94dbbd9e4bSmacallan
95dbbd9e4bSmacallanbeforeinstall:
96dbbd9e4bSmacallan.ifmake build
97dbbd9e4bSmacallan	@echo -n "Build started at: "
98dbbd9e4bSmacallan	@date
99dbbd9e4bSmacallan.endif
100dbbd9e4bSmacallan.ifndef DESTDIR
101e96acad6Smrg	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
102e96acad6Smrg.else
103e96acad6Smrg	(cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
104e96acad6Smrg.endif
105dbbd9e4bSmacallan
106e96acad6Smrgafterinstall:
107.if ${MKMAN} != "no" && !defined(_BUILD)
108	${MAKE} whatis.db
109.endif
110
111whatis.db:
112	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
113
114# wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
115# as the build will automatically remove/replace the non-pkg entries there.
116
117build: beforeinstall
118.if defined(FORCE_DOMESTIC)
119	@echo '*** CAPUTE!'
120	@echo '    The FORCE_DOMESTIC flag is not compatible with "make build".'
121	@echo '    Please correct the problem and try again.'
122	@false
123.endif
124.if ${MKSHARE} != "no"
125	(cd ${.CURDIR}/share/mk && ${MAKE} install)
126	(cd ${.CURDIR}/share/tmac && ${MAKE} && ${MAKE} install)
127.endif
128.if !defined(UPDATE)
129	${MAKE} cleandir
130.endif
131.if empty(HAVE_GCC28)
132.if defined(DESTDIR)
133	@echo "*** CAPUTE!"
134	@echo "    You attempted to compile the world without egcs.  You must"
135	@echo "    first install a native egcs compiler."
136	@false
137.else
138	(cd ${.CURDIR}/gnu/usr.bin/egcs && \
139	    ${MAKE} depend && ${MAKE} ${_J} MKMAN=no && \
140	    ${MAKE} MKMAN=no install && ${MAKE} cleandir)
141.endif
142.endif
143	${MAKE} includes
144	(cd ${.CURDIR}/lib/csu && \
145	    ${MAKE} depend && ${MAKE} ${_J} MKMAN=no && \
146	    ${MAKE} MKMAN=no install)
147	(cd ${.CURDIR}/lib && \
148	    ${MAKE} depend && ${MAKE} ${_J} MKMAN=no && \
149	    ${MAKE} MKMAN=no install)
150	(cd ${.CURDIR}/gnu/lib && \
151	    ${MAKE} depend && ${MAKE} ${_J} MKMAN=no MKINFO=no && \
152	    ${MAKE} MKMAN=no MKINFO=no install)
153	${MAKE} depend && ${MAKE} ${_J} && ${MAKE} _BUILD= install
154.if exists(domestic) && !defined(EXPORTABLE_SYSTEM)
155	(cd ${.CURDIR}/domestic && ${MAKE} ${_J} _SLAVE_BUILD= build)
156.endif
157	${MAKE} whatis.db
158	@echo -n "Build finished at: "
159	@date
160
161release snapshot: build
162	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
163
164.include <bsd.subdir.mk>
165