aboutsummaryrefslogtreecommitdiff
path: root/rules.mk
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2023-02-05 10:16:20 +0200
committeraqua <aqua@iserlohn-fortress.net>2023-02-05 10:16:20 +0200
commita5de90c48a1800c865285945aadd019fa07c7ad8 (patch)
treea2e476f4950aa142019617779f8e0bce4a01305c /rules.mk
parentblake2: use makefiles instead of meson.build (diff)
downloadkernel-a5de90c48a1800c865285945aadd019fa07c7ad8.tar.xz
Split Makefile
- Makefile: configure, doc and test targets - Makefile.all: info, build and run targets - rules.mk: add base test targets
Diffstat (limited to 'rules.mk')
-rw-r--r--rules.mk37
1 files changed, 21 insertions, 16 deletions
diff --git a/rules.mk b/rules.mk
index 333e4f8..4e2730a 100644
--- a/rules.mk
+++ b/rules.mk
@@ -12,11 +12,11 @@ CXXFLAGS += -isysteminclude -I../lib -Drestrict=__restrict__ \
-Werror=shadow
# Suffix rules
+.SUFFIXES: .s .S .c .cpp .o
%.a:
@echo ' AR $@'
@${AR} ${ARFLAGS} $@ $(filter %.o,$^)
-.SUFFIXES: .s .S .c .o
.s.o:
@echo ' AS $^'
@$(AS) $(ASFLAGS) -c -o $@ $^
@@ -33,28 +33,33 @@ CXXFLAGS += -isysteminclude -I../lib -Drestrict=__restrict__ \
@echo ' CXX $^'
@$(CXX) $(CXXFLAGS) -c -o $@ $^
-# Test rules
-TEST_CXX := c++
-GTEST := $(shell pkg-config --cflags --libs gtest gtest_main)
-GMOCK := $(shell pkg-config --cflags --libs gmock)
+%.elf:
+ @echo ' LD $@'
+ @${LD} ${LDFLAGS} -o $@ $^
+ @echo -n ' B2b '
+ @b2sum $@ | cut -d' ' -f1
+# test rules
tst/test_%: tst/%.cc
@echo ' CXX TEST $@'
- @$(TEST_CXX) $< -o $@ $(GTEST) $(GMOCK)
+ @$(TEST_CXX) $(TEST_CXXFLAGS) $< -o $@
-.PHONY: test valgrind
-test: $(TESTS)
- $(foreach f,$^,./$f;)
+.PHONY: test.base valgrind.base clean.base FORCE
+test.base: $(TESTS)
+ @echo " -> Running tests in $(shell pwd | xargs basename)"
+ @$(foreach f,$^,echo " -> $f"; ./$f &&) echo "Done"
-valgrind: $(TESTS)
- $(foreach f,$^,valgrind --leak-check=full ./$f;)
+valgrind.base: $(TESTS)
+ @echo " -> Running valgrind on tests in $(shell pwd | xargs basename)"
+ @$(foreach f,$^,echo " -> $f"; valgrind --leak-check=full ./$f;)
-
-# clean target
-.PHONY: clean FORCE
-clean:
+clean.base: FORCE
+ @echo " -> Cleaning $(shell pwd | xargs basename)"
@$(foreach V,$(filter %.OBJS, ${.VARIABLES}), rm -rf $($(V)))
+ @rm -rf *.a
@rm -rf include
@rm -rf tst/test_*
-FORCE:
+%: %.base ;
+
+FORCE: ;