-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
39 lines (30 loc) · 912 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
CC = g++
CPPFLAGS = -std=c++11
DEBUGFLAGS = -g -Wall
INCLUDE = include
SRCDIR = src
BINDIR = bin
OBJDIR = obj
TESTDIR = test
LIB = -lSDL2 -lSDL2_image -lSDL2_ttf
SRC = $(wildcard $(SRCDIR)/*.cpp)
BIN = $(wildcard $(BINDIR)/*)
TESTSRC = $(filter-out $(SRCDIR)/main.cpp, $(SRC))
OBJ = $(SRC:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
TESTOBJ = $(TESTSRC:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
main: $(OBJ) | $(BINDIR)
$(CC) $(CPPFLAGS) $(LIB) $^ -o $(BINDIR)/$@
debug: $(OBJ) | $(BINDIR)
$(CC) $(DEBUGFLAGS) $(CPPFLAGS) $(LIB) $^ -o $(BINDIR)/$@
$(OBJDIR)/test%.o: $(TESTDIR)/test%.cpp | $(OBJDIR)
$(CC) $(CPPFLAGS) -c $< -I$(INCLUDE) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
$(CC) $(DEBUGFLAGS) $(CPPFLAGS) -c $< -I$(INCLUDE) -o $@
$(OBJDIR):
mkdir -p $(OBJDIR)
$(BINDIR):
mkdir -p $(BINDIR)
test%: $(OBJDIR)/test%.o $(TESTOBJ)
$(CC) $(CPPFLAGS) $^ -o $(BINDIR)/$@
clean:
rm -rf $(OBJDIR)/*.o $(BINDIR)/*