geany-revision.m4 813 Bytes
Newer Older
1
dnl GEANY_CHECK_REVISION([action-if-found], [action-if-not-found])
2 3
dnl Check for the Git revision and set REVISION to "<revid>"
dnl or to "-1" if the revision can't be found
4 5 6
dnl Also AC_DEFINEs REVISION
AC_DEFUN([GEANY_CHECK_REVISION],
[
7
	REVISION="0"
8

9
	AC_MSG_CHECKING([for Git revision])
10 11
	# try Git first
	GIT=`which git 2>/dev/null`
12 13
	if test -d "$srcdir/.git" -a "x${GIT}" != "x" -a -x "${GIT}"; then
		REVISION=`cd "$srcdir"; "${GIT}" rev-parse --short --revs-only HEAD 2>/dev/null || echo 0`
14 15
	fi

16
	if test "x${REVISION}" != "x0"; then
17
		AC_MSG_RESULT([$REVISION])
18
		GEANY_STATUS_ADD([Compiling Git revision], [$REVISION])
19 20 21 22 23 24 25 26 27 28 29

		# call action-if-found
		$1
	else
		REVISION="-1"
		AC_MSG_RESULT([none])

		# call action-if-not-found
		$2
	fi

30
	AC_DEFINE_UNQUOTED([REVISION], "$REVISION", [git revision hash])
31
])