Improve makefile

This commit is contained in:
Reimar 2025-10-27 12:29:39 +01:00
parent d46ee05126
commit 4f34d06f73
2 changed files with 26 additions and 5 deletions

View File

@ -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

8
compile_flags.txt Normal file
View File

@ -0,0 +1,8 @@
-xc++
-std=c++23
-Wall
-Wextra
-Wpedantic
-Wconversion
-pedantic
-pedantic-errors