-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
64 lines (47 loc) · 1.36 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# makefile
CC:=clang
SRCDIR:=./src
EXTDIR:=./external
OBJDIR:=./obj
OPTIMIZATION_FLAG:=-O0
# Additional places to find C header files
ALSO_INCLUDE:=-I$(SRCDIR) -I$(EXTDIR)
CFLAGS:=-Wall $(OPTIMIZATION_FLAG) $(ALSO_INCLUDE)
# Recipe for building what will be a dependency of the main executable
BUILD_DEP=$(CC) $^ -c --output $@ $(CFLAGS)
################################################################################
# Remove the line for `external` if something is ever put in `external`
init:
mkdir -p obj
mkdir -p screenshots
mkdir -p external
run: build
./main.bin
build: main.bin
clean:
rm -f $(OBJDIR)/*.o
rm -f main.bin
# `-lm` was added after needing `round` function in <math.h>
# in order to avoid a compilation error
# Add `-fopenmp` if OpenMP is used
main.bin: ./main/main.c \
$(OBJDIR)/charu.o \
$(OBJDIR)/easy_alloc.o \
$(OBJDIR)/game.o \
$(OBJDIR)/nsec.o \
$(OBJDIR)/rand.o \
$(OBJDIR)/sdlu.o
$(CC) $^ --output $@ -g -lm $(CFLAGS) -lSDL2 -lSDL2_image
################################################################################
$(OBJDIR)/charu.o: $(SRCDIR)/charu.c
$(BUILD_DEP)
$(OBJDIR)/easy_alloc.o: $(SRCDIR)/easy_alloc.c
$(BUILD_DEP)
$(OBJDIR)/game.o: $(SRCDIR)/game.c
$(BUILD_DEP)
$(OBJDIR)/nsec.o: $(SRCDIR)/nsec.c
$(BUILD_DEP)
$(OBJDIR)/rand.o: $(SRCDIR)/rand.c
$(BUILD_DEP)
$(OBJDIR)/sdlu.o: $(SRCDIR)/sdlu.c
$(BUILD_DEP)