1 # geda-git-version.m4 -*-Autoconf-*-
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>
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.
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.
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],
27 AC_REQUIRE([AX_GIT_REPO])dnl
29 # First split version specified with AC_INIT into dotted and date
32 init_sed_pattern="^\([\.0-9]*\)\.\([0-9]*\)$"
34 DOTTED_VERSION="$PACKAGE_VERSION"
37 # If we're in a git repository, get the detailed version from git
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])
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])
58 git_sed_pattern="^\([^-]*\)-\([^-]*\).*"
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");
69 AC_MSG_WARN([The latest git tag name doesn't appear to match the version specified
70 by the configure script.])
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")