missing NULL terminator in set_config_x
[geda-gaf.git] / m4 / geda-git-version.m4
blobd8da653105fbe6520b4a5292cdda842ca499c4c9
1 # geda-git-version.m4                                   -*-Autoconf-*-
2 # serial 3
4 dnl Extract gEDA version parameters from a git repository, if present.
5 dnl Copyright (C) 2009-2011, 2016  Peter Brett <peter@peter-b.co.uk>
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2 of the License, or
10 dnl (at your option) any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 # AX_GIT_VERSION DATE-VERSION
22 # Check for a git repository. If present, sanity check the latest tag
23 # name. This probably isn't strictly necessary.
24 AC_DEFUN([AX_GIT_VERSION],
26   AC_PREREQ([2.69])dnl
27   AC_REQUIRE([AX_GIT_REPO])dnl
29   # First split version specified with AC_INIT into dotted and date
30   # parts
31 changequote(,)
32   init_sed_pattern="^\([\.0-9]*\)\.\([0-9]*\)$"
33 changequote([,])
34   DOTTED_VERSION="$PACKAGE_VERSION"
35   DATE_VERSION="$1"
37   # If we're in a git repository, get the detailed version from git
38   # describe.
39   if test "X$HAVE_GIT_REPO" = "Xyes"; then
40     AC_MSG_CHECKING([version from git repository])
41     GIT_VERSION=`cd $srcdir && $GIT rev-parse HEAD 2>/dev/null`
42     AC_MSG_RESULT([$GIT_VERSION])
44     AC_MSG_CHECKING([descriptive git version])
45     GIT_DESCRIBE_VERSION=`cd $srcdir && $GIT describe 2>/dev/null`
46     if test "$?" = "0"; then
47       AC_MSG_RESULT([$GIT_DESCRIBE_VERSION])
48     else
49       AC_MSG_RESULT([no])
50     fi
51   fi
53   # If there's an annotated tag available, test that the git version
54   # and AC_INIT versions agree.
55   if test "X$GIT_DESCRIBE_VERSION" != "X"; then
56     AC_MSG_CHECKING([whether git version matches configured version])
57 changequote(,)
58     git_sed_pattern="^\([^-]*\)-\([^-]*\).*"
59 changequote([,])
60     GIT_DOTTED_VERSION=`echo $GIT_DESCRIBE_VERSION |
61                         sed -e"s/$git_sed_pattern/\1/"`
62     GIT_DATE_VERSION=`echo $GIT_DESCRIBE_VERSION |
63                       sed -e"s/$git_sed_pattern/\2/"`
65     if (test "X$GIT_DOTTED_VERSION" != "X$DOTTED_VERSION") ||
66        (test "X$GIT_DATE_VERSION" != "X$DATE_VERSION");
67     then
68       AC_MSG_RESULT([no])
69       AC_MSG_WARN([The latest git tag name doesn't appear to match the version specified
70 by the configure script.])
71     else
72       AC_MSG_RESULT([yes])
73     fi
74   fi
76   AC_SUBST([DOTTED_VERSION])
77   AC_SUBST([DATE_VERSION])
79   # We generate some files differently if a git repo is present
80   AM_CONDITIONAL([HAVE_GIT_REPO], test "X$HAVE_GIT_REPO" = "Xyes")
82 ])dnl AX_GIT_VERSION