diff --git a/Makefile b/Makefile index e430c2f..ccb260c 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,6 @@ PREPROCESSED = preprocessed _PROG = HitObjectDrawable.cpp main.cpp osuparser.cpp TextureManager.cpp PROG = $(addprefix $(SRC)/, $(_PROG)) -PP_HXX = osuparser.hpp config.hpp -PP_CXX = osuparser.cpp -PP = $(PP_HXX) $(PP_CXX) - OBJ = $(_PROG:.cpp=.o) .PHONY: all clean @@ -42,9 +38,21 @@ clean: TMP = temp -preprocess: dirs +tmp: mkdir -p $(TMP) - $(foreach file, $(PP_HXX), $(CXX) $(CXXFLAGS) -E $(INCLUDE)/$(file) > $(TMP)/$(file);) - $(foreach file, $(PP_CXX), $(CXX) $(CXXFLAGS) -E $(SRC)/$(file) > $(TMP)/$(file);) - $(foreach file, $(PP), clang-format $(TMP)/$(file) > $(PREPROCESSED)/$(file);) + +_PP_HXX = osuparser.hpp config.hpp +_PP_CXX = osuparser.cpp +_PP = $(_PP_HXX) $(_PP_CXX) +PP = $(addprefix $(PREPROCESSED)/, $(_PP)) + +preprocess: dirs tmp $(PP) rm -rf $(TMP) + +$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp + $(CXX) $(CXXFLAGS) -E $< > $(TMP)/$(@:$(PREPROCESSED)/%=%) + clang-format $(TMP)/$(@:$(PREPROCESSED)/%=%) > $@ + +$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp + $(CXX) $(CXXFLAGS) -E $< > $(TMP)/$(@:$(PREPROCESSED)/%=%) + clang-format $(TMP)/$(@:$(PREPROCESSED)/%=%) > $@