From 3d2e73b0920f2fdc4ab39b24e7f4f42328dc2d5f Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Fri, 15 Sep 2017 14:05:39 +0100
Subject: [PATCH] build: Bundle an up-to-date AX_IS_RELEASE for now

The policy parameter we need is newer than what's in Debian stable.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 .gitignore          |  4 +--
 debian/copyright    | 12 +++++++
 m4/ax_is_release.m4 | 80 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 m4/ax_is_release.m4

diff --git a/.gitignore b/.gitignore
index 81822d72d..ab8670fcb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 /.version
 /INSTALL
 /build-aux/*
+/m4/*
 Makefile.in
 aclocal.m4
 autom4te.cache
@@ -9,8 +10,6 @@ config.status
 config.log
 configure
 libtool
-m4
-m4/*
 update
 Makefile
 .*stamp
@@ -61,3 +60,4 @@ libcapsule-*.txt
 *.prerequisites
 *.signals
 !/build-aux/git-version-gen
+!/m4/ax_is_release.m4
diff --git a/debian/copyright b/debian/copyright
index 0e93664b8..9a8ec1d83 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -16,6 +16,13 @@ Copyright:
  © 2007-2017 Free Software Foundation, Inc.
 License: GPL-3+
 
+Files:
+ m4/ax_is_release.m4
+Copyright:
+ © 2015 Philip Withnall
+ © 2016 Collabora Ltd.
+License: Autoconf-permissive
+
 License: LGPL-2.1+
  libcapsule is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
@@ -49,3 +56,8 @@ License: GPL-3+
 Comment:
  On Debian systems, the full text of the GNU General Public License
  version 3 can be found in the file '/usr/share/common-licenses/GPL-3'.
+
+License: Autoconf-permissive
+ Copying and distribution of this file, with or without modification, are
+ permitted in any medium without royalty provided the copyright notice
+ and this notice are preserved.
diff --git a/m4/ax_is_release.m4 b/m4/ax_is_release.m4
new file mode 100644
index 000000000..9097ddb6a
--- /dev/null
+++ b/m4/ax_is_release.m4
@@ -0,0 +1,80 @@
+# ===========================================================================
+#      https://www.gnu.org/software/autoconf-archive/ax_is_release.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_IS_RELEASE(POLICY)
+#
+# DESCRIPTION
+#
+#   Determine whether the code is being configured as a release, or from
+#   git. Set the ax_is_release variable to 'yes' or 'no'.
+#
+#   If building a release version, it is recommended that the configure
+#   script disable compiler errors and debug features, by conditionalising
+#   them on the ax_is_release variable.  If building from git, these
+#   features should be enabled.
+#
+#   The POLICY parameter specifies how ax_is_release is determined. It can
+#   take the following values:
+#
+#    * git-directory:  ax_is_release will be 'no' if a '.git' directory exists
+#    * minor-version:  ax_is_release will be 'no' if the minor version number
+#                      in $PACKAGE_VERSION is odd; this assumes
+#                      $PACKAGE_VERSION follows the 'major.minor.micro' scheme
+#    * micro-version:  ax_is_release will be 'no' if the micro version number
+#                      in $PACKAGE_VERSION is odd; this assumes
+#                      $PACKAGE_VERSION follows the 'major.minor.micro' scheme
+#    * dash-version:   ax_is_release will be 'no' if there is a dash '-'
+#                      in $PACKAGE_VERSION, for example 1.2-pre3, 1.2.42-a8b9
+#                      or 2.0-dirty (in particular this is suitable for use
+#                      with git-version-gen)
+#    * always:         ax_is_release will always be 'yes'
+#    * never:          ax_is_release will always be 'no'
+#
+#   Other policies may be added in future.
+#
+# LICENSE
+#
+#   Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk>
+#   Copyright (c) 2016 Collabora Ltd.
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+#serial 7
+
+AC_DEFUN([AX_IS_RELEASE],[
+    AC_BEFORE([AC_INIT],[$0])
+
+    m4_case([$1],
+      [git-directory],[
+        # $is_release = (.git directory does not exist)
+        AS_IF([test -d ${srcdir}/.git],[ax_is_release=no],[ax_is_release=yes])
+      ],
+      [minor-version],[
+        # $is_release = ($minor_version is even)
+        minor_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
+        AS_IF([test "$(( $minor_version % 2 ))" -ne 0],
+              [ax_is_release=no],[ax_is_release=yes])
+      ],
+      [micro-version],[
+        # $is_release = ($micro_version is even)
+        micro_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]]*\.[[^.]]*\.\([[^.]]*\).*/\1/'`
+        AS_IF([test "$(( $micro_version % 2 ))" -ne 0],
+              [ax_is_release=no],[ax_is_release=yes])
+      ],
+      [dash-version],[
+        # $is_release = ($PACKAGE_VERSION has a dash)
+        AS_CASE([$PACKAGE_VERSION],
+                [*-*], [ax_is_release=no],
+                [*], [ax_is_release=yes])
+      ],
+      [always],[ax_is_release=yes],
+      [never],[ax_is_release=no],
+      [
+        AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version, micro-version, dash-version, always, never.])
+      ])
+])
-- 
GitLab