summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid King <amigadave@amigadave.com>2015-02-05 15:11:10 +0000
committerDavid King <amigadave@amigadave.com>2015-02-05 16:17:41 +0000
commitb1490f18cede41f4eef65e73a459280267a8bb7d (patch)
treeb7b9b2f56ac2d79c3279a13e2920bc24819be472
parentde53b48de1ebd895e9052400192039618c3e4a84 (diff)
downloadyelp-b1490f18cede41f4eef65e73a459280267a8bb7d.tar.gz
Use AX_IS_RELEASE
Check for the presence of a git repository to determine if compiler warnings should be fatal. https://wiki.gnome.org/Projects/GnomeCommon/Migration#preview
-rw-r--r--configure.ac3
-rw-r--r--m4/ax_is_release.m460
2 files changed, 62 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 58ed84c3..c5f6cb37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,7 @@ AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])
+AX_IS_RELEASE([git-directory])
AX_CHECK_ENABLE_DEBUG([info], [YELP_DEBUG])
# Check for programs
@@ -39,7 +40,7 @@ PKG_CHECK_MODULES(YELP,
AC_SUBST([YELP_CFLAGS])
AC_SUBST([YELP_LIBS])
-AX_COMPILER_FLAGS
+AX_COMPILER_FLAGS([], [], [$ax_is_release])
# Initialize libtool
LT_PREREQ([2.2.6])
diff --git a/m4/ax_is_release.m4 b/m4/ax_is_release.m4
new file mode 100644
index 00000000..68e11f05
--- /dev/null
+++ b/m4/ax_is_release.m4
@@ -0,0 +1,60 @@
+# ===========================================================================
+# http://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
+# * 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>
+#
+# 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 2
+
+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 .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])
+ ],
+ [always],[ax_is_release=yes],
+ [never],[ax_is_release=no],
+ [
+ AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version.])
+ ])
+])