From bed341992592581fde80bf59f023137678d641b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 23 Feb 2021 12:41:27 +0100 Subject: [PATCH 1/5] Makefile: guard against TEST_OBJS in the environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add TEST_OBJS to the list of other *_OBJS variables we reset. We had already established this pattern when TEST_OBJS was introduced in daa99a91729 (Makefile: make sure test helpers are rebuilt when headers change, 2010-01-26), but it wasn't added to the list in that commit along with the rest. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 4edfda3e009d5b..588f75c3a0d3ea 100644 --- a/Makefile +++ b/Makefile @@ -591,6 +591,7 @@ SCRIPT_PYTHON = SCRIPT_SH = SCRIPT_LIB = TEST_BUILTINS_OBJS = +TEST_OBJS = TEST_PROGRAMS_NEED_X = THIRD_PARTY_SOURCES = From 752b3ef972e3f28626cf92332380dc093441aa80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 23 Feb 2021 12:41:28 +0100 Subject: [PATCH 2/5] Makefile: split up long OBJECTS line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split up the long OBJECTS line into multiple lines using the "+=" assignment we commonly use elsewhere in the Makefile when these lines get unwieldy. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 588f75c3a0d3ea..ba21075d7ce3e9 100644 --- a/Makefile +++ b/Makefile @@ -583,6 +583,7 @@ EXTRA_CPPFLAGS = FUZZ_OBJS = FUZZ_PROGRAMS = LIB_OBJS = +OBJECTS = PROGRAM_OBJS = PROGRAMS = EXCLUDED_PROGRAMS = @@ -2386,11 +2387,15 @@ XDIFF_OBJS += xdiff/xprepare.o XDIFF_OBJS += xdiff/xutils.o TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) -OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \ - $(XDIFF_OBJS) \ - $(FUZZ_OBJS) \ - common-main.o \ - git.o + +OBJECTS += $(LIB_OBJS) +OBJECTS += $(BUILTIN_OBJS) +OBJECTS += $(PROGRAM_OBJS) +OBJECTS += $(TEST_OBJS) +OBJECTS += $(XDIFF_OBJS) +OBJECTS += $(FUZZ_OBJS) +OBJECTS += common-main.o +OBJECTS += git.o ifndef NO_CURL OBJECTS += http.o http-walker.o remote-curl.o endif From d6da8b328e83337d866502ff308e9a7b30209466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 23 Feb 2021 12:41:29 +0100 Subject: [PATCH 3/5] Makefile: sort OBJECTS assignment for subsequent change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the order of the OBJECTS assignment, this makes a follow-up change where we split it up into two variables smaller. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ba21075d7ce3e9..da26a5d3506044 100644 --- a/Makefile +++ b/Makefile @@ -2390,12 +2390,12 @@ TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST OBJECTS += $(LIB_OBJS) OBJECTS += $(BUILTIN_OBJS) +OBJECTS += common-main.o +OBJECTS += git.o OBJECTS += $(PROGRAM_OBJS) OBJECTS += $(TEST_OBJS) OBJECTS += $(XDIFF_OBJS) OBJECTS += $(FUZZ_OBJS) -OBJECTS += common-main.o -OBJECTS += git.o ifndef NO_CURL OBJECTS += http.o http-walker.o remote-curl.o endif From abc3c87f3d08e7d3adf7ff1e034d99b10a9420cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 23 Feb 2021 12:41:30 +0100 Subject: [PATCH 4/5] Makefile: split OBJECTS into OBJECTS and GIT_OBJS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new GIT_OBJS variable, with the objects sufficient to get to a git.o or common-main.o. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index da26a5d3506044..7e24da7aaeeb72 100644 --- a/Makefile +++ b/Makefile @@ -582,6 +582,7 @@ GENERATED_H = EXTRA_CPPFLAGS = FUZZ_OBJS = FUZZ_PROGRAMS = +GIT_OBJS = LIB_OBJS = OBJECTS = PROGRAM_OBJS = @@ -2388,10 +2389,12 @@ XDIFF_OBJS += xdiff/xutils.o TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) -OBJECTS += $(LIB_OBJS) -OBJECTS += $(BUILTIN_OBJS) -OBJECTS += common-main.o -OBJECTS += git.o +GIT_OBJS += $(LIB_OBJS) +GIT_OBJS += $(BUILTIN_OBJS) +GIT_OBJS += common-main.o +GIT_OBJS += git.o + +OBJECTS += $(GIT_OBJS) OBJECTS += $(PROGRAM_OBJS) OBJECTS += $(TEST_OBJS) OBJECTS += $(XDIFF_OBJS) From 029bac01a87ec8c3f569199c1c3ce71c21c6a161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 23 Feb 2021 12:41:31 +0100 Subject: [PATCH 5/5] Makefile: add {program,xdiff,test,git,fuzz}-objs & objects targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add targets to compile the various *.o files we declared in commonly used *_OBJS variables. This is useful for debugging purposes, to e.g. get to the point where we can compile a git.o. See [1] for a use-case for this target. https://lore.kernel.org/git/YBCGtd9if0qtuQxx@coredump.intra.peff.net/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 7e24da7aaeeb72..452aca4501413a 100644 --- a/Makefile +++ b/Makefile @@ -669,6 +669,8 @@ ETAGS_TARGET = TAGS FUZZ_OBJS += fuzz-commit-graph.o FUZZ_OBJS += fuzz-pack-headers.o FUZZ_OBJS += fuzz-pack-idx.o +.PHONY: fuzz-objs +fuzz-objs: $(FUZZ_OBJS) # Always build fuzz objects even if not testing, to prevent bit-rot. all:: $(FUZZ_OBJS) @@ -686,6 +688,8 @@ PROGRAM_OBJS += http-backend.o PROGRAM_OBJS += imap-send.o PROGRAM_OBJS += sh-i18n--envsubst.o PROGRAM_OBJS += shell.o +.PHONY: program-objs +program-objs: $(PROGRAM_OBJS) # Binary suffix, set to .exe for Windows builds X = @@ -2386,13 +2390,19 @@ XDIFF_OBJS += xdiff/xmerge.o XDIFF_OBJS += xdiff/xpatience.o XDIFF_OBJS += xdiff/xprepare.o XDIFF_OBJS += xdiff/xutils.o +.PHONY: xdiff-objs +xdiff-objs: $(XDIFF_OBJS) TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) +.PHONY: test-objs +test-objs: $(TEST_OBJS) GIT_OBJS += $(LIB_OBJS) GIT_OBJS += $(BUILTIN_OBJS) GIT_OBJS += common-main.o GIT_OBJS += git.o +.PHONY: git-objs +git-objs: $(GIT_OBJS) OBJECTS += $(GIT_OBJS) OBJECTS += $(PROGRAM_OBJS) @@ -2402,6 +2412,8 @@ OBJECTS += $(FUZZ_OBJS) ifndef NO_CURL OBJECTS += http.o http-walker.o remote-curl.o endif +.PHONY: objects +objects: $(OBJECTS) dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d) dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))