Re: [PATCH 1/2] Makefile: use order-only prereq for UNIT_TEST_BIN
SZEDER Gábor <szeder.dev@gmail.com> writes:
> A third alternative is to use $(call mkdir_p_parent_template) in the
> recipe and get rid of the thus unnecessary UNIT_TEST_BIN dependency
> and target.
Yeah, that sounds like a good approach in this case.
> On a related note, 'make clean' doesn't remove this 't/unit-tests/bin'
> directory.
Not a new problem, but I did notice this, too.
Thanks.
Makefile | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git c/Makefile w/Makefile
index 958f4cd0bf..7f035a1c9f 100644
--- c/Makefile
+++ w/Makefile
@@ -3676,7 +3676,7 @@ cocciclean:
$(RM) contrib/coccinelle/*.cocci.patch
clean: profile-clean coverage-clean cocciclean
- $(RM) -r .build
+ $(RM) -r .build $(UNIT_TEST_BIN)
$(RM) po/git.pot po/git-core.pot
$(RM) git.res
$(RM) $(OBJECTS)
@@ -3863,10 +3863,8 @@ $(FUZZ_PROGRAMS): all
fuzz-all: $(FUZZ_PROGRAMS)
-$(UNIT_TEST_BIN):
- @mkdir -p $(UNIT_TEST_BIN)
-
-$(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_DIR)/test-lib.o $(GITLIBS) GIT-LDFLAGS | $(UNIT_TEST_BIN)
+$(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_DIR)/test-lib.o $(GITLIBS) GIT-LDFLAGS
+ $(call mkdir_p_parent_template)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
$(filter %.o,$^) $(filter %.a,$^) $(LIBS)