summary refs log tree commit diff
path: root/GNUmakefile
blob: 09bd738ab3ae112c3ca17712927092501e1a1932 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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}