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