Makefile revision 1.163 1 1.163 tv # $NetBSD: Makefile,v 1.163 2002/02/28 02:22:59 tv Exp $
2 1.95 cjs
3 1.95 cjs # This is the top-level makefile for building NetBSD. For an outline of
4 1.95 cjs # how to build a snapshot or release, as well as other release engineering
5 1.95 cjs # information, see http://www.netbsd.org/developers/releng/index.html
6 1.95 cjs #
7 1.95 cjs # Not everything you can set or do is documented in this makefile. In
8 1.95 cjs # particular, you should review the files in /usr/share/mk (especially
9 1.95 cjs # bsd.README) for general information on building programs and writing
10 1.95 cjs # Makefiles within this structure, and see the comments in src/etc/Makefile
11 1.95 cjs # for further information on installation and release set options.
12 1.95 cjs #
13 1.95 cjs # Variables listed below can be set on the make command line (highest
14 1.95 cjs # priority), in /etc/mk.conf (middle priority), or in the environment
15 1.95 cjs # (lowest priority).
16 1.95 cjs #
17 1.95 cjs # Variables:
18 1.101 sommerfe # DESTDIR is the target directory for installation of the compiled
19 1.101 sommerfe # software. It defaults to /. Note that programs are built against
20 1.101 sommerfe # libraries installed in DESTDIR.
21 1.95 cjs # MKMAN, if set to `no', will prevent building of manual pages.
22 1.101 sommerfe # MKOBJDIRS, if not set to `no', will build object directories at
23 1.101 sommerfe # an appropriate point in a build.
24 1.95 cjs # MKSHARE, if set to `no', will prevent building and installing
25 1.95 cjs # anything in /usr/share.
26 1.101 sommerfe # NBUILDJOBS is the number of jobs to start in parallel during a
27 1.127 tv # `make build'. It defaults to 1.
28 1.125 mrg # UPDATE, if defined, will avoid a `make cleandir' at the start of
29 1.125 mrg # `make build', as well as having the effects listed in
30 1.125 mrg # /usr/share/mk/bsd.README.
31 1.125 mrg # NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
32 1.125 mrg # of the `make build'.
33 1.119 toddpw # NOINCLUDES will avoid the `make includes' usually done by `make build'.
34 1.95 cjs #
35 1.95 cjs # Targets:
36 1.137 tv # build:
37 1.137 tv # Builds a full release of NetBSD in DESTDIR. If BUILD_DONE is
38 1.110 jlam # set, this is an empty target.
39 1.137 tv # release:
40 1.137 tv # Does a `make build,' and then tars up the DESTDIR files
41 1.95 cjs # into RELEASEDIR, in release(7) format. (See etc/Makefile for
42 1.95 cjs # more information on this.)
43 1.137 tv # regression-tests:
44 1.137 tv # Runs the regression tests in "regress" on this host.
45 1.123 mrg #
46 1.137 tv # Targets invoked by `make build,' in order:
47 1.155 tv # cleandir: cleans the tree.
48 1.137 tv # obj: creates object directories.
49 1.152 tv # do-tools: builds host toolchain.
50 1.131 tv # do-distrib-dirs: creates the distribution directories.
51 1.137 tv # includes: installs include files.
52 1.143 tv # do-lib-csu: builds and installs prerequisites from lib/csu.
53 1.143 tv # do-lib: builds and installs prerequisites from lib.
54 1.143 tv # do-gnu-lib: builds and installs prerequisites from gnu/lib.
55 1.137 tv # do-build: builds and installs the entire system.
56 1.32 cgd
57 1.146 tv .if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
58 1.146 tv .MAKEFLAGS: -m ${.CURDIR}/share/mk
59 1.146 tv .endif
60 1.163 tv
61 1.163 tv # If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
62 1.163 tv # not be the top level objdir, because "make obj" can happen in the *middle*
63 1.163 tv # of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set
64 1.163 tv # _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
65 1.163 tv _SRC_TOP_OBJ_=
66 1.148 jmc
67 1.146 tv .include <bsd.own.mk>
68 1.4 cgd
69 1.137 tv # Sanity check: make sure that "make build" is not invoked simultaneously
70 1.137 tv # with a standard recursive target.
71 1.137 tv
72 1.137 tv .if make(build) || make(release) || make(snapshot)
73 1.137 tv .for targ in ${TARGETS:Nobj:Ncleandir}
74 1.137 tv .if make(${targ}) && !target(.BEGIN)
75 1.137 tv .BEGIN:
76 1.137 tv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
77 1.137 tv @false
78 1.137 tv .endif
79 1.137 tv .endfor
80 1.137 tv .endif
81 1.58 tv
82 1.76 bouyer .if defined(NBUILDJOBS)
83 1.162 tv .if !target(.BEGIN)
84 1.162 tv .BEGIN:
85 1.162 tv @echo 'NBUILDJOBS is currently broken; see PR toolchain/14837.'
86 1.162 tv @false
87 1.162 tv .endif
88 1.162 tv #_J= -j${NBUILDJOBS}
89 1.76 bouyer .endif
90 1.76 bouyer
91 1.158 tv _SUBDIR= tools lib include gnu bin games libexec sbin usr.bin \
92 1.158 tv usr.sbin share sys etc distrib regress
93 1.105 assar
94 1.137 tv # Weed out directories that don't exist.
95 1.36 explorer
96 1.137 tv .for dir in ${_SUBDIR}
97 1.154 tv .if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
98 1.137 tv SUBDIR+= ${dir}
99 1.36 explorer .endif
100 1.137 tv .endfor
101 1.21 cgd
102 1.13 brezak .if exists(regress)
103 1.10 cgd regression-tests:
104 1.10 cgd @echo Running regression tests...
105 1.152 tv @(cd ${.CURDIR}/regress && ${MAKE} regress)
106 1.13 brezak .endif
107 1.20 cgd
108 1.159 perry whatis.db:
109 1.137 tv .if ${MKMAN} != "no"
110 1.152 tv (cd ${.CURDIR}/share/man && ${MAKE} makedb)
111 1.137 tv .endif
112 1.159 perry
113 1.159 perry # XXX I wish there was a more rational place to do this, but I can't
114 1.159 perry # think of one. There is no one place the info/dir file gets generated.
115 1.159 perry infodir-meta:
116 1.159 perry .if defined(UNPRIVED) && (${MKINFO} != "no")
117 1.159 perry echo "${DESTDIR}/usr/share/info/dir type=file mode=0644 uname=root gname=wheel" | \
118 1.159 perry sed -e 's|^/|./|g' -e 's|//|/|g' >>${METALOG}
119 1.159 perry .endif
120 1.159 perry
121 1.159 perry afterinstall: whatis.db infodir-meta
122 1.108 erh
123 1.137 tv # Targets (in order!) called by "make build".
124 1.123 mrg
125 1.156 tv BUILDTARGETS+= check-tools
126 1.155 tv .if !defined(UPDATE) && !defined(NOCLEANDIR)
127 1.155 tv BUILDTARGETS+= cleandir
128 1.155 tv .endif
129 1.149 tv .if ${MKOBJDIRS} != "no"
130 1.137 tv BUILDTARGETS+= obj
131 1.123 mrg .endif
132 1.138 tv .if ${USETOOLS} == "yes"
133 1.152 tv BUILDTARGETS+= do-tools
134 1.131 tv .endif
135 1.137 tv .if !defined(NODISTRIBDIRS)
136 1.137 tv BUILDTARGETS+= do-distrib-dirs
137 1.131 tv .endif
138 1.137 tv .if !defined(NOINCLUDES)
139 1.137 tv BUILDTARGETS+= includes
140 1.131 tv .endif
141 1.143 tv BUILDTARGETS+= do-lib-csu do-lib do-gnu-lib do-build
142 1.131 tv
143 1.137 tv # Enforce proper ordering of some rules.
144 1.123 mrg
145 1.137 tv .ORDER: ${BUILDTARGETS}
146 1.137 tv includes-lib: includes-include includes-sys
147 1.137 tv includes-gnu: includes-lib
148 1.123 mrg
149 1.137 tv # Build the system and install into DESTDIR.
150 1.123 mrg
151 1.137 tv build:
152 1.137 tv .if defined(BUILD_DONE)
153 1.137 tv @echo "Build already installed into ${DESTDIR}"
154 1.137 tv .else
155 1.137 tv @echo -n "Build started at: " && date
156 1.145 tv .for tgt in ${BUILDTARGETS}
157 1.156 tv @(cd ${.CURDIR} && ${MAKE} ${_J} ${tgt})
158 1.145 tv .endfor
159 1.137 tv @echo -n "Build finished at: " && date
160 1.71 mycroft .endif
161 1.160 thorpej
162 1.160 thorpej # Build a full distribution, but not a release (i.e. no sets into
163 1.160 thorpej # ${RELEASEDIR}).
164 1.160 thorpej
165 1.160 thorpej distribution: build
166 1.160 thorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
167 1.123 mrg
168 1.137 tv # Build a release or snapshot (implies "make build").
169 1.123 mrg
170 1.137 tv release snapshot: build
171 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
172 1.123 mrg
173 1.137 tv # Special components of the "make build" process.
174 1.156 tv
175 1.156 tv check-tools:
176 1.156 tv .if defined(USE_NEW_TOOLCHAIN) && (${USE_NEW_TOOLCHAIN} != "nowarn")
177 1.156 tv @echo '*** WARNING: Building on MACHINE=${MACHINE} with USE_NEW_TOOLCHAIN.'
178 1.156 tv @echo '*** This platform is not yet verified to work with the new toolchain,'
179 1.156 tv @echo '*** and may result in a failed build or corrupt binaries!'
180 1.156 tv .endif
181 1.123 mrg
182 1.137 tv do-distrib-dirs:
183 1.147 jmc .if !defined(DESTDIR) || ${DESTDIR} == ""
184 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
185 1.147 jmc .else
186 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
187 1.147 jmc .endif
188 1.123 mrg
189 1.152 tv .for dir in tools lib/csu lib gnu/lib
190 1.143 tv do-${dir:S/\//-/}:
191 1.137 tv .for targ in dependall install
192 1.154 tv (cd ${.CURDIR}/${dir} && ${MAKE} ${_J} ${targ})
193 1.137 tv .endfor
194 1.137 tv .endfor
195 1.143 tv
196 1.143 tv do-build:
197 1.154 tv .for targ in dependall install
198 1.154 tv (cd ${.CURDIR} && ${MAKE} ${_J} ${targ} BUILD_tools=no BUILD_lib=no)
199 1.154 tv .endfor
200 1.87 cjs
201 1.137 tv # Speedup stubs for some subtrees that don't need to run these rules.
202 1.137 tv # (Tells <bsd.subdir.mk> not to recurse for them.)
203 1.129 tv
204 1.152 tv .for dir in bin etc distrib games libexec regress sbin usr.sbin tools
205 1.152 tv includes-${dir}:
206 1.152 tv @true
207 1.152 tv .endfor
208 1.152 tv .for dir in etc distrib regress
209 1.152 tv install-${dir}:
210 1.152 tv @true
211 1.152 tv .endfor
212 1.152 tv
213 1.152 tv # XXX this needs to change when distrib Makefiles are recursion compliant
214 1.152 tv dependall-distrib depend-distrib all-distrib:
215 1.136 nathanw @true
216 1.161 lukem
217 1.161 lukem clean:
218 1.161 lukem rm -f METALOG
219 1.130 tv
220 1.151 tv .include <bsd.obj.mk>
221 1.146 tv .include <bsd.subdir.mk>
222 1.144 tv
223 1.150 tv build-docs: ${.CURDIR}/BUILDING
224 1.150 tv ${.CURDIR}/BUILDING: BUILDING.mdoc
225 1.150 tv groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
226