summary refs log tree commit diff
path: root/GNUmakefile
blob: f7eb64ac3f3f2fb2f9b0635ad64f21456fdc969a (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
37
38
39
40
41
42
#!/usr/bin/env -S gmake -f

GLAD ?= glad
MKDIR ?= mkdir -p

libs ::= openmpt fluidsynth
cflags ::= -I . -g -Og ${CFLAGS}
ldflags ::= -Wl,--rpath,'$$ORIGIN' $(addprefix -l,${libs}) ${LDFLAGS}

srcs ::= $(wildcard src/modules/*.c)
objs ::= $(addprefix out/,$(notdir ${srcs:.c=.o}))
deps ::= $(addprefix out/,$(notdir ${srcs:.c=.d}))

.PHONY: all run clean

all: out/mu-SDL2 out/mu-portaudio

run: out/mu-SDL2
	./$<

clean:
	${RM} -r out/

out/:
	${MKDIR} $@

out/%.o: src/modules/%.c out/%.d | out/
	${CC} -c -o $@ $< ${cflags}

out/%.d: src/modules/%.c | out/
	${CC} ${cflags} ${CPPFLAGS} -MM -MG -MF $@ -MT "${@:.d=.o} $@" $<

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-%: out/%.o ${objs} | out/
	${CC} -o $@ $^ ${cflags} ${ldflags} -l${<:out/%.o=%}

include ${deps}