Makefile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. SRCS=$(shell find ./src -name '*.c' -type f)
  2. DEPS=$(patsubst %.c, %.d, ${SRCS})
  3. HDRS=$(shell find ./src -name '*.h' -type f)
  4. CFLAGS+=-ansi -m64 -Og -ggdb \
  5. -pedantic -Wall -Wextra -Wshadow \
  6. -Wcast-align -Wunused -Wconversion -Wmisleading-indentation \
  7. -Wdouble-promotion -Wformat=2 -Wbad-function-cast \
  8. -Wmissing-declarations \
  9. -Wmissing-prototypes -Wnested-externs -Werror
  10. LDFLAGS+= -fsanitize=address
  11. ifneq ($(findstring -static, ${LDFLAGS}), )
  12. LDFLAGS:=$(filter-out -fsanitize=address, ${LDFLAGS})
  13. _PKGT_STATIC:=--static
  14. endif
  15. BIN := $(subst src/,,$(patsubst %.c, %, ${SRCS}))
  16. _CFLAGS_sdl3:=$(shell pkg-config ${_PKG_STATIC} --cflags sdl3)
  17. _LDFLAGS_sdl3:=$(shell pkg-config ${_PKG_STATIC} --libs sdl3)
  18. _CFLAGS_raylib:=$(shell pkg-config ${_PKG_STATIC} --cflags raylib)
  19. _LDFLAGS_raylib:=$(shell pkg-config ${_PKG_STATIC} --libs raylib)
  20. ${BIN}: %: src/%.o
  21. gcc ${LDFLAGS} ${_LDFLAGS_$@} $^ -o $@
  22. %.o: %.c
  23. gcc ${CFLAGS} ${_CFLAGS_${@:src/%.o=%}} $^ -c -o $@
  24. %.d: %.c
  25. gcc ${CFLAGS} -MM $^ > $@
  26. include ${DEPS}
  27. tags: ${SRCS} ${HDRS}
  28. ctags --kinds-all=* --totals=yes $^