1 # geda-git-version.m4 -*-Autoconf-*-
4 dnl Extract gEDA version parameters from a git repository, if present.
5 dnl Copyright (C) 2009-2011 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 describe`
42 AC_MSG_RESULT([$GIT_VERSION])
45 # If there's an annotated tag available, test that the git version
46 # and AC_INIT versions agree.
47 if (cd $srcdir && git describe > /dev/null); then
49 git_sed_pattern="^\([^-]*\)-\([^-]*\).*"
51 GIT_DOTTED_VERSION=`echo $GIT_VERSION | sed -e"s/$git_sed_pattern/\1/"`
52 GIT_DATE_VERSION=`echo $GIT_VERSION | sed -e"s/$git_sed_pattern/\2/"`
54 if (test "X$GIT_DOTTED_VERSION" != "X$DOTTED_VERSION") ||
55 (test "X$GIT_DATE_VERSION" != "X$DATE_VERSION");
58 AC_MSG_WARN([The latest git tag name doesn't appear to match the version specified
59 by the configure script.])
63 AC_SUBST([DOTTED_VERSION])
64 AC_SUBST([DATE_VERSION])
66 # We generate some files differently if a git repo is present
67 AM_CONDITIONAL([HAVE_GIT_REPO], test "X$HAVE_GIT_REPO" = "Xyes")