From b23a3ab831f91553d34a48f51370ed9525de07ac Mon Sep 17 00:00:00 2001 From: zlago Date: Tue, 24 Sep 2024 20:54:48 +0200 Subject: initial commit --- GNUmakefile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 GNUmakefile (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..39fcc6d --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,47 @@ +#!/usr/bin/env -S gmake -f + +export MKDIR ?= mkdir -p + +libs := SDL2 z + +CFLAGS ?= -Wall -Wpedantic -g -Og +cflags := -I lib/ -I . ${CFLAGS} +ldflags := $(addprefix -l,${libs}) ${LDFLAGS} + +srcs := $(wildcard src/*.c) +objs := $(addprefix out/${NS}/,$(notdir ${srcs:.c=.o})) +deps := $(addprefix out/${NS}/,$(notdir $(patsubst %.c,%.d,$(wildcard src/*.c)))) + +.PHONY: all run clean lib + +all: out/${NS}/a.out + +run: out/${NS}/a.out + ./$< + +clean: + ${RM} -r out/${NS}/ +# ${MAKE} -C lib clean + +#lib: +# ${MAKE} -C $@ + +out/${NS}/: + ${MKDIR} $@ + +out/: + ${MKDIR} $@ + +out/${NS}/%.o: src/%.c out/${NS}/%.d | out/${NS}/ + ${CC} -c -o $@ $< ${cflags} + +out/${NS}/%.d: src/%.c | out/${NS}/ + ${CC} ${cflags} ${CPPFLAGS} -MM -MG -MF $@ -MT "${@:.d=.o} $@" $< + +out/${NS}/a.out: ${objs} | out/${NS}/ #lib + ${CC} -o $@ $^ $(wildcard lib/out/*.o) ${cflags} ${ldflags} + +out/%: utl/%.c | out/${NS}/ + ${CC} -g -Og -o $@ $^ # i have no idea how im supposed to handle CFLAGS + +include ${deps} -- cgit 1.4.1-2-gfad0