commit 96a9716537e8709085b4e51a6d1ca6537bbe011a
parent d6bf27469ad5c35ff65d2fcb251b998574d2c61c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 30 Oct 2023 12:30:28 +0100
Update test compilation and link edition
Add the library as a dependency of the tests that must be linked to it.
This forces make to rerun the linker if the library is changed.
Make sure that the pkg-config directive for the local library appears as
the first compiler flag to be used and the first library to be linked,
to ensure that headers and libraries are searched for first in the local
path. This is because the compiler and linker look for directories in
the left-to-right order in which the -I and -L options appear. So, to
force inclusion of local headers and link editing with the local version
of the library, the -I./src and -L./ directives must appear first when
compiling and linking.
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
@@ -141,19 +141,19 @@ clean_test:
$(SHELL) make.sh clean_test $(TEST_SRC)
$(TEST_DEP): config.mk htgop-local.pc
- @$(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) $(HTGOP_CFLAGS) \
+ @$(CC) $(CFLAGS_EXE) $(HTGOP_CFLAGS) $(RSYS_CFLAGS) \
-MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
$(TEST_OBJ): config.mk htgop-local.pc
- $(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) $(HTGOP_CFLAGS) -c $(@:.o=.c) -o $@
+ $(CC) $(CFLAGS_EXE) $(HTGOP_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@
test_htgop \
test_htgop_fetch_radiative_properties \
test_htgop_get_radiative_properties_bounds \
test_htgop_load \
test_htgop_sample \
-: config.mk htgop-local.pc
- $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RSYS_LIBS) $(HTGOP_LIBS) -lm
+: config.mk htgop-local.pc $(LIBNAME)
+ $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(HTGOP_LIBS) $(RSYS_LIBS) -lm
# Touch the target to update its timestamp. Otherwise, the extracted file will
# have a timestamp lower than its prerequisite, forcing its re-extraction.