Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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+=-I./raylib-5.5_linux_amd64/include -std=c99
  20. rl: LDFLAGS+=-L./raylib-5.5_linux_amd64/lib -lraylib -Wl,-rpath=./raylib-5.5_linux_amd64/lib
  21. raw_x11: CFLAGS+=$(shell pkg-config ${_PKG_STATIC} --cflags x11)
  22. raw_x11: LDFLAGS+=$(shell pkg-config ${_PKG_STATIC} --libs x11)
  23. cad: CFLAGS+=$(shell pkg-config ${_PKG_STATIC} --cflags x11)
  24. cad: LDFLAGS+=$(shell pkg-config ${_PKG_STATIC} --libs x11)
  25. all: ${BIN}
  26. ${BIN}: %: src/%.o
  27. @echo -n "[LD] "
  28. gcc ${LDFLAGS} ${_LDFLAGS_$@} $^ -o $@
  29. %.d: %.c
  30. gcc ${CFLAGS} -MM $^ > $@
  31. include ${DEPS}
  32. tags: ${SRCS} ${HDRS}
  33. ctags --kinds-all=* --totals=yes $^
  34. clean:
  35. rm -fv ${BIN} ${OBJS}
  36. fullclean: clean
  37. rm -fv ${DEPS}