summary refs log tree commit diff
path: root/GNUmakefile
diff options
context:
space:
mode:
Diffstat (limited to 'GNUmakefile')
-rw-r--r--GNUmakefile36
1 files changed, 36 insertions, 0 deletions
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..09bd738
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,36 @@
+#!/usr/bin/env -S gmake -f
+
+GLAD ?= glad
+MKDIR ?= mkdir -p
+
+libs ::= SDL2
+cflags ::= -I . -g -Og ${CFLAGS}
+ldflags ::= -Wl,--rpath,'$$ORIGIN' $(addprefix -l,${libs}) ${LDFLAGS}
+
+srcs ::= $(wildcard src/*.c)
+objs ::= $(addprefix out/,$(notdir ${srcs:.c=.o}))
+deps ::= $(addprefix out/,$(notdir ${srcs:.c=.d}))
+
+.PHONY: all run clean
+
+all: out/mu-sdl
+
+run: out/mu-sdl
+	./$<
+
+clean:
+	${RM} -r out/
+
+out/:
+	${MKDIR} $@
+
+out/%.o: src/%.c out/%.d | out/
+	${CC} -c -o $@ $< ${cflags}
+
+out/%.d: src/%.c | out/
+	${CC} ${cflags} ${CPPFLAGS} -MM -MG -MF $@ -MT "${@:.d=.o} $@" $<
+
+out/mu-sdl: ${objs} | out/
+	${CC} -o $@ $^ ${cflags} ${ldflags}
+
+include ${deps}