Makefile revision 1.82 1 # $NetBSD: Makefile,v 1.82 2011/02/16 06:02:01 uebayasi Exp $
2
3 # Experimental RCS METALOG versioning
4 # (Needs host's rcs(1) commands)
5 #RCSMETALOG=1
6
7 # The `all' target must appear before bsd.own.mk is pulled in.
8 all:
9 @echo "Please understand what you are doing, first."
10 @false
11
12 .include <bsd.own.mk>
13 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
14
15 .if ${USE_PIGZGZIP} != "no"
16 COMPRESS_PROGRAM=${TOOL_PIGZ:Q}
17 .else
18 COMPRESS_PROGRAM=gzip
19 .endif
20
21 SETSENV= DESTDIR=${DESTDIR:Q} \
22 MACHINE=${MACHINE:Q} \
23 MACHINE_ARCH=${MACHINE_ARCH:Q} \
24 AWK=${TOOL_AWK:Q} \
25 CKSUM=${TOOL_CKSUM:Q} \
26 DB=${TOOL_DB:Q} \
27 HOST_SH=${HOST_SH:Q} \
28 MAKE=${MAKE:Q} \
29 MKTEMP=${TOOL_MKTEMP:Q} \
30 MTREE=${TOOL_MTREE:Q} \
31 PAX=${TOOL_PAX:Q} \
32 COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \
33 PKG_CREATE=${TOOL_PKG_CREATE:Q} \
34 SED=${TOOL_SED:Q} \
35 TSORT=${TSORT:Q}
36 SETSCMD= cd ${.CURDIR} && \
37 ${SETSENV} \
38 ${HOST_SH}
39
40 MAKETARS_FLAGS=
41 .if ${MKX11} != "no"
42 MAKESRCTARS_X11_FLAGS= -x ${X11SRCDIR}
43 .endif
44 .if ${MKEXTSRC} != "no"
45 MAKESRCTARS_EXTSRC_FLAGS= -y ${EXTSRCSRCDIR}
46 .endif
47 .if ${MKX11} != "no"
48 MAKEFLIST_X11_FLAGS= ,x
49 .endif
50 .if ${MKEXTSRC} != "no"
51 MAKEFLIST_EXTSRC_FLAGS= ,ext
52 .endif
53 MAKEFLIST_FLAGS= -L base${MAKEFLIST_X11_FLAGS}${MAKEFLIST_EXTSRC_FLAGS}
54 MAKESRCTARS_FLAGS= -N ${NETBSDSRCDIR}/etc
55
56 .if ${MAKEVERBOSE} < 2
57 MAKETARS_FLAGS+= -q
58 MAKESRCTARS_FLAGS+= -q
59 .endif
60
61 .if !defined(MAKETARSETS)
62 MAKETARSETS!= ${SETSCMD} ./makeflist -l ${MAKEFLIST_FLAGS}
63 .endif
64
65 print_have_gcc: .PHONY
66 @echo ${HAVE_GCC}
67
68 print_machine: .PHONY
69 @echo ${MACHINE}
70
71 print_machine_arch: .PHONY
72 @echo ${MACHINE_ARCH}
73
74 print_machine_cpu: .PHONY
75 @echo ${MACHINE_CPU}
76
77 print_object_fmt: .PHONY
78 @echo ${OBJECT_FMT}
79
80 print_toolchain_missing: .PHONY
81 @echo "${TOOLCHAIN_MISSING}"
82
83 print_mkvars \
84 print_set_lists_base print_set_lists_x print_set_lists_ext \
85 list_set_lists_base list_set_lists_x list_set_lists_ext \
86 list_set_files_base list_set_files_x list_set_files_ext \
87 : .PHONY
88 @${SETSENV}; rundir="${.CURDIR}"; . ./sets.subr; ${.TARGET}
89
90 #
91 # METALOG MANIPULATION TARGETS
92 #
93 # METALOG is the name of a metadata log file, and is set in <bsd.own.mk>
94 # if MKUNPRIVED is not "no".
95 #
96 # METALOG.unpriv is a command line option passed to various scripts;
97 # it is either blank or "-M ${METALOG}.sanitised", depending on the
98 # MKUNPRIVED flag.
99 #
100 # The sanitise_METALOG target creates METALOG.sanitised from METALOG,
101 # without modifying METALOG itself. METALOG.sanitised is sorted, and
102 # has duplicates merged. This is used near the end of a build, after
103 # build products have been installed in DESTDIR and corresponding lines
104 # have been added to METALOG, but before METALOG.sanitised is used in
105 # the creation of sets in RELEASEDIR.
106 #
107 # The clean_METALOG either deletes METALOG or replaces METALOG with
108 # a sanitised version of itself, depending on the MKUPDATE flag, and
109 # deletes old METALOG.* files. This is intended to be used at the start
110 # of a build, to ensure that repeated MKUPDATE builds do not cause
111 # unbounded growth of METALOG.
112 #
113
114 .if ${MKUNPRIVED} == "no"
115 METALOG.unpriv=
116 sanitise_METALOG: .PHONY
117 @true
118 clean_METALOG: .PHONY
119 @true
120 .else # MKUNPRIVED
121 METALOG.unpriv= -M ${METALOG}.sanitised
122 sanitise_METALOG: .PHONY ${METALOG}.sanitised
123 ${METALOG}.sanitised: ${METALOG}
124 ${TOOL_MTREE} -CSM -k all -N ${NETBSDSRCDIR}/etc <${METALOG} \
125 >${METALOG}.new
126 mv ${METALOG}.new ${METALOG}.sanitised
127 .if defined(RCSMETALOG)
128 . ./metalog.subr; \
129 xrcs_descr="build distribution METALOG"; \
130 xrcs_msg="$$(date)"; \
131 xrcs_cur=${METALOG}.sanitised; \
132 xrcs update
133 .endif
134 .if ${MKUPDATE} == "no" || !exists(${METALOG})
135 clean_METALOG: .PHONY
136 rm -f ${METALOG} ${METALOG}.*
137 .else # MKUPDATE
138 clean_METALOG: .PHONY ${METALOG}.sanitised
139 mv ${METALOG}.sanitised ${METALOG}
140 .if defined(RCSMETALOG)
141 [ -f ${METALOG}.sanitised,v ] && mv ${METALOG}.sanitised,v ${METALOG},v
142 .endif
143 rm -f ${METALOG}.*
144 .if defined(RCSMETALOG)
145 [ -f ${METALOG},v ] && mv ${METALOG},v ${METALOG}.sanitised,v
146 .endif
147 .endif # MKUPDATE
148 .endif # MKUNPRIVED
149
150 #
151 # FILE LIST TARGETS
152 #
153
154 # This target has debugging value only, really.
155 makeflist: .PHONY .PRECIOUS check_DESTDIR
156 ${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
157
158 checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
159 ${SETSCMD} ${.CURDIR}/checkflist \
160 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv}
161
162 checkflist-x11: .PHONY check_DESTDIR
163 ${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS}
164
165 checkflist-extsrc: .PHONY check_DESTDIR
166 ${SETSCMD} ./checkflist -y ${CHECKFLIST_FLAGS}
167
168 .if defined(DESTDIR) && ${DESTDIR} != ""
169 checkflist_if_DESTDIR: checkflist
170 .else
171 checkflist_if_DESTDIR:
172 .endif
173
174 #
175 # SET BUILDING TARGETS
176 #
177
178 TARDIR= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
179 SOURCETARDIR= ${RELEASEDIR}/source/sets
180
181 # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be
182 # made in series, even if make's "-j" flag requests multiple parallel
183 # jobs. This is useful on systems that exhibit poor performance when
184 # running multiple parallel disk-intensive operations. The default is
185 # MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make
186 # command.
187 #
188 MAKETARS_SERIAL?= NO
189 .if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss])
190 _MAKETARS_WAIT= # empty
191 .else
192 _MAKETARS_WAIT= .WAIT
193 .endif
194
195 maketars: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \
196 sanitise_METALOG checkflist_if_DESTDIR .WAIT \
197 maketarsetup .WAIT \
198 ${MAKETARSETS:@.TARS.@${_MAKETARS_WAIT} do-${.TARS.}@}
199 @true
200
201 maketarsetup: .EXEC
202 .if defined(DESTDIR) && ${DESTDIR} != ""
203 ${_MKMSG} "execute checkflist"
204 ${MAKE} checkflist
205 .endif
206 mkdir -p ${TARDIR}
207 for i in MD5 SHA512; do \
208 rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \
209 done
210
211 makesetfiles: .PHONY sanitise_METALOG
212 ${_MKMSG_CREATE} "set lists"
213 ${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
214 ${METALOG.unpriv} \
215 -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR}
216
217 .for tar in ${MAKETARSETS}
218 do-${tar}: .PHONY sanitise_METALOG
219 ${_MKMSG_CREATE} "${tar}.tgz"
220 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
221 ${METALOG.unpriv} \
222 -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \
223 || { rm -f ${TARDIR}/${tar}.tgz; false; }
224 .endfor
225
226
227 makesrctars: .PRECIOUS .PHONY check_RELEASEDIR
228 ${_MKMSG_CREATE} "source tar files"
229 mkdir -p ${SOURCETARDIR}
230 ${SETSCMD} ./makesrctars ${MAKESRCTARS_FLAGS} \
231 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \
232 ${NETBSDSRCDIR} ${SOURCETARDIR}
233
234
235 makesums: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \
236 ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@}
237 for i in MD5 SHA512; do \
238 mv ${TARDIR}/$$i.tmp ${TARDIR}/$$i; \
239 done
240
241 .for tar in ${MAKETARSETS}
242 do-sum-${tar}: .PHONY do-${tar}
243 ${_MKMSG_CREATE} "${tar} checksums"
244 ${MAKESUMS} -t ${TARDIR} ${tar}.tgz
245 for i in MD5 SHA512; do \
246 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp; \
247 done
248 .endfor
249 .ORDER: ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@}
250
251
252 installsets: .PHONY check_DESTDIR sanitise_METALOG
253 .if !defined(INSTALLDIR)
254 @echo "setenv INSTALLDIR before doing that!"
255 @false
256 .endif
257 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \
258 ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \
259 ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS}
260
261 # Should we ignore errors like extra or missing files in the flists?
262 SLOPPY_FLIST?= NO
263 .if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss])
264 CHECKFLIST_FLAGS+= -e -m
265 REGPKG.sloppy= -m
266 .endif
267
268 .if ${MAKEVERBOSE} == 0
269 REGPKG.verbose?= -q
270 .elif ${MAKEVERBOSE} == 1
271 REGPKG.verbose?=
272 .else # MAKEVERBOSE >= 2
273 REGPKG.verbose?= -v
274 .endif
275 REGPKG.force?= # -f, or empty
276 REGPKG.cache?= -c # -c, or empty
277 REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/}
278 SYSPKGSETS?= all
279 makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \
280 sanitise_METALOG checkflist_if_DESTDIR
281 mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
282 ${SETSCMD} ${.CURDIR}/regpkgset \
283 ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \
284 ${REGPKG.cache} ${REGPKG.update} \
285 -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \
286 -N ${NETBSDSRCDIR}/etc \
287 -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS}
288
289 makesyspkgsums: .PHONY check_RELEASEDIR
290 ${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
291
292 # Update the "deps" file.
293 # XXX: Why is "deps" checked in to the source tree, instead of
294 # just being created as necessary?
295 makedeps: .PHONY
296 ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps
297
298 #
299 # MAIN ENTRY POINTS
300 #
301
302 syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums
303 @true
304
305 sets: .PHONY maketars .WAIT makesums
306 @true
307
308 sourcesets: .PHONY makesrctars
309 @true
310
311 .include <bsd.sys.mk>
312