|
@@ -1,18 +1,40 @@
|
|
|
SRCS=$(shell find ./src -name '*.c' -type f)
|
|
SRCS=$(shell find ./src -name '*.c' -type f)
|
|
|
|
|
+DEPS=$(patsubst %.c, %.d, ${SRCS})
|
|
|
HDRS=$(shell find ./src -name '*.h' -type f)
|
|
HDRS=$(shell find ./src -name '*.h' -type f)
|
|
|
|
|
|
|
|
-CFLAGS=-ansi -m64 -Og -fsanitize=address -ggdb \
|
|
|
|
|
|
|
+CFLAGS+=-ansi -m64 -Og -ggdb \
|
|
|
-pedantic -Wall -Wextra -Wshadow \
|
|
-pedantic -Wall -Wextra -Wshadow \
|
|
|
-Wcast-align -Wunused -Wconversion -Wmisleading-indentation \
|
|
-Wcast-align -Wunused -Wconversion -Wmisleading-indentation \
|
|
|
-Wdouble-promotion -Wformat=2 -Wbad-function-cast \
|
|
-Wdouble-promotion -Wformat=2 -Wbad-function-cast \
|
|
|
-Wmissing-declarations \
|
|
-Wmissing-declarations \
|
|
|
-Wmissing-prototypes -Wnested-externs -Werror
|
|
-Wmissing-prototypes -Wnested-externs -Werror
|
|
|
|
|
|
|
|
-sdl3: src/sdl3.c ${HDRS}
|
|
|
|
|
- gcc $(shell pkg-config --cflags sdl3) $(shell pkg-config --libs sdl3) -ggdb ${CFLAGS} $^ -o $@
|
|
|
|
|
|
|
+LDFLAGS+= -fsanitize=address
|
|
|
|
|
|
|
|
-cint: src/cint.c ${HDRS}
|
|
|
|
|
- gcc -ggdb ${CFLAGS} $^ -o $@
|
|
|
|
|
|
|
+ifneq ($(findstring -static, ${LDFLAGS}), )
|
|
|
|
|
+ LDFLAGS:=$(filter-out -fsanitize=address, ${LDFLAGS})
|
|
|
|
|
+ _PKGT_STATIC:=--static
|
|
|
|
|
+endif
|
|
|
|
|
+
|
|
|
|
|
+BIN := $(subst src/,,$(patsubst %.c, %, ${SRCS}))
|
|
|
|
|
+
|
|
|
|
|
+_CFLAGS_sdl3:=$(shell pkg-config ${_PKG_STATIC} --cflags sdl3)
|
|
|
|
|
+_LDFLAGS_sdl3:=$(shell pkg-config ${_PKG_STATIC} --libs sdl3)
|
|
|
|
|
+
|
|
|
|
|
+_CFLAGS_raylib:=$(shell pkg-config ${_PKG_STATIC} --cflags raylib)
|
|
|
|
|
+_LDFLAGS_raylib:=$(shell pkg-config ${_PKG_STATIC} --libs raylib)
|
|
|
|
|
+
|
|
|
|
|
+${BIN}: %: src/%.o
|
|
|
|
|
+ gcc ${LDFLAGS} ${_LDFLAGS_$@} $^ -o $@
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+%.o: %.c
|
|
|
|
|
+ gcc ${CFLAGS} ${_CFLAGS_${@:src/%.o=%}} $^ -c -o $@
|
|
|
|
|
+
|
|
|
|
|
+%.d: %.c
|
|
|
|
|
+ gcc ${CFLAGS} -MM $^ > $@
|
|
|
|
|
+
|
|
|
|
|
+include ${DEPS}
|
|
|
|
|
|
|
|
tags: ${SRCS} ${HDRS}
|
|
tags: ${SRCS} ${HDRS}
|
|
|
ctags --kinds-all=* --totals=yes $^
|
|
ctags --kinds-all=* --totals=yes $^
|