commit f28272a8e0ddcb065acebf4985932d36b4ca9677
parent 7669e79a1db82627200fac5693229a6bd820b047
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 30 Mar 2025 11:42:56 +0200
Make test compilation more robust
These tests check internal functions. They cannot therefore access these
functions via the command library API. This is why test executables
must, in all cases, be linked to all the library's object files.
Diffstat:
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Makefile.combustion b/Makefile.combustion
@@ -111,8 +111,8 @@ TEST_SRC = src/combustion/test_htrdr_combustion_laser.c
TEST_OBJ = $(TEST_SRC:.c=.o)
TEST_DEP = $(TEST_SRC:.c=.d)
-CFLAGS_TEST = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-combustion rsys)
-LDFLAGS_TEST = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-combustion rsys)
+CFLAGS_TEST = $(CFLAGS_EXE) $(COMBUSTION_INCS)
+LDFLAGS_TEST = $(LDFLAGS_EXE) $(COMBUSTION_LIBS)
test: tests
./test_htrdr_combustion_laser > /dev/null 2>&1
@@ -120,8 +120,10 @@ test: tests
tests: library $(TEST_DEP)
@$(MAKE) -fMakefile.combustion -f$(TEST_DEP) test_htrdr_combustion_laser
+# Link with all obj files in the combustion library since the test checks
+# hidden functions
test_htrdr_combustion_laser: $(TEST_OBJ)
- $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) src/combustion/htrdr_combustion_laser.o $(LDFLAGS_TEST)
+ $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) $(OBJ) $(LDFLAGS_TEST)
$(TEST_DEP):
@$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
diff --git a/Makefile.planets b/Makefile.planets
@@ -114,8 +114,8 @@ TEST_SRC = src/planets/test_htrdr_planets_source.c
TEST_OBJ = $(TEST_SRC:.c=.o)
TEST_DEP = $(TEST_SRC:.c=.d)
-CFLAGS_TEST = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-planets rsys)
-LDFLAGS_TEST = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-planets rsys)
+CFLAGS_TEST = $(CFLAGS_EXE) $(PLANETS_INCS)
+LDFLAGS_TEST = $(LDFLAGS_EXE) $(PLANETS_LIBS)
test: tests
./test_htrdr_planets_source > /dev/null 2>&1
@@ -123,8 +123,10 @@ test: tests
tests: library $(TEST_DEP)
@$(MAKE) -fMakefile.planets -f$(TEST_DEP) test_htrdr_planets_source
+# Link with all obj files in the planet library since the test checks
+# hidden functions
test_htrdr_planets_source: $(TEST_OBJ)
- $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) src/planets/htrdr_planets_source.o $(LDFLAGS_TEST)
+ $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) $(OBJ) $(LDFLAGS_TEST)
$(TEST_DEP):
@$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@