osuplusplus/Makefile

61 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 = $(addprefix $(BIN)/, $(_PROG:.cpp=.o))
.PHONY: all clean test
all: dirs test $(NAME)
dirs:
mkdir -p $(BIN)
mkdir -p $(PREPROCESSED)
$(NAME): $(OBJ)
$(CXX) $^ $(LDFLAGS) -o $(BIN)/$@
$(BIN)/%.o: $(SRC)/%.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
clean:
rm -rf $(addprefix $(BIN)/, $(OBJ))
rm -rf $(BIN)/$(NAME)
rm -rf $(BIN)
rm -rf $(PREPROCESSED)
_PP_HXX = osuparser.hpp config.hpp
_PP_CXX = osuparser.cpp
_PP = $(_PP_HXX) $(_PP_CXX)
PP = $(addprefix $(PREPROCESSED)/, $(_PP))
# PP_DEBUG gets rid of all the macros we don't need
# when debugging the preprocessed output
pp: dirs $(PP)
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp
$(CXX) -DPP_DEBUG $(CXXFLAGS) -E $< > $@
clang-format -i $@
$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
$(CXX) -DPP_DEBUG $(CXXFLAGS) -E $< > $@
clang-format -i $@
test:
@CXX="$(CXX)" \
CXXFLAGS="$(CXXFLAGS)" \
BIN="$(BIN)/test" \
INCLUDE="$(INCLUDE)" \
make -f test/Makefile