source: trunk/m4/yat_svn_release.m4

Last change on this file was 1627, checked in by Peter Johansson, 10 days ago

recent changes from yat

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