Merge pull request #1406 from kugel-/for-upstream
[geany-mirror.git] / m4 / geany-revision.m4
blobc4a19f7de5bb845199b93ed8204d6c0dc4ab2529
1 dnl GEANY_CHECK_REVISION([action-if-found], [action-if-not-found])
2 dnl Check for the Git revision and set REVISION to "<revid>"
3 dnl or to "-1" if the revision can't be found
4 dnl Also AC_DEFINEs REVISION
5 AC_DEFUN([GEANY_CHECK_REVISION],
7         REVISION="0"
9         AC_MSG_CHECKING([for Git revision])
10         # try Git first
11         GIT=`which git 2>/dev/null`
12         if test -d "$srcdir/.git" -a "x${GIT}" != "x" -a -x "${GIT}"; then
13                 REVISION=`cd "$srcdir"; "${GIT}" rev-parse --short --revs-only HEAD 2>/dev/null || echo 0`
14         fi
16         if test "x${REVISION}" != "x0"; then
17                 AC_MSG_RESULT([$REVISION])
18                 GEANY_STATUS_ADD([Compiling Git revision], [$REVISION])
20                 # call action-if-found
21                 $1
22         else
23                 REVISION="-1"
24                 AC_MSG_RESULT([none])
26                 # call action-if-not-found
27                 $2
28         fi
30         AC_DEFINE_UNQUOTED([REVISION], "$REVISION", [git revision hash])