diff --git a/Makefile b/Makefile index ca48f21..ae09bfa 100644 --- a/Makefile +++ b/Makefile @@ -5,16 +5,29 @@ OBJS= \ build/src/Player.o \ build/src/GameRenderer.o -LIBS=-lSDL2 -lSDL2_image +MAKEFLAGS += -j $(shell nproc) + +CXX_FLAGS = -std=c++23 -Wall -Wextra -Wpedantic -Wconversion -pedantic -pedantic-errors + +RELEASE=0 + +ifeq ($(RELEASE), 1) + CXX_FLAGS += -Werror +else + CXX_FLAGS += -fsanitize=address,undefined + LINKER_FLAGS += -fsanitize=address,undefined +endif + +CXX_FLAGS += $(shell pkg-config sdl2 SDL2_image --cflags) +LINKER_FLAGS += $(shell pkg-config sdl2 SDL2_image --libs) build/%.o: %.cpp $(wildcard *.hpp) - mkdir -p `dirname $@` - g++ $(CFLAGS) -c -o $@ $< $(LIBS) + @mkdir -p `dirname $@` + g++ $(CXXFLAGS) -c -o $@ $< all: $(OBJS) - g++ $(CFLAGS) $(OBJS) $(LIBS) + g++ $(OBJS) $(LINKER_FLAGS) clean: rm -r build rm a.out - diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..758390f --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,8 @@ +-xc++ +-std=c++23 +-Wall +-Wextra +-Wpedantic +-Wconversion +-pedantic +-pedantic-errors