-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (37 loc) · 908 Bytes
/
Makefile
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
BINDIR = ./bin
BLDDIR = ./build
SRCDIR = ./src
SRCS = $(wildcard $(SRCDIR)/*.c)
OBJS = $(addprefix $(BLDDIR)/, $(notdir $(SRCS:.c=.o)))
DEPS = $(OBJS:.o=.d)
MODE =
LIBS = -lSDL2 -lSDL2_mixer -lSDL2_image
CFLAGS = -std=c99 -Wall -pedantic
MAIN = $(BINDIR)/pxdrummer
ifeq ($(MODE),debug)
CFLAGS += -g
else
CFLAGS += -O2
endif
.PHONY: all clean
all: $(MAIN)
$(BLDDIR)/.depend: $(DEPS)
@cat $(BLDDIR)/*.d > $(BLDDIR)/.depend
$(BINDIR):
@mkdir -p $(BINDIR)
$(BLDDIR):
@mkdir -p $(BLDDIR)
$(MAIN): | $(BINDIR)
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(OBJS) $(LIBS)
$(OBJS): | $(BLDDIR)
$(BLDDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(DEPS): | $(BLDDIR)
$(BLDDIR)/%.d: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -MM $< -MT $(@:.d=.o) > $@
clean:
@rm -rf $(BINDIR)
@rm -rf $(BLDDIR)
@echo cleaning done
include $(BLDDIR)/.depend