Skip to content

Commit dac076f

Browse files
flichtenheldcron2
authored andcommitted
configure: Allow to detect git checkout if .git is not a directory
E.g. if you use openvpn as a git submodule, it can be a file that points to the parent's git directory. The changes to Makefile.am are not strictly required, they still work with that case, but I wanted to keep the usage consistent. Change-Id: I9b7a3df012e7606ddb04a944e3fa33247180e8dd Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Arne Schwabe <[email protected]> Acked-by: Yuriy Darnobyt <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg29092.html Signed-off-by: Gert Doering <[email protected]>
1 parent 233e10a commit dac076f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ dist_noinst_DATA = \
7575
README.wolfssl
7676

7777
config-version.h:
78-
@CONFIGURE_GIT_CHFILES="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) diff-files --name-status -r --ignore-submodules --quiet -- || echo \"+\"`"; \
79-
CONFIGURE_GIT_UNCOMMITTED="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) diff-index --cached --quiet --ignore-submodules HEAD || echo \"*\"`"; \
80-
CONFIGURE_GIT_REVISION="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --symbolic-full-name HEAD | cut -d/ -f3-`/`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --short=16 HEAD`"; \
78+
@CONFIGURE_GIT_CHFILES="`$(GIT) -C \"$(top_srcdir)\" diff-files --name-status -r --ignore-submodules --quiet -- || echo \"+\"`"; \
79+
CONFIGURE_GIT_UNCOMMITTED="`$(GIT) -C \"$(top_srcdir)\" diff-index --cached --quiet --ignore-submodules HEAD || echo \"*\"`"; \
80+
CONFIGURE_GIT_REVISION="`$(GIT) -C \"$(top_srcdir)\" rev-parse --symbolic-full-name HEAD | cut -d/ -f3-`/`$(GIT) -C \"$(top_srcdir)\" rev-parse --short=16 HEAD`"; \
8181
echo "#define CONFIGURE_GIT_REVISION \"$${CONFIGURE_GIT_REVISION}\"" > config-version.h.tmp; \
8282
echo "#define CONFIGURE_GIT_FLAGS \"$${CONFIGURE_GIT_CHFILES}$${CONFIGURE_GIT_UNCOMMITTED}\"" >> config-version.h.tmp
8383

configure.ac

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,11 @@ fi
13081308

13091309
AC_MSG_CHECKING([git checkout])
13101310
GIT_CHECKOUT="no"
1311-
if test -n "${GIT}" -a -d "${srcdir}/.git"; then
1312-
AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h])
1313-
GIT_CHECKOUT="yes"
1311+
if test -n "${GIT}"; then
1312+
if ${GIT} -C "$srcdir" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
1313+
AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h])
1314+
GIT_CHECKOUT="yes"
1315+
fi
13141316
fi
13151317
AC_MSG_RESULT([${GIT_CHECKOUT}])
13161318

0 commit comments

Comments
 (0)