]> arthur.barton.de Git - bup.git/commitdiff
Respect/prefer/remember user specified CPPFLAGS/CFLAGS/LDFLAGS
authorRob Browning <rlb@defaultvalue.org>
Sun, 22 May 2022 17:20:10 +0000 (12:20 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 25 Jun 2022 18:26:11 +0000 (13:26 -0500)
While we remembered a configure-time CC, we didn't do the same for
other common user specified build variables, i.e. CPPFLAGS, CFLAGS,
and LDFLAGS.  Fix that, and arrange for the user's values to come
last so that they can override the configuration values.

This matches expectations established by other tools, in particular
autoconf/automake, and avoids having to remember to specify overrides
to every invocation of make.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
GNUmakefile
README.md
config/config.vars.in

index a6335ae7840bc250e7a8324fdc213cad0ec1e627..48725d2f5413659dad5d374f1ac6d0f558697d41 100644 (file)
@@ -1,6 +1,5 @@
 
 MAKEFLAGS += --warn-undefined-variables
-OUTPUT_OPTION = -MMD -MP -o $@
 
 SHELL := bash
 .DEFAULT_GOAL := all
@@ -32,14 +31,13 @@ current_sampledata := test/sampledata/var/rev/v$(sampledata_rev)
 os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok))
 os := $(call shout,$(os),Unable to determine OS)
 
+# CFLAGS CPPFLAGS LDFLAGS are handled vis config/config.vars.in
+
 # Satisfy --warn-undefined-variables
-CFLAGS ?=
 DESTDIR ?=
-CPPFLAGS ?=
-LDFLAGS ?=
 TARGET_ARCH ?=
 
-bup_shared_cflags := -O2 -Wall -Werror -Wformat=2
+bup_shared_cflags := -O2 -Wall -Werror -Wformat=2 -MMD -MP
 bup_shared_cflags := -Wno-unknown-pragmas -Wsign-compare $(bup_shared_cflags)
 bup_shared_cflags := -D_FILE_OFFSET_BITS=64 $(bup_shared_cflags)
 bup_shared_cflags := $(bup_config_cflags) $(bup_shared_cflags)
@@ -160,8 +158,8 @@ embed_ldflags := $(bup_python_ldflags_embed) $(bup_shared_ldflags)
 config/config.h: config/config.vars
 clean_paths += config/config.h.tmp
 
-cc_bin = $(CC) $(embed_cflags) $(CFLAGS) $^ $(embed_ldflags) $(LDFLAGS) -fPIE \
-  -I src $(OUTPUT_OPTION)
+cc_bin = $(CC) $(embed_cflags) -I src $(CPPFLAGS) $(CFLAGS) $^ \
+  $(embed_ldflags) $(LDFLAGS) -fPIE -o $@
 
 clean_paths += dev/python-proposed
 generated_dependencies += dev/python-proposed.d
@@ -194,8 +192,8 @@ lib/cmd/bup: lib/cmd/bup.c src/bup/compat.c src/bup/io.c
 clean_paths += lib/bup/_helpers$(soext)
 generated_dependencies += lib/bup/_helpers.d
 lib/bup/_helpers$(soext): lib/bup/_helpers.c lib/bup/bupsplit.c
-       $(CC) $(helpers_cflags) $(CFLAGS) $^ \
-         $(helpers_ldflags) $(LDFLAGS) $(OUTPUT_OPTION)
+       $(CC) $(helpers_cflags) $(CPPFLAGS) $(CFLAGS) $^ \
+         $(helpers_ldflags) $(LDFLAGS) -o $@
 
 test/tmp:
        mkdir test/tmp
index c88116dde26e6ef37ea3afce28549e3b0e996533..53f84d2f3533ab87c2c7c90163616e5f1c0f2194 100644 (file)
--- a/README.md
+++ b/README.md
@@ -222,6 +222,13 @@ From source
    `config/config.var/bup-python-config`, and you can change the
    selection by re-running `./configure`.
 
+- If you want to specify your own `CPPFLAGS`, `CFLAGS`, or `LDFLAGS`,
+  you can set them for individual `make` invocations, e.g. `make
+  CFLAGS=-O0 check`, or persistently via `./configure` with
+  `CFLAGS=-O0 ./configure`.  At the moment, `make clean` clears the
+  configuration, but we may change that at some point, perhaps by
+  adding and requiring a `make distclean` to clear the configuration.
+
 From binary packages
 --------------------
 
index 4101ed3896770e4d0d2d1d36968c27a6acd3e7a9..f354e5f50f3b5f0fc1a5e99c299d6a0e05036dcd 100644 (file)
@@ -2,6 +2,10 @@ CONFIGURE_FILES=@CONFIGURE_FILES@
 GENERATED_FILES=@GENERATED_FILES@
 
 CC = @CC@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+
 bup_config_cflags = @bup_config_cflags@
 bup_make=@bup_make@