Make GNUmakefile work with in-place builds.
[m4/ericb.git] / Makefile.maint
blob2e808451c9f61ba02a00c98ceb70843e99cdee13
1 ## Makefile.maint -- Makefile rules for m4 maintainers -*-Makefile-*-
2 ##
3 ## Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
4 ##
5 ## This file is part of GNU M4.
6 ##
7 ## GNU M4 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 3 of the License, or
10 ## (at your option) any later version.
12 ## GNU M4 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.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 # Do not save the original name or timestamp in the .tar.gz file.
21 # Use --rsyncable if available.
22 gzip_rsyncable := \
23   $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable)
24 GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
26 CVS = cvs
27 GIT = git
28 VC = $(GIT)
29 VC-tag = git tag -s -m '$(VERSION)' -u $(gpg_key_ID)
31 VERSION_REGEXP = $(subst .,\.,$(VERSION))
32 ifeq ($(VC),$(GIT))
33 this-vc-tag = v$(VERSION)
34 else
35 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
36 tag-this-version = $(subst .,_,$(VERSION))
37 this-vc-tag = $(tag-package)-$(tag-this-version)
38 endif
39 my_distdir = $(PACKAGE)-$(VERSION)
41 # Ensure that we use only the standard $(VAR) notation,
42 # not @...@ in Makefile.am, now that we can rely on automake
43 # to emit a definition for each substituted variable.
44 makefile-check:
45         grep -nE '@[A-Z_0-9]+@' `find $(srcdir) -name Makefile.am` \
46           && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
48 news-date-check: NEWS version-check
49         today=`date +%Y-%m-%d`;                                         \
50         if head $(srcdir)/NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')'     \
51             >/dev/null; then                                            \
52           :;                                                            \
53         else                                                            \
54           echo "version or today's date is not in NEWS" 1>&2;           \
55           exit 1;                                                       \
56         fi
58 changelog-check:
59         if head $(srcdir)/ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$'      \
60             >/dev/null; then                                            \
61           :;                                                            \
62         else                                                            \
63           echo "$(VERSION) not in ChangeLog" 1>&2;                      \
64           exit 1;                                                       \
65         fi
67 m4-check:
68         @grep -n 'AC_DEFUN([^[]' $(srcdir)/m4/*.m4 \
69           && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
70                exit 1; } || :
72 vc-diff-check:
73         (CDPATH=; cd $(srcdir) && $(VC) diff) > vc-diffs || :
74         if test -s vc-diffs; then                               \
75           cat vc-diffs;                                         \
76           echo "Some files are locally modified:" 1>&2;         \
77           exit 1;                                               \
78         else                                                    \
79           rm vc-diffs;                                          \
80         fi
82 maintainer-distcheck:
83         $(MAKE) distcheck
84         $(MAKE) my-distcheck
86 # Don't make a distribution if checks fail.
87 # Also, make sure the NEWS file is up-to-date.
88 vc-dist: $(local-check) vc-diff-check maintainer-distcheck
89         $(MAKE) dist
91 # Use this to make sure we don't run these programs when building
92 # from a virgin tgz file, below.
93 null_AM_MAKEFLAGS = \
94   ACLOCAL=false \
95   AUTOCONF=false \
96   AUTOMAKE=false \
97   AUTOHEADER=false \
98   MAKEINFO=false
100 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
101 # Also, check for shadowing problems with -Wshadow, and for pointer
102 # arithmetic problems with -Wpointer-arith.
103 # These CFLAGS are pretty strict.  If you build this target, you probably
104 # have to have a recent version of gcc and glibc headers.
105 TMPDIR ?= /tmp
106 t=$(TMPDIR)/$(PACKAGE)/test
107 my-distcheck: $(local-check) check
108         -rm -rf $(t)
109         mkdir -p $(t)
110         GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
111         cd $(t)/$(distdir)                              \
112           && ./configure                                \
113           && $(MAKE) CFLAGS='$(warn_cflags)'            \
114               AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
115           && $(MAKE) dvi                                \
116           && $(MAKE) check                              \
117           && $(MAKE) distclean
118         (cd $(t) && mv $(distdir) $(distdir).old        \
119           && $(AMTAR) -zxf - ) < $(distdir).tar.gz
120         diff -ur $(t)/$(distdir).old $(t)/$(distdir)
121         -rm -rf $(t)
122         @echo "========================"; \
123         echo "$(distdir).tar.gz is ready for distribution"; \
124         echo "========================"
126 gnulib-version = $$(cd $(gnulib_dir) && git describe)
128 announcement: NEWS ChangeLog $(rel-files)
129         @./build-aux/announce-gen                                       \
130             --release-type=$(RELEASE_TYPE)                              \
131             --package=$(PACKAGE)                                        \
132             --prev=$(PREV_VERSION)                                      \
133             --curr=$(VERSION)                                           \
134             --gpg-key-id=$(gpg_key_ID)                                  \
135             --news=NEWS                                                 \
136             --bootstrap-tools=autoconf,automake,gnulib                  \
137             --gnulib-version=$(gnulib-version)                          \
138             $(addprefix --url-dir=, $(url_dir_list))
140 .PHONY: alpha beta major
141 alpha beta major: $(local-check)
142         test $@ = major                                         \
143           && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
144                || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
145           || :
146         $(MAKE) vc-dist
147         $(MAKE) news-date-check changelog-check
148         $(MAKE) deltas
149         $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
150         $(VC-tag) $(this-vc-tag)
152 .PHONY: version-check
153 version-check:
154         @case $(VERSION) in \
155         *[acegikmoqsuwy]) \
156           echo "Version \`$(VERSION)' is not a releasable version, please read:"; \
157           echo "    http://www.gnu.org/software/libtool/contribute.html"; \
158           exit 1; \
159           ;; \
160         esac
162 .PHONY: prev-tarball
163 prev-tarball:
164 ## Make sure we have the previous release tarball in the tree.
165         @if test -z "$(PREV_VERSION)"; \
166                 then echo "PREV_VERSION is not set"; exit 1; fi
167         @ofile="$(PACKAGE)-$(PREV_VERSION).tar.gz"; \
168         if test -f $$ofile; then :; \
169         else echo "Cannot make deltas without $$ofile"; exit 1; fi
171 .PHONY: new-tarball
172 new-tarball:
173 ## Make sure we have the new release tarball in the tree.
174         @ofile="$(PACKAGE)-$(VERSION).tar.gz"; \
175         if test -f $$ofile; then :; \
176         else echo "Cannot make deltas without $$ofile"; exit 1; fi
178 .PHONY: got-xdelta
179 got-xdelta:
180 ## Make sure xdelta exists;
181         @if ($(XDELTA) --version 2>&1 | grep version)>/dev/null 2>/dev/null; \
182         then :;\
183         else \
184           echo "Get xdelta from http://sourceforge.net/projects/xdelta."; \
185           exit 1; \
186         fi
188 .PHONY: deltas
189 deltas: delta-diff delta-xdelta
191 DIFF = diff
192 DIFF_OPTIONS = -ruNp
194 .PHONY: delta-diff
195 delta-diff: prev-tarball new-tarball
196 ## Unpack the tarballs somewhere to diff them
197         rm -rf delta-diff
198         mkdir delta-diff
199         ofile="../$(PACKAGE)-$(PREV_VERSION)-$(VERSION).diff.gz"; \
200         cd delta-diff \
201         && tar xzf "../$(PACKAGE)-$(PREV_VERSION).tar.gz" \
202         && tar xzf "../$(PACKAGE)-$(VERSION).tar.gz" \
203         && $(DIFF) $(DIFF_OPTIONS) \
204                 $(PACKAGE)-$(PREV_VERSION) $(PACKAGE)-$(VERSION) \
205                 | GZIP=$(GZIP_ENV) gzip -c > $$ofile
206         rm -rf delta-diff
208 XDELTA = xdelta
209 XDELTA_OPTIONS = -9
211 .PHONY: delta-xdelta
212 delta-xdelta: prev-tarball new-tarball got-xdelta
213 ## Generate the delta file (xdelta has weird exit statuses, so we need to
214 ## add some shell code to keep make happy), and then generate the signatures
215 ## for FSF ftp-upload:
216         ofile="$(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta"; \
217         ( test -z `$(XDELTA) delta $(XDELTA_OPTIONS) \
218             $(PACKAGE)-$(PREV_VERSION).tar.gz $(PACKAGE)-$(VERSION).tar.gz \
219             $$ofile 2>&1` \
220           && : )
222 .PHONY: web-manual
223 web-manual:
224         @cd ./doc ; \
225           $(SHELL) $(srcdir)/build-aux/gendocs.sh $(PACKAGE) \
226             "GNU $(PACKAGE)- GNU macro processor"
227         @echo " *** Upload the doc/manual directory to web-cvs."