commit b3f4526f0aa457c8c1419e89ed9af1ac46dd006e
parent a929fd856478ec7cc17797a9310ef82366908d45
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 19 Jul 2023 11:58:59 +0200
Update Makefile targets of tests and .d files
The tests depend on the linker flags set in the config.mk file. This
dependency is not really necessary since these executables depend on
their object file which themselves depend on the config.mk file. So in
any case, their linking would be redone even without this change which
in all rigor remains necessary.
Like .o files, the .d files depend on the contents of the config.mk
file, including the value of build flags such as include directories to
search for headers and macro definitions. In addition, the .d files of
the tests no longer use the inference rule defined for the library and
now rely on its own targets with its own compilation flags used for its
compilation. If in practice this does not change anything, it is more
rigorous.
Diffstat:
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
@@ -38,14 +38,14 @@ OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
build_library: .config $(DEP)
- @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done)\
- $$(if [ -n "$(LIBNAME)" ]; then\
- echo "$(LIBNAME)";\
- else\
- echo "$(LIBNAME_SHARED)";\
- fi)
+ @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \
+ $$(if [ -n "$(LIBNAME)" ]; then\
+ echo "$(LIBNAME)";\
+ else\
+ echo "$(LIBNAME_SHARED)";\
+ fi)
-$(OBJ): config.mk
+$(DEP) $(OBJ): config.mk
$(LIBNAME_SHARED): $(OBJ)
$(CC) -std=c99 $(CFLAGS) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(SOFLAGS) $(DPDC_LIBS)
@@ -151,6 +151,9 @@ test: build_tests
clean_test:
@$(SHELL) make.sh clean_test $(TEST_SRC)
+$(TEST_DEP): config.mk s2d-local.pc
+ @$(CC) -std=c89 $(CFLAGS) $(S2D_CFLAGS) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
$(TEST_OBJ): config.mk s2d-local.pc
$(CC) -std=c89 $(CFLAGS) $(S2D_CFLAGS) -c $(@:.o=.c) -o $@
@@ -165,5 +168,5 @@ test_s2d_scene_view \
test_s2d_scene_view2 \
test_s2d_trace_ray \
test_s2d_trace_ray_3d \
-: s2d-local.pc
+: config.mk s2d-local.pc
$(CC) -o $@ src/$@.o $(LDFLAGS) $(S2D_LIBS) -lm