osuplusplus/Makefile

67 lines
1.7 KiB
Makefile
Raw Normal View History

2024-03-18 11:25:15 +01:00
CXX = g++
CXXFLAGS = -std=c++20 -O3 -Wall -Wextra -Wpedantic
LDFLAGS = -lsfml-graphics -lsfml-window -lsfml-system
NAME = osu++
2024-04-24 19:30:34 +02:00
INCLUDE = include
CXXFLAGS += -I$(INCLUDE)
2024-03-18 11:25:15 +01:00
SRC = src
BIN = target
2024-04-24 19:30:34 +02:00
PREPROCESSED = preprocessed
2024-03-18 11:25:15 +01:00
_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)
2024-04-24 19:30:34 +02:00
mkdir -p $(PREPROCESSED)
2024-03-18 11:25:15 +01:00
$(NAME): $(OBJ)
$(CXX) $(addprefix $(BIN)/, $^) $(LDFLAGS) -o $(BIN)/$@
2024-04-24 19:53:08 +02:00
%.o: $(SRC)/%.cpp
2024-03-18 11:25:15 +01:00
$(CXX) -c $< $(CXXFLAGS) -o $(BIN)/$@
clean:
rm -rf $(addprefix $(BIN)/, $(OBJ))
rm -rf $(BIN)/$(NAME)
2024-04-24 19:30:34 +02:00
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))
awk marker comments to save necessary macros I restructured the beginnings of the preprocessed files for debugging to make the awks in the makefile not eat headers which are needed for debugging (e.g. the FOR_EACH macro) it's done by putting awk marker comments: // awk stop marker (check make pp) after the macros to be eaten by awk and before the ones we wanna keep I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this
2024-04-24 23:36:25 +02:00
# the awks below will remove all includes, pragmas and blank lines from the top of the file
# until they hit something else
#
# 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 marker comments to save necessary macros I restructured the beginnings of the preprocessed files for debugging to make the awks in the makefile not eat headers which are needed for debugging (e.g. the FOR_EACH macro) it's done by putting awk marker comments: // awk stop marker (check make pp) after the macros to be eaten by awk and before the ones we wanna keep I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this
2024-04-24 23:36:25 +02:00
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 marker comments to save necessary macros I restructured the beginnings of the preprocessed files for debugging to make the awks in the makefile not eat headers which are needed for debugging (e.g. the FOR_EACH macro) it's done by putting awk marker comments: // awk stop marker (check make pp) after the macros to be eaten by awk and before the ones we wanna keep I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this
2024-04-24 23:36:25 +02:00
awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
clang-format -i $@
rm -rf $(TMP)