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