source: trunk/m4/yat_svn_release.m4 @ 4321

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

YAT_SVN_TIMESTAMP uses make variable SVN; AC_REQUIRE new macro _YAT_PROG_SVN to ensure that variable is defined.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 8.0 KB
Line 
1## $Id: yat_svn_release.m4 4321 2023-02-21 15:35:54Z 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
35AC_DEFUN([YAT_AC_WRITE],
36[
37m4_esyscmd([cat > $1 << '__EOF'
38$2
39__EOF
40])
41])
42
43
44AC_DEFUN([YAT_AC_WRITE_APPEND],
45[
46m4_esyscmd([cat >> $1 << '__EOF'
47$2
48__EOF
49])
50])
51
52
53# YAT_SVN_RELEASE(am-file, stable-version, upload-url, download-url, news-url)
54# ============================================================================
55AC_DEFUN([YAT_SVN_RELEASE],
56[
57  m4_pushdef([YAT_OUTPUTFILE], [m4_default([$1], [maintainer.am])])
58
59  AC_REQUIRE([AC_PROG_SED])
60  AC_REQUIRE([AC_PROG_EGREP])
61  AC_REQUIRE([_YAT_PROG_SVN])
62  AC_CHECK_PROGS([MD5], [md5sum gmd5sum md5 md5deep], [false])
63  AC_CHECK_PROG([SVNCOPYRIGHT], [svncopyright], [svncopyright], [false])
64  AC_CHECK_PROG([SVNDIGEST_COPY_CACHE], [svndigest-copy-cache],
65                [svndigest-copy-cache], [false])
66  AC_CHECK_PROG([SCP], [scp], [scp], [false])
67
68  YAT_AC_WRITE(YAT_OUTPUTFILE,
69[# $1 generated by Autoconf ]AC_AUTOCONF_VERSION[ from macro $0
70## include this file in Makefile.am
71
72STABLE_VERSION = $2
73STABLE_BRANCH = ^/branches/$(STABLE_VERSION)-stable
74UPLOAD_URL = $3
75DOWNLOAD_URL = $4
76NEWS_URL = $5
77SVN_LIST_CC = `$(SVN) list -R $(srcdir) | $(EGREP) ".cc$$" | $(SED) 's,^,$(srcdir)/,'`
78
79.PHONY: check-svn-diff check-news check-news-date check-version \
80        check-release-tools maintainer-check release
81
82# --------------------------------------------------------------------
83# Tagging and uploading a release
84#
85# This is the main target used at release. It does several checks of
86# the package, creates a tarball, an svn tag, and uploads the package
87# to download page.
88# --------------------------------------------------------------------
89release-tag-upload:
90  @test -z "$(RELEASE_LOCAL)" || $(MAKE) $(AM_MAKEFLAGS) $(RELEASE_LOCAL)
91  $(MAKE) $(AM_MAKEFLAGS) check-release-tools
92  $(MAKE) $(AM_MAKEFLAGS) release-check
93  $(MAKE) $(AM_MAKEFLAGS) distcheck
94  $(MAKE) $(AM_MAKEFLAGS) maintainer-check
95  $(MAKE) $(AM_MAKEFLAGS) svn-tag
96  $(SVN) update $(srcdir)
97  $(MAKE) $(AM_MAKEFLAGS) dist
98  $(MAKE) $(AM_MAKEFLAGS) $(distdir).tar.gz.MD5
99  $(MAKE) $(AM_MAKEFLAGS) announce.txt
100  $(MAKE) $(AM_MAKEFLAGS) upload
101
102$(distdir).tar.gz.MD5: $(distdir).tar.gz
103  $(MD5) $(distdir).tar.gz > $(distdir).tar.gz.MD5
104
105# Check that we have all tools needed to do a release
106check-release-tools:
107  @test x"$(sf_user)" != x"" || \
108  { echo "make variable 'sf_user' is empty" >&2; exit 1; }
109  @test "x$(MD5)" != "xfalse" || \
110  { echo "no tool to calculate MD5 checksum available" 1>&2 && exit 1; }
111  @test "x$(SVN)" != "xfalse" || \
112  { echo "no subversion client available" 1>&2 && exit 1; }
113  @test "x$(SVNDIGEST_COPY_CACHE)" != "xfalse" || \
114  { echo "svndigest-copy-cache not available" 1>&2 && exit 1; }
115  @test "x$(SCP)" != "xfalse" || \
116  { echo "scp not available" 1>&2 && exit 1; }
117
118# upload dist tarball to $(UPLOAD_URL)
119upload: $(distdir).tar.gz $(distdir).tar.gz.MD5
120  $(SCP) $(distdir).tar.gz $(distdir).tar.gz.MD5 \
121  $(sf_user),$(UPLOAD_URL)
122
123
124mc_exportdir = _exported
125mc_builddir = _exported_build
126
127# ---------------------------------------------------------------------
128# Similar to automake generated distcheck rule
129#
130# This rule 'svn export' the local WC and tries to bootstrap, a VPATH
131# configuration, and check that everything is there to make dist. The
132# rule is hookable; if variable MAINTAINER_CHECK_LOCAL is non-empty it
133# will be issued. A typical declaration would be
134# MAINTAINER_CHECK_LOCAL = check
135# ---------------------------------------------------------------------
136maintainer-check:
137  $(MAKE) $(AM_MAKEFLAGS) syntax-check
138  rm -rf $(mc_exportdir)
139  rm -rf $(mc_builddir)
140  $(SVN) export $(srcdir) $(mc_exportdir)
141  mkdir $(mc_builddir)
142  @cd $(mc_exportdir) \
143  && echo "./bootstrap" \
144  && ./bootstrap \
145  && cd ../$(mc_builddir) \
146  && ../$(mc_exportdir)/configure --srcdir=../$(mc_exportdir) \
147     $(DISTCHECK_CONFIGURE_FLAGS) \
148  && { test -z "$(MAINTAINER_CHECK_LOCAL)" || \
149        $(MAKE) $(AM_MAKEFLAGS) $(MAINTAINER_CHECK_LOCAL); } \
150  && $(MAKE) $(AM_MAKEFLAGS) dist || exit 1
151  rm -rf $(mc_builddir) $(mc_exportdir)
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/)//' >> $][@]dnl
245)
246
247m4_ifdef([AM_PROG_LIBTOOL],
248[YAT_AC_WRITE_APPEND(YAT_OUTPUTFILE,
249[ @$(srcdir)/libtool --version | head -n 1 | $(SED) -e 's/.*(//' -e 's/)//' >> $][@])
250])
251
252YAT_AC_WRITE_APPEND(YAT_OUTPUTFILE,
253[ @echo >> $][@
254  @echo You can find the list of significant changes between $(VERSION)>> $][@
255  @echo and earlier versions at >> $][@
256  @echo >> $][@
257  @echo $(NEWS_URL) >> $][@
258])
259
260m4_popdef([YAT_OUTPUTFILE])
261]) # YAT_SVN_RELEASE
Note: See TracBrowser for help on using the repository browser.