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