[PATCH] configure: detect version by compiler for build

Subject: [PATCH] configure: detect version by compiler for build

Date: Mon, 27 Jul 2020 22:41:05 +0700

To: notmuch@notmuchmail.org

Cc: Đoàn Trần Công Danh

From: Đoàn Trần Công Danh


We'll need to run the compiled binary to report our current version.

With the same code base, we should have the same version information
regardless of compiler and architecture.

Let's use the compiler for building architecture to build the reporting
binary. Which is usually reported under variable CC_FOR_BUILD,
a convention established by GNU Autotools, and fall back to CC if it's
not defined.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 98f5f1ea..db3538b3 100755
--- a/configure
+++ b/configure
@@ -85,8 +85,10 @@ fi
 BASHCMD=${BASHCMD:-bash}
 PERL=${PERL:-perl}
 CC=${CC:-cc}
+CC_FOR_BUILD=${CC_FOR_BUILD:-$CC}
 CXX=${CXX:-c++}
 CFLAGS=${CFLAGS:--g -O2}
+CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD:-$CFLAGS}
 CPPFLAGS=${CPPFLAGS:-}
 CXXFLAGS_for_sh=${CXXFLAGS:-${CFLAGS}}
 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
@@ -410,7 +412,7 @@ int main(void) {
     return 0;
 }
 EOF
-if ${CC} ${CFLAGS} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \
+if ${CC_FOR_BUILD} ${CFLAGS_FOR_BUILD} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \
        && ./_libversion > _libversion.sh && . ./_libversion.sh
 then
     printf "OK.\n"
-- 
2.28.0.rc2.21.g5c06d60fc5
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: