Makefile revision 1.192 1 1.192 lukem # $NetBSD: Makefile,v 1.192 2002/12/02 08:27:03 lukem 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.178 enami # 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.125 mrg # UPDATE, if defined, will avoid a `make cleandir' at the start of
27 1.178 enami # `make build', as well as having the effects listed in
28 1.178 enami # /usr/share/mk/bsd.README.
29 1.125 mrg # NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
30 1.178 enami # of the `make build'.
31 1.119 toddpw # NOINCLUDES will avoid the `make includes' usually done by `make build'.
32 1.95 cjs #
33 1.95 cjs # Targets:
34 1.137 tv # build:
35 1.137 tv # Builds a full release of NetBSD in DESTDIR. If BUILD_DONE is
36 1.110 jlam # set, this is an empty target.
37 1.137 tv # release:
38 1.137 tv # Does a `make build,' and then tars up the DESTDIR files
39 1.95 cjs # into RELEASEDIR, in release(7) format. (See etc/Makefile for
40 1.95 cjs # more information on this.)
41 1.137 tv # regression-tests:
42 1.137 tv # Runs the regression tests in "regress" on this host.
43 1.123 mrg #
44 1.137 tv # Targets invoked by `make build,' in order:
45 1.155 tv # cleandir: cleans the tree.
46 1.137 tv # obj: creates object directories.
47 1.152 tv # do-tools: builds host toolchain.
48 1.131 tv # do-distrib-dirs: creates the distribution directories.
49 1.137 tv # includes: installs include files.
50 1.168 tv # do-lib-csu: builds and installs prerequisites from lib/csu.
51 1.186 thorpej # do-lib-libc: builds and installs prerequisites from lib/libc.
52 1.143 tv # do-lib: builds and installs prerequisites from lib.
53 1.143 tv # do-gnu-lib: builds and installs prerequisites from gnu/lib.
54 1.189 itohy # do-ld.so: builds and installs prerequisites from libexec/ld.*_so.
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.166 simonb _SUBDIR= tools lib include gnu bin games libexec sbin usr.bin
83 1.183 lukem _SUBDIR+= usr.sbin share rescue sys etc distrib regress
84 1.105 assar
85 1.137 tv # Weed out directories that don't exist.
86 1.36 explorer
87 1.137 tv .for dir in ${_SUBDIR}
88 1.154 tv .if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
89 1.137 tv SUBDIR+= ${dir}
90 1.36 explorer .endif
91 1.137 tv .endfor
92 1.21 cgd
93 1.13 brezak .if exists(regress)
94 1.10 cgd regression-tests:
95 1.10 cgd @echo Running regression tests...
96 1.152 tv @(cd ${.CURDIR}/regress && ${MAKE} regress)
97 1.13 brezak .endif
98 1.20 cgd
99 1.179 thorpej .if defined(UNPRIVED)
100 1.179 thorpej NOPOSTINSTALL= # defined
101 1.179 thorpej .endif
102 1.179 thorpej
103 1.176 lukem afterinstall:
104 1.137 tv .if ${MKMAN} != "no"
105 1.152 tv (cd ${.CURDIR}/share/man && ${MAKE} makedb)
106 1.137 tv .endif
107 1.159 perry .if defined(UNPRIVED) && (${MKINFO} != "no")
108 1.164 jmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
109 1.176 lukem .endif
110 1.179 thorpej .if !defined(NOPOSTINSTALL)
111 1.180 drochner (cd ${.CURDIR} && ${MAKE} postinstall-check)
112 1.159 perry .endif
113 1.170 lukem
114 1.170 lukem postinstall-check:
115 1.169 lukem @echo " === Post installation checks ==="
116 1.175 lukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check
117 1.171 lukem @echo " ================================"
118 1.171 lukem
119 1.171 lukem postinstall-fix: .NOTMAIN
120 1.171 lukem @echo " === Post installation fixes ==="
121 1.175 lukem sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix
122 1.169 lukem @echo " ================================"
123 1.169 lukem
124 1.108 erh
125 1.137 tv # Targets (in order!) called by "make build".
126 1.123 mrg
127 1.156 tv BUILDTARGETS+= check-tools
128 1.155 tv .if !defined(UPDATE) && !defined(NOCLEANDIR)
129 1.155 tv BUILDTARGETS+= cleandir
130 1.155 tv .endif
131 1.149 tv .if ${MKOBJDIRS} != "no"
132 1.137 tv BUILDTARGETS+= obj
133 1.123 mrg .endif
134 1.138 tv .if ${USETOOLS} == "yes"
135 1.152 tv BUILDTARGETS+= do-tools
136 1.131 tv .endif
137 1.137 tv .if !defined(NODISTRIBDIRS)
138 1.137 tv BUILDTARGETS+= do-distrib-dirs
139 1.131 tv .endif
140 1.137 tv .if !defined(NOINCLUDES)
141 1.137 tv BUILDTARGETS+= includes
142 1.131 tv .endif
143 1.189 itohy BUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build
144 1.131 tv
145 1.137 tv # Enforce proper ordering of some rules.
146 1.123 mrg
147 1.137 tv .ORDER: ${BUILDTARGETS}
148 1.137 tv includes-lib: includes-include includes-sys
149 1.137 tv includes-gnu: includes-lib
150 1.123 mrg
151 1.137 tv # Build the system and install into DESTDIR.
152 1.123 mrg
153 1.191 lukem START_TIME!= date
154 1.191 lukem
155 1.137 tv build:
156 1.137 tv .if defined(BUILD_DONE)
157 1.137 tv @echo "Build already installed into ${DESTDIR}"
158 1.137 tv .else
159 1.191 lukem @echo "Build started at: ${START_TIME}"
160 1.145 tv .for tgt in ${BUILDTARGETS}
161 1.173 sommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt})
162 1.145 tv .endfor
163 1.191 lukem @echo "Build started at: ${START_TIME}"
164 1.172 bjh21 @printf "Build finished at: " && date
165 1.71 mycroft .endif
166 1.160 thorpej
167 1.160 thorpej # Build a full distribution, but not a release (i.e. no sets into
168 1.160 thorpej # ${RELEASEDIR}).
169 1.160 thorpej
170 1.179 thorpej distribution:
171 1.182 uwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
172 1.160 thorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
173 1.181 thorpej .if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/"
174 1.181 thorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist)
175 1.181 thorpej .endif
176 1.192 lukem @echo "make ${.TARGET} started at: ${START_TIME}"
177 1.185 lukem @printf "make ${.TARGET} finished at: " && date
178 1.123 mrg
179 1.181 thorpej # Build a release or snapshot (implies "make build"). Note that
180 1.181 thorpej # in this case, the set lists will be checked before the tar files
181 1.181 thorpej # are made.
182 1.123 mrg
183 1.179 thorpej release snapshot:
184 1.179 thorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
185 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
186 1.192 lukem @echo "make ${.TARGET} started at: ${START_TIME}"
187 1.185 lukem @printf "make ${.TARGET} finished at: " && date
188 1.123 mrg
189 1.137 tv # Special components of the "make build" process.
190 1.156 tv
191 1.156 tv check-tools:
192 1.187 thorpej .if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN)
193 1.187 thorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.'
194 1.187 thorpej @echo '*** May result in a failed build or corrupt binaries!'
195 1.187 thorpej .elif defined(EXTERNAL_TOOLCHAIN)
196 1.187 thorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.'
197 1.156 tv .endif
198 1.173 sommerfe .if defined(NBUILDJOBS)
199 1.173 sommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
200 1.173 sommerfe .endif
201 1.123 mrg
202 1.137 tv do-distrib-dirs:
203 1.147 jmc .if !defined(DESTDIR) || ${DESTDIR} == ""
204 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
205 1.147 jmc .else
206 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
207 1.147 jmc .endif
208 1.190 lukem
209 1.190 lukem .for targ in cleandir obj includes
210 1.190 lukem do-${targ}: ${targ}
211 1.190 lukem @true
212 1.190 lukem .endfor
213 1.123 mrg
214 1.186 thorpej .for dir in tools lib/csu lib/libc lib gnu/lib
215 1.143 tv do-${dir:S/\//-/}:
216 1.137 tv .for targ in dependall install
217 1.173 sommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ})
218 1.137 tv .endfor
219 1.184 lukem .endfor
220 1.184 lukem
221 1.189 itohy do-ld.so:
222 1.184 lukem .for targ in dependall install
223 1.189 itohy .if (${OBJECT_FMT} == "a.out")
224 1.189 itohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ})
225 1.189 itohy .endif
226 1.189 itohy .if (${OBJECT_FMT} == "ELF")
227 1.184 lukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ})
228 1.189 itohy .endif
229 1.137 tv .endfor
230 1.143 tv
231 1.143 tv do-build:
232 1.154 tv .for targ in dependall install
233 1.173 sommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no)
234 1.154 tv .endfor
235 1.87 cjs
236 1.137 tv # Speedup stubs for some subtrees that don't need to run these rules.
237 1.137 tv # (Tells <bsd.subdir.mk> not to recurse for them.)
238 1.129 tv
239 1.152 tv .for dir in bin etc distrib games libexec regress sbin usr.sbin tools
240 1.152 tv includes-${dir}:
241 1.152 tv @true
242 1.152 tv .endfor
243 1.152 tv .for dir in etc distrib regress
244 1.152 tv install-${dir}:
245 1.152 tv @true
246 1.152 tv .endfor
247 1.152 tv
248 1.152 tv # XXX this needs to change when distrib Makefiles are recursion compliant
249 1.152 tv dependall-distrib depend-distrib all-distrib:
250 1.136 nathanw @true
251 1.130 tv
252 1.151 tv .include <bsd.obj.mk>
253 1.146 tv .include <bsd.subdir.mk>
254 1.144 tv
255 1.150 tv build-docs: ${.CURDIR}/BUILDING
256 1.188 lukem ${.CURDIR}/BUILDING: doc/BUILDING.mdoc
257 1.150 tv groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
258