commit f644273287bdff97dadc239d0ee12f03bfe67cd3
parent 0ef7a99f3a0750d36e3132a23c07d746efe89431
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 30 Oct 2023 15:02:33 +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
@@ -174,14 +174,14 @@ clean_test:
$(SHELL) make.sh clean_test $(TEST_SRC)
$(TEST_DEP): config.mk htcp-local.pc
- @$(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) $(HTCP_CFLAGS) \
+ @$(CC) $(CFLAGS_EXE) $(HTCP_CFLAGS) $(RSYS_CFLAGS) \
-MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
$(TEST_OBJ): config.mk htcp-local.pc
- $(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) $(HTCP_CFLAGS) -c $(@:.o=.c) -o $@
+ $(CC) $(CFLAGS_EXE) $(HTCP_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@
test_htcp \
test_htcp_load \
test_htcp_load_from_file \
-: config.mk htcp-local.pc
- $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RSYS_LIBS) $(HTCP_LIBS) -lm
+: config.mk htcp-local.pc $(LIBNAME)
+ $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(HTCP_LIBS) $(RSYS_LIBS) -lm