Makefile 1.1 KB

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