summary refs log tree commit diff
path: root/GNUmakefile
blob: 2a814e15c6fb11c4fa135c231fb6f6b4cb3ef322 (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
43
44
45
46
47
48
49
#!/usr/bin/env -S gmake -f

MKDIR ?= mkdir -p

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

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

.SECONDARY:

.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/common/%.c out/%.d | out/
	${CC} -c -o $@ $< ${cflags}

out/%.d: src/common/%.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}