]> git.saurik.com Git - bison.git/blob - Makefile.maint
e9258740d062c00695ad3f47200ac9a7604c550b
[bison.git] / Makefile.maint
1 # -*-Makefile-*-
2 # This Makefile fragment is shared between fileutils, sh-utils, textutils,
3 # CPPI, Bison, and Autoconf.
4
5 prev_version_file ?= .prev-version
6
7 THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
8 PREV_VERSION := $(shell cat $(prev_version_file))
9 PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
10
11 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
12 tag-this-version = $(subst .,_,$(VERSION))
13 tag-prev-version = $(subst .,_,$(PREV_VERSION))
14 this-cvs-tag = $(tag-package)-$(tag-this-version)
15 prev-cvs-tag = $(tag-package)-$(tag-prev-version)
16 my_distdir = $(PACKAGE)-$(VERSION)
17
18 # Old releases are stored here.
19 # Used for diffs and xdeltas.
20 release_archive_dir ?= ../release
21
22
23
24 ## --------------- ##
25 ## Sanity checks. ##
26 ## --------------- ##
27
28 # Checks that don't require cvs.
29 local-check: changelog-check po-check writable-files copyright-check
30
31 changelog-check:
32 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
33 :; \
34 else \
35 echo "$(VERSION) not in ChangeLog" 1>&2; \
36 exit 1; \
37 fi
38
39 # Verify that all source files using _() are listed in po/POTFILES.in.
40 po-check:
41 if test -f po/POTFILES.in; then \
42 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
43 grep -E -l '\b_\(' lib/*.c src/*.c | sort > $@-2; \
44 diff -u $@-1 $@-2 || exit 1; \
45 rm -f $@-1 $@-2; \
46 fi
47
48 # Check that `make alpha' will not fail at the end of the process.
49 writable-files:
50 if test -d $(release_archive_dir); then :; else \
51 mkdir $(release_archive_dir); \
52 fi
53 for file in $(distdir).tar.gz $(xd-delta) \
54 $(release_archive_dir)/$(distdir).tar.gz \
55 $(release_archive_dir)/$(xd-delta); do \
56 test -e $$file || continue; \
57 test -w $$file \
58 || { echo ERROR: $$file is not writable; fail=1; }; \
59 done; \
60 test "$$fail" && exit 1 || :
61
62 # Make sure that the copyright date in lib/version-etc.c is up to date.
63 copyright-check:
64 @if test -f lib/version-etc.c; then \
65 grep 'N_("Copyright (C) $(shell date +%Y) Free' lib/version-etc.c \
66 >/dev/null \
67 || { echo 'out of date copyright in $<; update it' 1>&2; exit 1; }; \
68 fi
69
70
71 # Sanity checks with the CVS repository.
72 cvs-tag-check:
73 echo $(this-cvs-tag); \
74 if cvs -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
75 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
76 exit 1; \
77 else :; fi
78
79 cvs-diff-check:
80 if cvs diff >cvs-diffs; then \
81 rm cvs-diffs; \
82 else \
83 echo "Some files are locally modified:" 1>&2; \
84 cat cvs-diffs; \
85 exit 1; \
86 fi
87
88 cvs-check: cvs-diff-check cvs-tag-check
89
90 maintainer-distcheck: changelog-check
91 $(MAKE) distcheck
92 $(MAKE) my-distcheck
93
94
95 # Do not save the original name or timestamp in the .tar.gz file.
96 GZIP_ENV = '--no-name --best'
97
98 # Automake 1.4 does not define AMTAR.
99 AMTAR ?= $(TAR)
100
101 # Tag before making distribution. Also, don't make a distribution if
102 # checks fail. Also, make sure the NEWS file is up-to-date.
103 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
104 cvs-dist: cvs-check maintainer-distcheck
105 cvs update po
106 cvs tag -c $(this-cvs-tag)
107 $(MAKE) dist
108
109 # Use this to make sure we don't run these programs when building
110 # from a virgin tgz file, below.
111 null_AM_MAKEFLAGS = \
112 ACLOCAL=false \
113 AUTOCONF=false \
114 AUTOMAKE=false \
115 AUTOHEADER=false \
116 MAKEINFO=false
117
118 # Detect format-string/arg-list mismatches that would normally be obscured
119 # by the use of _(). The --disable-nls effectively defines away that macro,
120 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
121 # treated as a failure.
122 t=./=test
123 my-distcheck: writable-files po-check
124 -rm -rf $(t)
125 mkdir $(t)
126 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
127 cd $(t)/$(distdir) \
128 && ./configure --disable-nls \
129 && $(MAKE) CFLAGS='-Wformat -Werror' \
130 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
131 && $(MAKE) dvi \
132 && $(MAKE) check \
133 && $(MAKE) distclean
134 cd $(t) && mv $(distdir) $(distdir).old \
135 && $(AMTAR) -zxf ../$(distdir).tar.gz
136 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
137 -rm -rf $(t)
138 @echo "========================"; \
139 echo "$(distdir).tar.gz is ready for distribution"; \
140 echo "========================"
141
142 # This must be the same name on both hosts.
143 # Make it a symlink that points to the right place.
144 real_dir = fetish-ftp
145
146 url_dir_list = $(foreach x,$(hosts),ftp://$($(x)_host)/$($(x)_url_dir))
147
148 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
149 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
150 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
151 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
152 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([Mk]\).*/ \1B/')
153 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([Mk]\).*/ \1B/')
154 xd-size = $(shell du --human $(xd-delta)|sed 's/\([Mk]\).*/ \1B/')
155
156 rel-check:
157 tarz=/tmp/rel-check-tarz-$$$$; \
158 md5_tmp=/tmp/rel-check-md5-$$$$; \
159 set -e; \
160 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
161 wget -q --output-document=$$tarz $(url); \
162 echo "$(md5) -" > $$md5_tmp; \
163 md5sum -c $$md5_tmp < $$tarz
164
165 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
166 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
167
168 GZIP = gzip
169 BZIP2 = bzip2
170 $(my_distdir).tar.bz2: $(my_distdir).tar.gz
171 $(GZIP) -dc $< > $(my_distdir).tar
172 rm -f $@
173 $(BZIP2) -9 $(my_distdir).tar
174
175 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
176 announcement: NEWS ChangeLog $(rel-files)
177 @( \
178 echo Subject: $(my_distdir) released; \
179 echo; \
180 echo FIXME: put comments here; \
181 echo; \
182 for url in $(url_dir_list); do \
183 echo " $$url/$(my_distdir).tar.gz ($(tgz-size))"; \
184 echo " $$url/$(my_distdir).tar.bz2 ($(bz2-size))"; \
185 done; \
186 echo; \
187 echo And here are xdelta-style diffs; \
188 echo; \
189 for url in $(url_dir_list); do \
190 echo " $$url/$(xd-delta) ($(xd-size))"; \
191 done; \
192 echo; \
193 echo "Here are the MD5 and SHA1 signatures for the compressed tar files:"; \
194 echo; \
195 echo "$(tgz-md5) $(my_distdir).tar.gz"; \
196 echo "$(bz2-md5) $(my_distdir).tar.bz2"; \
197 echo "$(tgz-sha1) $(my_distdir).tar.gz"; \
198 echo "$(bz2-sha1) $(my_distdir).tar.bz2"; \
199 echo; \
200 echo NEWS:; \
201 sed -n "/$(THIS_VERSION_REGEXP)[]:]/,/$(PREV_VERSION_REGEXP)[]:]/p" NEWS \
202 | grep -v '^\['; \
203 echo; \
204 echo ChangeLog entries:; \
205 find . -name ChangeLog -maxdepth 2 \
206 | xargs cvs diff -up -r$(prev-cvs-tag) -rHEAD \
207 | sed -n 's/^+//p' \
208 | perl -ne 'm!^\+\+ (\./)?! or print,next;' \
209 -e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
210 )
211
212 WGET = wget
213 ftp-gnu = ftp://ftp.gnu.org/gnu
214
215 # Use mv, if you don't have/want move-if-change.
216 move_if_change ?= move-if-change
217
218 # The following pseudo table associates a local directory and a URL
219 # with each of the files that belongs to some other package and is
220 # regularly updated from the specified URL.
221 wget_files ?= $(srcdir)/config.guess $(srcdir)/config.sub \
222 $(srcdir)/src/ansi2knr.c \
223 $(srcdir)/doc/texinfo.tex
224 get-targets = $(patsubst %, get-%, $(wget_files))
225
226 config.guess-url_prefix = $(ftp-gnu)/config/
227 config.sub-url_prefix = $(ftp-gnu)/config/
228
229 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
230
231 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
232
233 standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
234 make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
235
236 target = $(patsubst get-%, %, $@)
237 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
238
239 .PHONY: $(get-targets)
240 $(get-targets):
241 $(WGET) $(url) -O $(target).t \
242 && $(move_if_change) $(target).t $(target)
243
244 automake_repo=:pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
245 .PHONY: wget-update
246 wget-update: $(get-targets)
247 for f in depcomp missing; do \
248 test -f $$f || continue; \
249 echo checking out $$f...; \
250 cvs -d $(automake_repo) co -p automake/lib/$$f > $$f.t \
251 && $(move_if_change) $$f.t $$f; \
252 done
253
254 define emit-rsync-commands
255 echo =====================================
256 echo =====================================
257 echo 'for host in $(a_host) $(b_host); do \'
258 echo ' rsync -e ssh --pro -av $(xd-delta) $(my_distdir).tar.bz2 \'
259 echo ' $(my_distdir).tar.gz $$host:$(real_dir); done'
260 echo '# send the /tmp/announcement e-mail'
261 echo =====================================
262 echo =====================================
263 endef
264
265 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
266 xdelta delta -9 $^ $@ || :
267
268 alpha: local-check
269 $(MAKE) cvs-dist
270 $(MAKE) $(xd-delta)
271 $(MAKE) -s announcement > /tmp/announce-$(my_distdir)
272 ln $(rel-files) $(release_archive_dir)
273 chmod a-w $(rel-files)
274 echo $(VERSION) > $(prev_version_file)
275 cvs ci -m. $(prev_version_file)
276 @$(emit-rsync-commands)