-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (39 loc) · 1.05 KB
/
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
50
CC=gcc
CFLAGS=$(shell pkg-config --cflags glfw3 glew)
LDFLAGS=$(shell pkg-config --libs glfw3 glew)
CUSTOMCFLAGS=
# To avoid having to clean when changing parameters
# Maybe there is another way but I'm not aware
OBJSUFFIX=
# Use `DEBUG=1` in the invocation of `make` to enable
ifdef DEBUG
CUSTOMCFLAGS := $(CUSTOMCFLAGS) -g -DDEBUG
OBJSUFFIX := $(OBJSUFFIX)-debug
else
CUSTOMCFLAGS := $(CUSTOMCFLAGS) -O3
endif
SRCDIR=src
ODIR=obj
SOURCES=field.c game.c input.c main.c piece.c
# Use `TRACK_FPS=1`
ifdef TRACK_FPS
CUSTOMCFLAGS := $(CUSTOMCFLAGS) -DTRACK_FPS
SOURCES := $(SOURCES) fps.c
OBJSUFFIX := $(OBJSUFFIX)-fps
endif
# Use `FAST_RENDER=1`
ifdef FAST_RENDER
SOURCES := $(SOURCES) fast_render.c
OBJSUFFIX := $(OBJSUFFIX)-fast-render
else
SOURCES := $(SOURCES) fancy_render.c
endif
OBJS=$(patsubst %.c,%$(OBJSUFFIX).o,$(SOURCES))
$(ODIR)/%$(OBJSUFFIX).o: $(SRCDIR)/%.c
mkdir -p $(ODIR)
$(CC) -c -o $@ $(CFLAGS) $(CUSTOMCFLAGS) $<
tetris: $(addprefix $(ODIR)/,$(OBJS))
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS)
.PHONY: clean
clean:
rm $(ODIR)/*.o tetris