[DTrace-devel] [PATCH] configure: work when only env vars are specified

Nick Alcock nick.alcock at oracle.com
Tue Apr 9 14:52:28 UTC 2024


Specifying only env vars to configure claimed that build/config.h
was written even though it wasn't, then emitted a nonsense error
message from cat in configure when it tried to cat build/.config,
which also didn't exist.  Create both (as empty) in this case.

Also, a number of env vars that were meant to be overrideable
were initialized with = rather than ?= in the top-level GNUmakefile,
preventing them from being properly initialized from the .mk.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
 GNUmakefile |  6 +++---
 configure   | 10 ++++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index d967134faa627..4fc13e90239d5 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -110,7 +110,7 @@ DTRACE ?= $(objdir)/dtrace
 
 # Variables derived from the above.
 
-export CC = gcc
+export CC ?= gcc
 
 BITNESS := 64
 NATIVE_BITNESS_ONLY := $(shell echo 'int main (void) { }' | $(CC) -x c -o /dev/null -m32 - 2>/dev/null || echo t)
@@ -121,11 +121,11 @@ CPPFLAGS += -Iinclude -Iuts/common -Iinclude/$(ARCHINC) -I$(objdir)
 
 override CFLAGS += $(INVARIANT_CFLAGS)
 PREPROCESS = $(CC) -E
-export BPFC = bpf-unknown-none-gcc
+export BPFC ?= bpf-unknown-none-gcc
 
 BPFCPPFLAGS += -D$(subst sparc64,__sparc,$(subst aarch64,__aarch64__,$(subst x86_64,__amd64,$(ARCH))))
 BPFCFLAGS ?= -O2 -Wall -Wno-unknown-pragmas $(if $(HAVE_BPFV3),-mcpu=v3)
-export BPFLD = bpf-unknown-none-ld
+export BPFLD ?= bpf-unknown-none-ld
 
 all::
 
diff --git a/configure b/configure
index 312e2aa2cfa49..b9fd2076b9ea7 100755
--- a/configure
+++ b/configure
@@ -170,12 +170,14 @@ done
 
 echo 'Writing build/config-vars.mk'
 rm -f build/config-vars.mk
-[[ -f build/.config-vars.mk.new ]] && \
-   mv -f build/.config-vars.mk.new build/config-vars.mk
+[[ ! -f build/.config-vars.mk.new ]] && \
+  touch build/config-vars.mk
+mv -f build/.config-vars.mk.new build/config-vars.mk
 
 rm -rf build/.config
-[[ -d build/.config.new ]] && \
-    mv -f build/.config.new build/.config
+[[ ! -d build/.config.new ]] && \
+  mkdir -p build/.config.new
+mv -f build/.config.new build/.config
 
 # Arrange for build/config.{h,mk} to exist as soon as this
 # script ends, so that users can see that the files we said we

base-commit: 22b87f957ddd29226632ee0e14b2d548ee9cb015
-- 
2.44.0.273.ge0bd14271f




More information about the DTrace-devel mailing list