[PATCH 1/2] GNUmakefile: add missing clean paths

1 view
Skip to first unread message

Rob Browning

unread,
Jul 1, 2026, 5:29:39 PM (3 days ago) Jul 1
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed to main.

GNUmakefile | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index d1d6a0cc..596a86cb 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -99,8 +99,10 @@ ifneq (0, $(.SHELLSTATUS))
endif
clean_paths += lib/bup/checkout_info.py

+# config.vars must be cleaned first (see clean: below)
config/config.vars: configure config/test/*.c
MAKE="$(MAKE)" ./configure
+clean_paths += config.log

# On some platforms, Python.h and readline.h fight over the
# _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
@@ -248,64 +250,80 @@ ld_bin = $(CC) $(LDFLAGS) $^ -o $@ $(embed_ldflags)
# common files to build for the binaries
src/bup/%.o: src/bup/%.c
$(cc_bin)
-clean_paths += src/bup/compat.o src/bup/io.o
generated_dependencies += src/bup/compat.d src/bup/io.d
+clean_paths += src/bup/compat.o src/bup/io.o

-clean_paths += dev/python-proposed dev/python-proposed.o
-generated_dependencies += dev/python-proposed.d
dev/python-proposed.o: dev/python.c
$(cc_bin)
+generated_dependencies += dev/python-proposed.d
+clean_paths += dev/python-proposed.o
+
dev/python-proposed: dev/python-proposed.o src/bup/compat.o src/bup/io.o
rm -f dev/python
$(ld_bin)
+clean_paths += dev/python-proposed

-clean_paths += dev/python
dev/python: dev/python-proposed
dev/validate-python $@-proposed
cp -R -p $@-proposed $@
+clean_paths += dev/python

-clean_paths += dev/bup-exec
-generated_dependencies += dev/bup-exec.d
dev/bup-exec.o: bup_common_cflags += -D BUP_DEV_BUP_EXEC=1
dev/bup-exec.o: lib/cmd/bup.c
$(cc_bin)
+generated_dependencies += dev/bup-exec.d
+clean_paths += dev/bup-exec.o
+
dev/bup-exec: dev/bup-exec.o src/bup/compat.o src/bup/io.o
$(ld_bin)
+clean_paths += dev/bup-exec

-clean_paths += dev/bup-python
-generated_dependencies += dev/bup-python.d
dev/bup-python.o: bup_common_cflags += -D BUP_DEV_BUP_PYTHON=1
dev/bup-python.o: lib/cmd/bup.c
$(cc_bin)
+generated_dependencies += dev/bup-python.d
+clean_paths += dev/bup-python.o
+
dev/bup-python: dev/bup-python.o src/bup/compat.o src/bup/io.o
$(ld_bin)
+clean_paths += dev/bup-python

-clean_paths += lib/cmd/bup
-generated_dependencies += lib/cmd/bup.d
lib/cmd/bup.o: lib/cmd/bup.c
$(cc_bin)
+generated_dependencies += lib/cmd/bup.d
+clean_paths += lib/cmd/bup.o
+
lib/cmd/bup: lib/cmd/bup.o src/bup/compat.o src/bup/io.o
$(ld_bin)
+clean_paths += lib/cmd/bup

cc_helpers = $(CC) -fPIC $(helpers_cflags) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
ld_helpers = $(CC) -fPIC $^ -o $@ $(helpers_ldflags) $(LDFLAGS)

lib/bup/%.o: lib/bup/%.c
$(cc_helpers)
+
src/bup/pyutil.o: src/bup/pyutil.c
$(cc_helpers)
+generated_dependencies += src/bup/pyutil.d
+clean_paths += src/bup/pyutil.o
+
+helpers_c := $(addprefix lib/bup/,_hashsplit.c _helpers.c bupsplit.c)
+helpers_objs := $(helpers_c:.c=.o)

-clean_paths += lib/bup/_helpers$(soext) lib/bup/_helpers.o
-generated_dependencies += lib/bup/_helpers.d src/bup/pyutil.d lib/bup/bupsplit.d lib/bup/_hashsplit.d
-lib/bup/_helpers$(soext): lib/bup/_helpers.o src/bup/pyutil.o lib/bup/bupsplit.o lib/bup/_hashsplit.o
+lib/bup/_helpers$(soext): $(helpers_objs) src/bup/pyutil.o
$(ld_helpers)
+generated_dependencies += $(helpers_c:.c=.d)
+clean_paths += lib/bup/_helpers$(soext) $(helpers_objs)

-clean_paths += src/bup/test-pyutil.o test/ext/test-pyutil
-generated_dependencies += src/bup/test-pyutil.d
src/bup/test-%.o: src/bup/test-%.c
$(cc_bin)
+generated_dependencies += src/bup/test-pyutil.d
+clean_paths += src/bup/test-pyutil.o
+
test/ext/test-%: src/bup/test-%.o src/bup/pyutil.o
$(ld_bin)
+clean_paths += test/ext/test-pyutil

test/tmp:
mkdir test/tmp
@@ -366,7 +384,7 @@ Documentation/substvars.current: $(bup_deps)
"s,%BUP_DATE%,$$bup_date,g") > $@
Documentation/substvars: Documentation/substvars.current
@cmp $@ $< || cp $< $@
-doc_clean_paths += substvars substvars.current
+doc_clean_paths += Documentation/substvars Documentation/substvars.current

define render_page
$(pf); sed -f Documentation/substvars $< \
--
2.47.3

Rob Browning

unread,
Jul 1, 2026, 5:29:40 PM (3 days ago) Jul 1
to bup-...@googlegroups.com
Build common and helpers object files via static pattern rule, and
simplify the helpers flag handling. Just include the flags (like
those for readline) unconditionally, relying on them to be empty when
not set. These adjustments should also make it easier to add
additional modules.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed to main.

GNUmakefile | 128 ++++++++++++++--------------
configure | 2 +
dev/{python.c => python-proposed.c} | 0
3 files changed, 66 insertions(+), 64 deletions(-)
rename dev/{python.c => python-proposed.c} (100%)

diff --git a/GNUmakefile b/GNUmakefile
index 596a86cb..14e7dd02 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -46,6 +46,10 @@ ifneq (0, $(.SHELLSTATUS))
bup_config_cflags ?=
bup_config_ldflags_so ?=
bup_have_acls ?=
+ bup_libacl_cflags ?=
+ bup_libacl_ldflags ?=
+ bup_python_cflags ?=
+ bup_python_cflags_embed ?=
bup_python_ldflags ?=
bup_python_ldflags_embed ?=
bup_readline_cflags ?=
@@ -108,24 +112,13 @@ clean_paths += config.log
# _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
# now, we're just going to let Python's version win.

-helpers_cflags = $(bup_python_cflags) $(bup_common_cflags) -I$(CURDIR)/src
-helpers_ldflags := $(bup_python_ldflags) $(bup_common_ldflags)
-helpers_ldflags += $(bup_config_ldflags_so)
-
ifneq ($(strip $(bup_readline_cflags)),)
- readline_cflags += $(bup_readline_cflags)
+ readline_cflags = $(bup_readline_cflags)
readline_xopen := $(filter -D_XOPEN_SOURCE=%,$(readline_cflags))
readline_xopen := $(subst -D_XOPEN_SOURCE=,,$(readline_xopen))
readline_cflags := $(filter-out -D_XOPEN_SOURCE=%,$(readline_cflags))
readline_cflags += $(addprefix -DBUP_RL_EXPECTED_XOPEN_SOURCE=,$(readline_xopen))
- helpers_cflags += $(readline_cflags)
-endif
-
-helpers_ldflags += $(bup_readline_ldflags)
-
-ifeq ($(bup_have_acls),1)
- helpers_cflags += $(bup_libacl_cflags)
- helpers_ldflags += $(bup_libacl_ldflags)
+ bup_readline_cflags = $(readline_cflags)
endif

bup_ext_cmds := lib/cmd/bup-import-rdiff-backup lib/cmd/bup-import-rsnapshot
@@ -241,26 +234,62 @@ install: all
$(INSTALL) -pm 0644 lib/bup/source_info.py $(dest_libdir)/bup/; \
fi

-embed_cflags = -fPIE $(bup_python_cflags_embed) $(bup_common_cflags) -I$(CURDIR)/src
-embed_ldflags := -pie $(bup_python_ldflags_embed) $(bup_common_ldflags)
+# So we don't have to build different .o flavors
+ifneq ($(bup_python_cflags),$(bup_python_cflags_embed))
+ $(error --embed alters python-config --cflags)
+endif
+
+# Must not be := assignments (would break target-specific adjustments)
+py_cflags = -fPIC $(bup_python_cflags) $(bup_common_cflags) -I$(CURDIR)/src
+py_mod_ldflags = -fPIC $(bup_python_ldflags) $(bup_common_ldflags) $(bup_config_ldflags_so)
+py_embed_ldflags = -fPIC -pie $(bup_python_ldflags_embed) $(bup_common_ldflags)
+
+cc_py_obj = $(CC) $(py_cflags) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+ld_py_bin = $(CC) $(LDFLAGS) $^ -o $@ $(py_embed_ldflags)
+
+
+## common object files and tests
+
+common_obj := \
+ dev/python-proposed.o \
+ lib/cmd/bup.o \
+ src/bup/compat.o \
+ src/bup/io.o \
+ src/bup/pyutil.o \
+ src/bup/test-pyutil.o
+
+$(common_obj): %.o: %.c
+ $(cc_py_obj)
+generated_dependencies += $(common_obj:.o=.d)
+clean_paths += $(common_obj)
+
+test/ext/test-pyutil: src/bup/test-pyutil.o src/bup/pyutil.o
+ $(ld_py_bin)
+clean_paths += test/ext/test-pyutil
+

-cc_bin = $(CC) $(embed_cflags) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-ld_bin = $(CC) $(LDFLAGS) $^ -o $@ $(embed_ldflags)
+## _helpers.so

-# common files to build for the binaries
-src/bup/%.o: src/bup/%.c
- $(cc_bin)
-generated_dependencies += src/bup/compat.d src/bup/io.d
-clean_paths += src/bup/compat.o src/bup/io.o
+helpers_cflags := $(py_cflags) $(bup_readline_cflags) $(bup_libacl_cflags)
+helpers_ldflags := $(py_mod_ldflags) $(bup_readline_ldflags) $(bup_libacl_ldflags)

-dev/python-proposed.o: dev/python.c
- $(cc_bin)
-generated_dependencies += dev/python-proposed.d
-clean_paths += dev/python-proposed.o
+helpers_o := lib/bup/_hashsplit.o lib/bup/_helpers.o lib/bup/bupsplit.o
+
+$(helpers_o): %.o: %.c
+ $(CC) $(helpers_cflags) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+generated_dependencies += $(helpers_o:.o=.d)
+clean_paths += $(helpers_o)
+
+lib/bup/_helpers$(soext): $(helpers_o) src/bup/pyutil.o
+ $(CC) $^ -o $@ $(helpers_ldflags) $(LDFLAGS)
+clean_paths += lib/bup/_helpers$(soext)
+
+
+## dev/python

dev/python-proposed: dev/python-proposed.o src/bup/compat.o src/bup/io.o
rm -f dev/python
- $(ld_bin)
+ $(ld_py_bin)
clean_paths += dev/python-proposed

dev/python: dev/python-proposed
@@ -268,62 +297,33 @@ dev/python: dev/python-proposed
cp -R -p $@-proposed $@
clean_paths += dev/python

+
+## bup.c variants (bup bup-exec bup-python)
+
dev/bup-exec.o: bup_common_cflags += -D BUP_DEV_BUP_EXEC=1
dev/bup-exec.o: lib/cmd/bup.c
- $(cc_bin)
+ $(cc_py_obj)
generated_dependencies += dev/bup-exec.d
clean_paths += dev/bup-exec.o

dev/bup-exec: dev/bup-exec.o src/bup/compat.o src/bup/io.o
- $(ld_bin)
+ $(ld_py_bin)
clean_paths += dev/bup-exec

dev/bup-python.o: bup_common_cflags += -D BUP_DEV_BUP_PYTHON=1
dev/bup-python.o: lib/cmd/bup.c
- $(cc_bin)
+ $(cc_py_obj)
generated_dependencies += dev/bup-python.d
clean_paths += dev/bup-python.o

dev/bup-python: dev/bup-python.o src/bup/compat.o src/bup/io.o
- $(ld_bin)
+ $(ld_py_bin)
clean_paths += dev/bup-python

-lib/cmd/bup.o: lib/cmd/bup.c
- $(cc_bin)
-generated_dependencies += lib/cmd/bup.d
-clean_paths += lib/cmd/bup.o
-
lib/cmd/bup: lib/cmd/bup.o src/bup/compat.o src/bup/io.o
- $(ld_bin)
+ $(ld_py_bin)
clean_paths += lib/cmd/bup

-cc_helpers = $(CC) -fPIC $(helpers_cflags) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-ld_helpers = $(CC) -fPIC $^ -o $@ $(helpers_ldflags) $(LDFLAGS)
-
-lib/bup/%.o: lib/bup/%.c
- $(cc_helpers)
-
-src/bup/pyutil.o: src/bup/pyutil.c
- $(cc_helpers)
-generated_dependencies += src/bup/pyutil.d
-clean_paths += src/bup/pyutil.o
-
-helpers_c := $(addprefix lib/bup/,_hashsplit.c _helpers.c bupsplit.c)
-helpers_objs := $(helpers_c:.c=.o)
-
-lib/bup/_helpers$(soext): $(helpers_objs) src/bup/pyutil.o
- $(ld_helpers)
-generated_dependencies += $(helpers_c:.c=.d)
-clean_paths += lib/bup/_helpers$(soext) $(helpers_objs)
-
-src/bup/test-%.o: src/bup/test-%.c
- $(cc_bin)
-generated_dependencies += src/bup/test-pyutil.d
-clean_paths += src/bup/test-pyutil.o
-
-test/ext/test-%: src/bup/test-%.o src/bup/pyutil.o
- $(ld_bin)
-clean_paths += test/ext/test-pyutil

test/tmp:
mkdir test/tmp
diff --git a/configure b/configure
index 85b9349a..74650f1f 100755
--- a/configure
+++ b/configure
@@ -402,6 +402,8 @@ then
c_define[BUP_HAVE_ACLS]=1
info ' (found)'
else
+ bup_libacl_cflags=
+ bup_libacl_ldflags=
info ' (not found)'
fi

diff --git a/dev/python.c b/dev/python-proposed.c
similarity index 100%
rename from dev/python.c
rename to dev/python-proposed.c
--
2.47.3

Reply all
Reply to author
Forward
0 new messages