summary refs log tree commit diff
path: root/GNUmakefile
diff options
context:
space:
mode:
authorzlago2024-08-31 19:00:41 +0200
committerzlago2024-08-31 19:07:37 +0200
commiteb068a88abe0f685309cb1a977f363c7d8708cad (patch)
tree68e1b14acf1fe611cc24cde1632531b8c4cef50d /GNUmakefile
initial commit
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}