1# =========================================================================== 2# https://www.gnu.org/software/autoconf-archive/ax_is_release.html 3# =========================================================================== 4# 5# SYNOPSIS 6# 7# AX_IS_RELEASE(POLICY) 8# 9# DESCRIPTION 10# 11# Determine whether the code is being configured as a release, or from 12# git. Set the ax_is_release variable to 'yes' or 'no'. 13# 14# If building a release version, it is recommended that the configure 15# script disable compiler errors and debug features, by conditionalising 16# them on the ax_is_release variable. If building from git, these 17# features should be enabled. 18# 19# The POLICY parameter specifies how ax_is_release is determined. It can 20# take the following values: 21# 22# * git-directory: ax_is_release will be 'no' if a '.git' directory exists 23# * minor-version: ax_is_release will be 'no' if the minor version number 24# in $PACKAGE_VERSION is odd; this assumes 25# $PACKAGE_VERSION follows the 'major.minor.micro' scheme 26# * micro-version: ax_is_release will be 'no' if the micro version number 27# in $PACKAGE_VERSION is odd; this assumes 28# $PACKAGE_VERSION follows the 'major.minor.micro' scheme 29# * dash-version: ax_is_release will be 'no' if there is a dash '-' 30# in $PACKAGE_VERSION, for example 1.2-pre3, 1.2.42-a8b9 31# or 2.0-dirty (in particular this is suitable for use 32# with git-version-gen) 33# * always: ax_is_release will always be 'yes' 34# * never: ax_is_release will always be 'no' 35# 36# Other policies may be added in future. 37# 38# LICENSE 39# 40# Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk> 41# Copyright (c) 2016 Collabora Ltd. 42# 43# Copying and distribution of this file, with or without modification, are 44# permitted in any medium without royalty provided the copyright notice 45# and this notice are preserved. 46 47#serial 7 48 49AC_DEFUN([AX_IS_RELEASE],[ 50 AC_BEFORE([AC_INIT],[$0]) 51 52 m4_case([$1], 53 [git-directory],[ 54 # $is_release = (.git directory does not exist) 55 AS_IF([test -d ${srcdir}/.git],[ax_is_release=no],[ax_is_release=yes]) 56 ], 57 [minor-version],[ 58 # $is_release = ($minor_version is even) 59 minor_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'` 60 AS_IF([test "$(( $minor_version % 2 ))" -ne 0], 61 [ax_is_release=no],[ax_is_release=yes]) 62 ], 63 [micro-version],[ 64 # $is_release = ($micro_version is even) 65 micro_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]]*\.[[^.]]*\.\([[^.]]*\).*/\1/'` 66 AS_IF([test "$(( $micro_version % 2 ))" -ne 0], 67 [ax_is_release=no],[ax_is_release=yes]) 68 ], 69 [dash-version],[ 70 # $is_release = ($PACKAGE_VERSION has a dash) 71 AS_CASE([$PACKAGE_VERSION], 72 [*-*], [ax_is_release=no], 73 [*], [ax_is_release=yes]) 74 ], 75 [always],[ax_is_release=yes], 76 [never],[ax_is_release=no], 77 [ 78 AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version, micro-version, dash-version, always, never.]) 79 ]) 80]) 81