commit c28ee5202cd4a230ae8330e14c690beaf757309c
parent aad9dbddf25ae3627660323e4748afd4fada1f50
Author: vaplv <vaplv@free.fr>
Date: Wed, 30 Apr 2025 09:00:53 +0200
Clean test Makefile targets
Since all tests are built in the same way, do not explicitly list all
their object files, but simply replace them with TEST_OBJ macros.
Write a specific Makefile target for their dependency file. Their
compilation flags differ from those of the library and should therefore
not use the inference rules defined for the library.
Diffstat:
| M | Makefile | | | 57 | +++++++++------------------------------------------------ |
1 file changed, 9 insertions(+), 48 deletions(-)
diff --git a/Makefile b/Makefile
@@ -258,13 +258,6 @@ $(TEST_TGT):
printf 'test_all: %s\n' "$${exe}"; \
} > $@
-$(TEST_DEP) $(TEST_OBJ): config.mk rsys-local.pc
-
-clean_test:
- rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT)
- rm -f libtest_lib.so test_lib.o test_text_reader.txt test.ppm
- for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done
-
test_lib.o: src/test_library.c src/rsys.h config.mk
$(CC) $(CFLAGS_SO) -c src/test_library.c -DTEST_LIBRARY_BUILD_LIB -o $@
@@ -273,47 +266,10 @@ libtest_lib.so: test_lib.o config.mk
test_library: libtest_lib.so
-src/test_algorithm.o \
-src/test_atomic.o \
-src/test_binary_heap.o \
-src/test_condition.o \
-src/test_cstr.o \
-src/test_double2.o \
-src/test_double22.o \
-src/test_double3.o \
-src/test_double33.o \
-src/test_double4.o \
-src/test_double44.o \
-src/test_dynamic_array.o \
-src/test_endianness.o \
-src/test_float2.o \
-src/test_float22.o \
-src/test_float3.o \
-src/test_float33.o \
-src/test_float4.o \
-src/test_float44.o \
-src/test_free_list.o \
-src/test_func_name.o \
-src/test_hash_sha256.o \
-src/test_hash_table.o \
-src/test_image.o \
-src/test_library.o \
-src/test_list.o \
-src/test_logger.o \
-src/test_math.o \
-src/test_mem_allocator.o \
-src/test_misc.o \
-src/test_morton.o \
-src/test_mutex.o \
-src/test_quaternion.o \
-src/test_ref.o \
-src/test_signal.o \
-src/test_str.o \
-src/test_stretchy_array.o \
-src/test_text_reader.o \
-src/test_time.o \
-src/test_vmacros.o \
-:
+$(TEST_DEP): config.mk rsys-local.pc
+ @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+$(TEST_OBJ): config.mk rsys-local.pc
$(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@
test_algorithm \
@@ -359,6 +315,11 @@ test_vmacros \
: config.mk rsys-local.pc $(LIBNAME)
$(CC) $(CFLAGS_TEST) -o $@ src/$@.o $(LDFLAGS_TEST)
+clean_test:
+ rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT)
+ rm -f libtest_lib.so test_lib.o test_text_reader.txt test.ppm
+ for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done
+
test: tests
@err=0; \
for i in $(TEST_SRC); do \