From: Daniel Elstner Date: Mon, 17 Aug 2015 00:08:39 +0000 (+0200) Subject: Build: Make dependency on git change more robust X-Git-Tag: libsigrok-0.4.0~425 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=7c16e74d45b91123206efee2116d86462c8e707c 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. --- diff --git a/configure.ac b/configure.ac index cd563c18..6a692b20 100644 --- a/configure.ac +++ b/configure.ac @@ -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' \