commit 600bb761f42e2a75f49a8ad9693236631c445ed8
parent be3b10da67530b25097dba01d3b7ec973248333a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 19 Jul 2023 12:12:57 +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.
The explicit dependency of the .o and .d test files to their
corresponding source is removed since it is defined in the .d file.
Do not use the "$<" macro when compiling tests because its meaning is
undefined elsewhere than in inference rules.
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
@@ -140,10 +140,13 @@ test: build_tests
clean_test:
rm -f test_s3daw cbox.mtl cbox2.mtl cbox.obj
-$(TEST_OBJ) $(TEST_DEP): config.mk
+$(TEST_OBJ) $(TEST_DEP): config.mk s3daw-local.pc
-src/test_s3daw.o: src/test_s3daw.c s3daw-local.pc
- $(CC) $(CFLAGS) $(S3D_CFLAGS) $(S3DAW_CFLAGS) $(RSYS_CFLAGS) -c $< -o $@
+src/test_s3daw.d: config.mk s3daw-local.pc
+ @$(CC) $(CFLAGS) $(S3D_CFLAGS) $(S3DAW_CFLAGS) $(RSYS_CFLAGS) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
-test_s3daw: src/test_s3daw.o s3daw-local.pc
+src/test_s3daw.o: config.mk s3daw-local.pc
+ $(CC) $(CFLAGS) $(S3D_CFLAGS) $(S3DAW_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@
+
+test_s3daw: src/test_s3daw.o config.mk s3daw-local.pc
$(CC) -o $@ src/$@.o $(S3D_LIBS) $(S3DAW_LIBS) $(RSYS_LIBS)