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