osuplusplus/Makefile
jacekpoz 2e259e946d
improve make preprocess
fun story - I had this exact piece of code without a single changed not
work the prior 2 times, then I changed a bit, a part started working so
I changed it back to this and the 3rd time it somehow works
2024-04-24 20:03:18 +02:00

58 lines
1.2 KiB
Makefile

CXX = g++
CXXFLAGS = -std=c++20 -O3 -Wall -Wextra -Wpedantic
LDFLAGS = -lsfml-graphics -lsfml-window -lsfml-system
NAME = osu++
INCLUDE = include
CXXFLAGS += -I$(INCLUDE)
SRC = src
BIN = target
PREPROCESSED = preprocessed
_PROG = HitObjectDrawable.cpp main.cpp osuparser.cpp TextureManager.cpp
PROG = $(addprefix $(SRC)/, $(_PROG))
OBJ = $(_PROG:.cpp=.o)
.PHONY: all clean
all: dirs $(NAME)
dirs:
mkdir -p $(BIN)
mkdir -p $(PREPROCESSED)
$(NAME): $(OBJ)
$(CXX) $(addprefix $(BIN)/, $^) $(LDFLAGS) -o $(BIN)/$@
%.o: $(SRC)/%.cpp
$(CXX) -c $< $(CXXFLAGS) -o $(BIN)/$@
clean:
rm -rf $(addprefix $(BIN)/, $(OBJ))
rm -rf $(BIN)/$(NAME)
rm -rf $(BIN)
rm -rf $(PREPROCESSED)
TMP = temp
tmp:
mkdir -p $(TMP)
_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)/%=%) > $@