source: trunk/m4/yat_svn_release.m4 @ 4326

Last change on this file since 4326 was 4326, checked in by Peter, 7 months ago

We had two macros with very similar behaviour: YAT_AC_APPEND in
'yat_svn_release' and private macro _YAT_AC_APPEND_TO_FILE. Replace
with new macro YAT_AC_APPEND_TO_FILE with tested and documented
behaviour. Similarly a macro YAT_AC_WRITE_TO_FILE.

Introduce a new macro YAT_AM_LOCAL, which is recommended to use when
using any of the macros generating automake input.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 8.5 KB
Line 
1## $Id: yat_svn_release.m4 4326 2023-03-12 00:37:24Z peter $
2
3# serial 18 (yat 0.21)
4
5# SYNOPSIS
6#
7#   YAT_SVN_RELEASE
8#
9# DESCRIPTION
10#
11#
12# COPYLEFT
13m4_define([yat_svn_release_copyright], [dnl
14#
15#   Copyright (C) 2009, 2010, 2011, 2012, 2014, 2019 Peter Johansson
16#
17#   This file is part of the yat library, http://dev.thep.lu.se/yat
18#
19#   The yat library is free software; you can redistribute it and/or
20#   modify it under the terms of the GNU General Public License as
21#   published by the Free Software Foundation; either version 3 of the
22#   License, or (at your option) any later version.
23#
24#   The yat library is distributed in the hope that it will be useful,
25#   but WITHOUT ANY WARRANTY; without even the implied warranty of
26#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27#   General Public License for more details.
28#
29#   You should have received a copy of the GNU General Public License
30#   along with yat. If not, see <http://www.gnu.org/licenses/>.
31#
32])
33
34
35# YAT_SVN_RELEASE(am-file, stable-version, upload-url, download-url, news-url)
36# ============================================================================
37AC_DEFUN([YAT_SVN_RELEASE],
38[
39  m4_pushdef([YAT_OUTPUTFILE], [m4_default([$1], [maintainer.am])])
40
41  AC_REQUIRE([AC_PROG_SED])
42  AC_REQUIRE([AC_PROG_EGREP])
43  AC_REQUIRE([_YAT_PROG_SVN])
44  AC_CHECK_PROGS([MD5], [md5sum gmd5sum md5 md5deep], [false])
45  AC_CHECK_PROG([SVNCOPYRIGHT], [svncopyright], [svncopyright], [false])
46  AC_CHECK_PROG([SVNDIGEST_COPY_CACHE], [svndigest-copy-cache],
47                [svndigest-copy-cache], [false])
48  AC_CHECK_PROG([SCP], [scp], [scp], [false])
49
50  m4_ifdef([AM_PROG_LIBTOOL], [
51    m4_pushdef([write_LIBTOOL_VERSION_cmd],
52               [$(srcdir)/libtool --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> [$]@])
53  ], [
54    m4_pushdef([write_LIBTOOL_VERSION_cmd], [:])
55  ])
56  _YAT_AM_LOCAL_WRITE(YAT_OUTPUTFILE, [
57
58STABLE_VERSION = $2
59STABLE_BRANCH = ^/branches/$(STABLE_VERSION)-stable
60UPLOAD_URL = $3
61DOWNLOAD_URL = $4
62NEWS_URL = $5
63SVN_LIST_CC = `$(SVN) list -R $(srcdir) | $(EGREP) ".cc$$" | $(SED) 's,^,$(srcdir)/,'`
64
65.PHONY: check-svn-diff check-news check-news-date check-version \
66        check-release-tools maintainer-check maintainer-check-local \
67        release-tag-upload release-tag-upload-local
68
69# --------------------------------------------------------------------
70# Tagging and uploading a release
71#
72# This is the main target used at release. It does several checks of
73# the package, creates a tarball, an svn tag, and uploads the package
74# to download page.
75# --------------------------------------------------------------------
76release-tag-upload:
77  $(MAKE) $(AM_MAKEFLAGS) release-tag-upload-local
78  $(MAKE) $(AM_MAKEFLAGS) check-release-tools
79  $(MAKE) $(AM_MAKEFLAGS) release-check
80  $(MAKE) $(AM_MAKEFLAGS) distcheck
81  $(MAKE) $(AM_MAKEFLAGS) maintainer-check
82  $(MAKE) $(AM_MAKEFLAGS) svn-tag
83  $(SVN) update $(srcdir)
84  $(MAKE) $(AM_MAKEFLAGS) dist
85  $(MAKE) $(AM_MAKEFLAGS) $(distdir).tar.gz.MD5
86  $(MAKE) $(AM_MAKEFLAGS) announce.txt
87  $(MAKE) $(AM_MAKEFLAGS) upload
88  $(MAKE) $(AM_MAKEFLAGS) release-tag-upload-hook
89
90# This is run early in release-tag-upload. Add targets to
91# $(RELEASE_LOCAL) such as checks that needed tools to make a release
92# are available.
93release-tag-upload-local: $(RELEASE_LOCAL)
94
95# This is run late in release-tag-upload. Add targets to
96# $(RELEASE_HOOK) if extra targets are desired.
97release-tag-upload-hook: $(RELEASE_HOOK)
98
99$(distdir).tar.gz.MD5: $(distdir).tar.gz
100  $(MD5) $(distdir).tar.gz > $(distdir).tar.gz.MD5
101
102# Check that we have all tools needed to do a release
103check-release-tools:
104  @test x"$(sf_user)" != x"" || \
105  { echo "make variable 'sf_user' is empty" >&2; exit 1; }
106  @test "x$(MD5)" != "xfalse" || \
107  { echo "no tool to calculate MD5 checksum available" 1>&2 && exit 1; }
108  @test "x$(SVN)" != "xfalse" || \
109  { echo "no subversion client available" 1>&2 && exit 1; }
110  @test "x$(SVNDIGEST_COPY_CACHE)" != "xfalse" || \
111  { echo "svndigest-copy-cache not available" 1>&2 && exit 1; }
112  @test "x$(SCP)" != "xfalse" || \
113  { echo "scp not available" 1>&2 && exit 1; }
114
115# upload dist tarball to $(UPLOAD_URL)
116upload: $(distdir).tar.gz $(distdir).tar.gz.MD5
117  $(SCP) $(distdir).tar.gz $(distdir).tar.gz.MD5 \
118  $(sf_user),$(UPLOAD_URL)
119
120
121mc_exportdir = _exported
122mc_builddir = _exported_build
123
124# ---------------------------------------------------------------------
125# Similar to automake generated distcheck rule
126#
127# This rule 'svn export' the local WC and tries to bootstrap, a VPATH
128# configuration, and check that everything is there to make dist. The
129# rule is hookable; if variable MAINTAINER_CHECK_LOCAL is non-empty it
130# will be issued. A typical declaration would be
131# MAINTAINER_CHECK_LOCAL = check
132# ---------------------------------------------------------------------
133maintainer-check:
134  $(MAKE) $(AM_MAKEFLAGS) syntax-check
135  rm -rf $(mc_exportdir)
136  rm -rf $(mc_builddir)
137  $(SVN) export $(srcdir) $(mc_exportdir)
138  mkdir $(mc_builddir)
139  @cd $(mc_exportdir) \
140  && echo "./bootstrap" \
141  && ./bootstrap \
142  && cd ../$(mc_builddir) \
143  && ../$(mc_exportdir)/configure $(DISTCHECK_CONFIGURE_FLAGS) \
144  && $(MAKE) $(AM_MAKEFLAGS) maintainer-check-local \
145  && $(MAKE) $(AM_MAKEFLAGS) dist || exit 1
146  rm -rf $(mc_builddir) $(mc_exportdir)
147
148# This is run during maintainer-check. Add targets to
149# $(MAINTAINER_CHECK_LOCAL), if extra targets such as 'check' is
150# desired during maintainer-check.
151maintainer-check-local: $(MAINTAINER_CHECK_LOCAL)
152
153# -----------------------------------------
154# Check that package is ready for release
155# -----------------------------------------
156release-check: check-news check-news-date check-svn-diff check-version
157
158# Check that NEWS mention VERSION early on
159check-news:
160  @case `sed 15q $(srcdir)/NEWS` in \
161  *"$(VERSION)"*);; \
162  *) \
163    echo "NEWS not updated" 1>&2; \
164    exit 1;; \
165  esac
166
167# Check that NEWS mention today's date (in UTC)
168check-news-date:
169  @today=`date -u "+%e %B %Y"`; \
170  case `sed 15q $(srcdir)/NEWS` in \
171  *"$$today"*);; \
172  *) \
173    echo "NEWS: release date incorrect; expected '$$today'" 1>&2;\
174    exit 1;; \
175  esac
176
177# Check that VERSION is appropriate for release
178check-version:
179  @echo $(VERSION) | $(EGREP) '^[0-9]+(\.[0-9]+)+$$' > /dev/null || \
180  { echo "invalid version string: $(VERSION)" 1>&2; exit 1; }
181
182
183#------------------
184# Subversion rules
185#------------------
186
187# Check that WC is in sync with repository
188check-svn-diff:
189  @str=`$(SVN) diff -rHEAD $(srcdir)`; \
190  test -z "$$str" || { echo "$$str" 1>&2; exit 1; }
191
192check-svn-wc-is-trunk:
193  @$(SVN) info $(srcdir) | $(GREP) -q '/trunk'
194
195
196# create a tag from current stable branch; depends on check-version to
197# ensure that version is macro.minor.micro (no pre suffix), that wc is
198# pristine and updated.
199svn-tag: check-version check-svn-diff
200  cd $(srcdir) && \
201  $(SVN) copy $(STABLE_BRANCH) ^/tags/$(VERSION) \
202  -m "tagging version $(VERSION)"
203
204# create a stable-branch from trunk
205svn-stable-branch: check-svn-diff check-svn-wc-is-trunk
206  cd $(srcdir) && \
207  $(SVN) copy ^/trunk $(STABLE_BRANCH) \
208  -m "New stable branch $(STABLE_VERSION)" \
209  && svn co $(STABLE_BRANCH) ../$(PACKAGE)-$(STABLE_VERSION).x \
210  && $(SVNDIGEST_COPY_CACHE) -v -r . -t ../$(PACKAGE)-$(STABLE_VERSION).x
211
212
213# Update copyright statement
214copyright:
215  $(SVNCOPYRIGHT) -v -r $(srcdir)
216
217syntax-check: sc_config_h
218
219sc_config_h:
220  @for f in $(SVN_LIST_CC); do \
221    $(GREP) '^#include' $$f | head -n 1 | $(GREP) -q '<config.h>' || \
222    { echo "missing '#include <config.h>' in $$f" >&2; exit 1; } \
223  done
224
225# Generate an announcement
226announce.txt: Makefile $(distdir).tar.gz.MD5
227  @echo "I'm happy to announce the release of $(PACKAGE_STRING)" > ]$[@
228  @echo >> ]$[@
229  @echo "<INSERT TEXT HERE>" >> ]$[@
230  @echo >> ]$[@
231  @echo "You can find the new release here:" >> ]$[@
232  @echo >> ]$[@
233  @echo "$(DOWNLOAD_URL)" >> ]$[@
234  @echo >> ]$[@
235  @echo "Here is the checksum" >> ]$[@
236  @echo >> ]$[@
237  @printf "MD5:    " >> ]$[@
238  @cat $(distdir).tar.gz.MD5 | $(SED) 's/ .*//' >> ]$[@
239  @echo >> ]$[@
240  @echo "Please report bugs by email to $(PACKAGE_BUGREPORT)" >> ]$[@
241  @echo >> ]$[@
242  @echo "This release was bootstrapped with the following tools:" >> ]$[@
243  @$(AUTOCONF) --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> ]$[@
244  @$(AUTOMAKE) --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> ]$[@
245        @]write_LIBTOOL_VERSION_cmd[
246  @echo >> ]$[@
247  @echo You can find the list of significant changes between $(VERSION)>> ]$[@
248  @echo and earlier versions at >> ]$[@
249  @echo >> ]$[@
250  @echo $(NEWS_URL) >> ]$[@
251
252])
253m4_popdef([YAT_OUTPUTFILE])
254m4_popdef([write_LIBTOOL_VERSION_cmd])
255]) # YAT_SVN_RELEASE
256
257# See file 'yat_common.m4' for new macros
258AU_ALIAS([YAT_AC_WRITE], [YAT_AC_WRITE_TO_FILE])
259AU_ALIAS([YAT_AC_WRITE_APPEND], [YAT_AC_APPEND_TO_FILE])
Note: See TracBrowser for help on using the repository browser.