clean up (?) the makefiles

This commit is contained in:
jacekpoz 2024-04-29 19:45:45 +02:00
parent 0491c3655a
commit d970e74ce3
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
2 changed files with 18 additions and 16 deletions

View file

@ -16,7 +16,7 @@ PROG = $(addprefix $(SRC)/, $(_PROG))
OBJ = $(addprefix $(BIN)/, $(_PROG:.cpp=.o)) OBJ = $(addprefix $(BIN)/, $(_PROG:.cpp=.o))
.PHONY: all clean .PHONY: all clean test
all: dirs $(NAME) all: dirs $(NAME)
@ -53,4 +53,9 @@ $(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
$(CXX) -DPP_DEBUG $(CXXFLAGS) -E $< > $@ $(CXX) -DPP_DEBUG $(CXXFLAGS) -E $< > $@
clang-format -i $@ clang-format -i $@
include test/Makefile test:
@CXX="$(CXX)" \
CXXFLAGS="$(CXXFLAGS)" \
BIN="$(BIN)/test" \
INCLUDE="$(INCLUDE)" \
make -f test/Makefile

View file

@ -1,29 +1,26 @@
INCLUDE_TEST = include test INCLUDE += test
CXXFLAGS += $(addprefix -I, $(INCLUDE_TEST)) CXXFLAGS += $(addprefix -I, $(INCLUDE))
TEST = test TEST = test
BIN_TEST = $(BIN)/$(TEST)
_TESTS = example.cpp _TESTS = example.cpp
TESTS = $(addprefix $(TEST)/, $(_TESTS)) TESTS = $(addprefix $(TEST)/, $(_TESTS))
OBJ_TEST = $(addprefix $(BIN_TEST)/, $(_TESTS:.cpp=)) OBJ = $(addprefix $(BIN)/, $(_TESTS:.cpp=))
.PHONY: test .PHONY: all
dirs_test: all: dirs_test $(OBJ)
mkdir -p $(BIN_TEST)
test_start:
@echo @echo
@echo "---------- STARTING TESTS ----------" @echo "---------- STARTING TESTS ----------"
@echo @echo
$(foreach test,$(OBJ),@./$(test))
test: dirs_test test_start $(OBJ_TEST)
$(foreach _test,$(OBJ_TEST),@./$(_test))
@echo @echo
@echo "---------- FINISHED TESTS ----------" @echo "---------- FINISHED TESTS ----------"
@echo @echo
$(BIN_TEST)/%: $(TEST)/%.cpp dirs_test:
@$(CXX) $< $(CXXFLAGS) -o $@ mkdir -p $(BIN)
$(BIN)/%: $(TEST)/%.cpp
$(CXX) $< $(CXXFLAGS) -o $@