Build: Make dependency on git change more robust

It can sometimes happen that .git/HEAD or .git/refs/head/*, which
are added as config.status dependencies during configure, do not
exist anymore at build time.  For instance, when the current branch
is deleted after switching to a different one.

Wrap the dependencies inside $(wildcard ...) to avoid this problem.
Note that this is a GNU make feature.  However, it should be fine
as it is only used for git builds.  Even if a non-GNU make is used,
the construct will hopefully just expand to nothing.
This commit is contained in:
Daniel Elstner 2015-08-17 02:08:39 +02:00
parent 965d68898a
commit 7c16e74d45
1 changed files with 8 additions and 2 deletions

View File

@ -69,10 +69,16 @@ SR_PACKAGE_VERSION="AC_PACKAGE_VERSION"
sr_head=`git -C "$srcdir" rev-parse --verify --short HEAD 2>&AS_MESSAGE_LOG_FD`
AS_IF([test "$?" -eq 0 && test -n "$sr_head"], [
CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/.git/HEAD'
sr_git_deps=
test ! -f "$srcdir/.git/HEAD" || sr_git_deps=' $(top_srcdir)/.git/HEAD'
sr_head_name=`git -C "$srcdir" rev-parse --symbolic-full-name HEAD 2>&AS_MESSAGE_LOG_FD`
AS_IF([test "$?" -eq 0 && test -f "$srcdir/.git/$sr_head_name"],
[CONFIG_STATUS_DEPENDENCIES="$CONFIG_STATUS_DEPENDENCIES \$(top_srcdir)/.git/$sr_head_name"])
[sr_git_deps="$sr_git_deps \$(top_srcdir)/.git/$sr_head_name"])
# Use $(wildcard) so that things do not break if for whatever
# reason these files do not exist anymore at make time.
test -z "$sr_git_deps" || CONFIG_STATUS_DEPENDENCIES="\$(wildcard$sr_git_deps)"
# Append the revision hash unless we are exactly on a tagged release.
git -C "$srcdir" describe --match 'AC_PACKAGE_NAME-AC_PACKAGE_VERSION' \