]> git.saurik.com Git - bison.git/blob - Makefile.maint
* src/scan-gram.l: When it starts with `%', complain about the
[bison.git] / Makefile.maint
1 # -*-Makefile-*-
2 # This Makefile fragment is shared between fileutils, sh-utils, textutils,
3 # CPPI, Bison, and Autoconf.
4
5 ## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
6 ##
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2, or (at your option)
10 ## any later version.
11 ##
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, write to the Free Software
19 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 ## 02111-1307, USA.
21
22 # Do not save the original name or timestamp in the .tar.gz file.
23 GZIP_ENV = '--no-name --best'
24
25 CVS = cvs
26
27 prev_version_file ?= .prev-version
28
29 THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
30 PREV_VERSION := $(shell cat $(prev_version_file))
31 PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
32
33 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
34 tag-this-version = $(subst .,_,$(VERSION))
35 tag-prev-version = $(subst .,_,$(PREV_VERSION))
36 this-cvs-tag = $(tag-package)-$(tag-this-version)
37 prev-cvs-tag = $(tag-package)-$(tag-prev-version)
38 my_distdir = $(PACKAGE)-$(VERSION)
39
40 # Old releases are stored here.
41 # Used for diffs and xdeltas.
42 release_archive_dir ?= ../release
43
44
45
46 ## --------------- ##
47 ## Sanity checks. ##
48 ## --------------- ##
49
50 # Checks that don't require cvs.
51 # Run `changelog-check' last, as previous test may reveal problems requiring
52 # new ChangeLog entries.
53 local-check = \
54 po-check copyright-check writable-files m4-check author_mark_check \
55 changelog-check strftime-check header-check
56 .PHONY: $(local-check)
57
58 # Make sure C source files in src/ don't include xalloc.h directly,
59 # since they all already include it via sys2.h.
60 # It's not a big deal -- just aesthetics.
61 header-check:
62 if test -f $(srcdir)/src/sys2.h; then \
63 if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
64 exit 1; \
65 fi; \
66 fi
67
68 # Ensure that date's --help output stays in sync with the info
69 # documentation for GNU strftime. The only exception is %N,
70 # which date accepts but GNU strftime does not.
71 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
72 strftime-check:
73 if test -f $(srcdir)/src/date.c; then \
74 grep '^ %. ' $(srcdir)/src/date.c | sort \
75 | $(extract_char) > $@-src; \
76 { echo N; \
77 info libc date calendar format | grep '^ `%.'\' \
78 | $(extract_char); } | sort > $@-info; \
79 diff -u $@-src $@-info || exit 1; \
80 rm -f $@-src $@-info; \
81 fi
82
83 changelog-check:
84 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
85 :; \
86 else \
87 echo "$(VERSION) not in ChangeLog" 1>&2; \
88 exit 1; \
89 fi
90
91 m4-check:
92 @grep 'AC_DEFUN([^[]' m4/*.m4 \
93 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
94 exit 1; } || :
95
96 # Verify that all source files using _() are listed in po/POTFILES.in.
97 po-check:
98 if test -f po/POTFILES.in; then \
99 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
100 grep -E -l '\b_\(' lib/*.[ch] src/*.[ch] | sort > $@-2; \
101 diff -u $@-1 $@-2 || exit 1; \
102 rm -f $@-1 $@-2; \
103 fi
104
105 # In a definition of #define AUTHORS "... and ..." where the RHS contains
106 # the English word `and', the string must be marked with `N_ (...)' so that
107 # gettext recognizes it as a string requiring translation.
108 author_mark_check:
109 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
110 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
111 exit 1; } || :
112
113 # Check that `make alpha' will not fail at the end of the process.
114 writable-files:
115 if test -d $(release_archive_dir); then :; else \
116 mkdir $(release_archive_dir); \
117 fi
118 for file in $(distdir).tar.gz $(xd-delta) \
119 $(release_archive_dir)/$(distdir).tar.gz \
120 $(release_archive_dir)/$(xd-delta); do \
121 test -e $$file || continue; \
122 test -w $$file \
123 || { echo ERROR: $$file is not writable; fail=1; }; \
124 done; \
125 test "$$fail" && exit 1 || :
126
127 v_etc_file = lib/version-etc.c
128 # Make sure that the copyright date in $(v_etc_file) is up to date.
129 copyright-check:
130 @if test -f $(v_etc_file); then \
131 grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
132 >/dev/null \
133 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
134 exit 1; }; \
135 fi
136
137
138 # Sanity checks with the CVS repository.
139 cvs-tag-check:
140 echo $(this-cvs-tag); \
141 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
142 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
143 exit 1; \
144 else :; fi
145
146 cvs-diff-check:
147 if $(CVS) diff >cvs-diffs; then \
148 rm cvs-diffs; \
149 else \
150 echo "Some files are locally modified:" 1>&2; \
151 cat cvs-diffs; \
152 exit 1; \
153 fi
154
155 cvs-check: cvs-diff-check cvs-tag-check
156
157 maintainer-distcheck: changelog-check
158 $(MAKE) distcheck
159 $(MAKE) my-distcheck
160
161
162 # Tag before making distribution. Also, don't make a distribution if
163 # checks fail. Also, make sure the NEWS file is up-to-date.
164 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
165 cvs-dist: $(local-check) cvs-check maintainer-distcheck
166 $(CVS) update po
167 $(CVS) tag -c $(this-cvs-tag)
168 $(MAKE) dist
169
170 # Use this to make sure we don't run these programs when building
171 # from a virgin tgz file, below.
172 null_AM_MAKEFLAGS = \
173 ACLOCAL=false \
174 AUTOCONF=false \
175 AUTOMAKE=false \
176 AUTOHEADER=false \
177 MAKEINFO=false
178
179 # Detect format-string/arg-list mismatches that would normally be obscured
180 # by the use of _(). The --disable-nls effectively defines away that macro,
181 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
182 # treated as a failure.
183 t=./=test
184 my-distcheck: $(local-check)
185 -rm -rf $(t)
186 mkdir $(t)
187 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
188 cd $(t)/$(distdir) \
189 && ./configure --disable-nls \
190 && $(MAKE) CFLAGS='-Wformat -Werror' \
191 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
192 && $(MAKE) dvi \
193 && $(MAKE) check \
194 && $(MAKE) distclean
195 cd $(t) && mv $(distdir) $(distdir).old \
196 && $(AMTAR) -zxf ../$(distdir).tar.gz
197 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
198 -rm -rf $(t)
199 @echo "========================"; \
200 echo "$(distdir).tar.gz is ready for distribution"; \
201 echo "========================"
202
203 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
204 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
205 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
206 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
207 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
208 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
209 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
210 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
211 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
212
213 rel-check:
214 tarz=/tmp/rel-check-tarz-$$$$; \
215 md5_tmp=/tmp/rel-check-md5-$$$$; \
216 set -e; \
217 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
218 wget -q --output-document=$$tarz $(url); \
219 echo "$(md5) -" > $$md5_tmp; \
220 md5sum -c $$md5_tmp < $$tarz
221
222 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
223 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
224
225 news-r1 = /^[^ ].*$(THIS_VERSION_REGEXP)[]:]/
226 news-r2 = /^[^ ].*$(PREV_VERSION_REGEXP)[]:]/
227
228 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
229 announcement: NEWS ChangeLog $(rel-files)
230 @( \
231 echo Subject: $(my_distdir) released; \
232 echo; \
233 echo FIXME: put comments here; \
234 echo; \
235 for url in $(url_dir_list); do \
236 echo " $$url/$(my_distdir).tar.gz ($(tgz-size))"; \
237 echo " $$url/$(my_distdir).tar.bz2 ($(bz2-size))"; \
238 done; \
239 echo; \
240 echo And here are xdelta-style diffs; \
241 echo; \
242 for url in $(url_dir_list); do \
243 echo " $$url/$(xd-delta) ($(xd-size))"; \
244 done; \
245 echo; \
246 echo "Here are the MD5 and SHA1 signatures:"; \
247 echo; \
248 echo "$(tgz-md5) $(my_distdir).tar.gz"; \
249 echo "$(bz2-md5) $(my_distdir).tar.bz2"; \
250 echo "$(xdelta-md5) $(xd-delta)"; \
251 echo "$(tgz-sha1) $(my_distdir).tar.gz"; \
252 echo "$(bz2-sha1) $(my_distdir).tar.bz2"; \
253 echo "$(xdelta-sha1) $(xd-delta)"; \
254 echo; \
255 echo NEWS:; \
256 sed -n "$(news-r1),$(news-r2)p" NEWS \
257 | grep -v '^\['; \
258 echo; \
259 echo ChangeLog entries:; \
260 find . -name ChangeLog -maxdepth 2 \
261 | xargs $(CVS) diff -up -r$(prev-cvs-tag) -rHEAD \
262 | sed -n 's/^+//p' \
263 | perl -ne 'm!^\+\+ (\./)?! or print,next;' \
264 -e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
265 )
266
267
268 ## ---------------- ##
269 ## Updating files. ##
270 ## ---------------- ##
271
272 WGET = wget
273 ftp-gnu = ftp://ftp.gnu.org/gnu
274
275 # Use mv, if you don't have/want move-if-change.
276 move_if_change ?= move-if-change
277
278
279 # --------------------- #
280 # Updating everything. #
281 # --------------------- #
282
283 .PHONY: update
284 update: wget-update cvs-update po-update
285
286
287 # ------------------- #
288 # Updating PO files. #
289 # ------------------- #
290
291 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
292 .PHONY: do-po-update po-update
293 do-po-update:
294 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
295 rm -rf $$tmppo && \
296 mkdir $$tmppo && \
297 (cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
298 cp $$tmppo/*.po po
299 cd po && $(MAKE) update-po
300 $(MAKE) po-check
301
302 po-update:
303 if test -d "po"; then \
304 $(MAKE) do-po-update; \
305 fi
306
307 # -------------------------- #
308 # Updating GNU build tools. #
309 # -------------------------- #
310
311 # The following pseudo table associates a local directory and a URL
312 # with each of the files that belongs to some other package and is
313 # regularly updated from the specified URL.
314 wget_files ?= $(srcdir)/config/config.guess \
315 $(srcdir)/config/config.sub \
316 $(srcdir)/src/ansi2knr.c \
317 $(srcdir)/config/texinfo.tex
318 get-targets = $(patsubst %, get-%, $(wget_files))
319
320 config.guess-url_prefix = $(ftp-gnu)/config/
321 config.sub-url_prefix = $(ftp-gnu)/config/
322
323 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
324
325 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
326
327 standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
328 make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
329
330 target = $(patsubst get-%, %, $@)
331 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
332
333 .PHONY: $(get-targets)
334 $(get-targets):
335 $(WGET) $(url) -O $(target).t \
336 && $(move_if_change) $(target).t $(target)
337
338 cvs_files ?= $(srcdir)/config/depcomp $(srcdir)/config/missing $(srcdir)/config/mkinstalldirs \
339 $(srcdir)/config/install-sh $(srcdir)/src/ansi2knr.c
340 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
341 .PHONY: wget-update
342 wget-update: $(get-targets)
343
344 .PHONY: cvs-update
345 cvs-update:
346 for f in $(cvs_files); do \
347 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
348 file=$$(basename $$f); \
349 echo checking out $$file...; \
350 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
351 && $(move_if_change) $$f.t $$f; \
352 done
353
354 define emit-upload-commands
355 echo =====================================
356 echo =====================================
357 echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
358 echo '# send the /tmp/announcement e-mail'
359 echo =====================================
360 echo =====================================
361 endef
362
363 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
364 xdelta delta -9 $^ $@ || :
365
366 alpha: $(local-check)
367 $(MAKE) cvs-dist
368 $(MAKE) $(xd-delta)
369 $(MAKE) -s announcement > /tmp/announce-$(my_distdir)
370 ln $(rel-files) $(release_archive_dir)
371 chmod a-w $(rel-files)
372 echo $(VERSION) > $(prev_version_file)
373 $(CVS) ci -m. $(prev_version_file)
374 @$(emit-upload-commands)