69 lines
1.8 KiB
Makefile
69 lines
1.8 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)
|
|
|
|
_PP_HXX = osuparser.hpp config.hpp
|
|
_PP_CXX = osuparser.cpp
|
|
_PP = $(_PP_HXX) $(_PP_CXX)
|
|
PP = $(addprefix $(PREPROCESSED)/, $(_PP))
|
|
|
|
# the awks below will remove all includes, pragmas and blank lines from the top of the file
|
|
# until they hit something else
|
|
#
|
|
# that something else could be an awk marker comment which saves part of the includes
|
|
# from being eaten by awk - ones useful when debugging the output of these godforsaken macros
|
|
#
|
|
# doing that makes clang-format considerably faster (c++ std moment)
|
|
# but also removes my own headers which makes some of the macros not evaluate
|
|
#
|
|
# that issue is fixed by adding a comment that'll stop the awk before my macros
|
|
# and after all the others
|
|
pp: dirs $(PP)
|
|
|
|
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp
|
|
$(eval TMP := $(shell mktemp).hpp)
|
|
awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
|
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
|
clang-format -i $@
|
|
rm -rf $(TMP)
|
|
|
|
$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
|
|
$(eval TMP := $(shell mktemp).cpp)
|
|
awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
|
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
|
clang-format -i $@
|
|
rm -rf $(TMP)
|