Avoid running $(CXX) during build to obtain header file paths
authorFlorian Weimer <fweimer@redhat.com>
Wed, 21 Sep 2016 08:45:32 +0000 (10:45 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 21 Sep 2016 08:45:32 +0000 (10:45 +0200)
This reduces the build time somewhat and is particularly noticeable
during rebuilds with few code changes.

ChangeLog
Makerules
config.make.in
configure
configure.ac

index 71fed8f..12a217a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2016-09-21  Florian Weimer  <fweimer@redhat.com>
 
+       Avoid running $(CXX) during build to obtain header file paths.
+       * configure.ac (CXX_SYSINCLUDES, CXX_CMATH_HEADER): Set.
+       * config.make.in (c++-cstdlib-header, c++-cmath-header): Define.
+       * Makerules (cstdlib, cmath): Remove variables.  Use
+       $(c++-cstdlib-header), $(c++-cmath-header) instead.
+       * configure: Regenerate.
+
+2016-09-21  Florian Weimer  <fweimer@redhat.com>
+
        * Makeconfig (all-object-suffixes): Include .op only if
        $(build-profile).
 
index 748790b..e865782 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -121,14 +121,10 @@ ifneq (,$(CXX))
 # will be used instead of /usr/include/stdlib.h and /usr/include/math.h.
 before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \
                  $(before-compile)
-cstdlib=$(shell echo "\#include <cstdlib>" | $(CXX) -M -MP -x c++ - \
-               | sed -n "/cstdlib:/{s/:$$//;p}")
-$(common-objpfx)cstdlib: $(cstdlib)
+$(common-objpfx)cstdlib: $(c++-cstdlib-header)
        $(INSTALL_DATA) $< $@T
        $(move-if-change) $@T $@
-cmath=$(shell echo "\#include <cmath>" | $(CXX) -M -MP -x c++ - \
-               | sed -n "/cmath:/{s/:$$//;p}")
-$(common-objpfx)cmath: $(cmath)
+$(common-objpfx)cmath: $(c++-cmath-header)
        $(INSTALL_DATA) $< $@T
        $(move-if-change) $@T $@
 endif
index 95c6f36..04a8b3e 100644 (file)
@@ -45,6 +45,8 @@ defines = @DEFINES@
 sysheaders = @sysheaders@
 sysincludes = @SYSINCLUDES@
 c++-sysincludes = @CXX_SYSINCLUDES@
+c++-cstdlib-header = @CXX_CSTDLIB_HEADER@
+c++-cmath-header = @CXX_CMATH_HEADER@
 all-warnings = @all_warnings@
 enable-werror = @enable_werror@
 
index 17625e1..6ff2527 100755 (executable)
--- a/configure
+++ b/configure
@@ -635,6 +635,8 @@ BISON
 INSTALL_INFO
 PERL
 BASH_SHELL
+CXX_CMATH_HEADER
+CXX_CSTDLIB_HEADER
 CXX_SYSINCLUDES
 SYSINCLUDES
 AUTOCONF
@@ -5054,6 +5056,18 @@ fi
 
 
 
+# Obtain some C++ header file paths.  This is used to make a local
+# copy of those headers in Makerules.
+if test -n "$CXX"; then
+  find_cxx_header () {
+    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}"
+  }
+  CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
+  CXX_CMATH_HEADER="$(find_cxx_header cmath)"
+fi
+
+
+
 # Test if LD_LIBRARY_PATH contains the notation for the current directory
 # since this would lead to problems installing/building glibc.
 # LD_LIBRARY_PATH contains the current directory if one of the following
index 33bcd62..9938ab0 100644 (file)
@@ -1039,6 +1039,18 @@ fi
 AC_SUBST(SYSINCLUDES)
 AC_SUBST(CXX_SYSINCLUDES)
 
+# Obtain some C++ header file paths.  This is used to make a local
+# copy of those headers in Makerules.
+if test -n "$CXX"; then
+  find_cxx_header () {
+    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}"
+  }
+  CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
+  CXX_CMATH_HEADER="$(find_cxx_header cmath)"
+fi
+AC_SUBST(CXX_CSTDLIB_HEADER)
+AC_SUBST(CXX_CMATH_HEADER)
+
 # Test if LD_LIBRARY_PATH contains the notation for the current directory
 # since this would lead to problems installing/building glibc.
 # LD_LIBRARY_PATH contains the current directory if one of the following