-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·71 lines (57 loc) · 2.07 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
65
66
67
68
69
70
71
UNAME_S := $(shell uname -s)
EXE = pacman
SRC = $(wildcard src/*.cpp)
LIBSRC = $(wildcard lib/*.c)
OUTPATH = bin/release/
OUTFILE = $(OUTPATH)$(EXE)
OBJPATH = obj/release/
OBJ = $(addprefix $(OBJPATH),$(notdir $(SRC:.cpp=.o)))
LIBOBJ = $(addprefix $(OBJPATH),$(notdir $(LIBSRC:.c=.o)))
DEBUG_OUTPATH = bin/debug/
DEBUG_OUTFILE = $(DEBUG_OUTPATH)$(EXE)
DEBUG_OBJPATH = obj/debug/
DEBUG_OBJ = $(addprefix $(DEBUG_OBJPATH),$(notdir $(SRC:.cpp=.o)))
LIBOBJ = $(addprefix $(OBJPATH),$(notdir $(LIBSRC:.c=.o)))
ifeq ($(UNAME_S),Darwin)
CXX = clang++
CC = clang
CXXFLAGS = -DNDEBUG
CCFLAGS = -DNDEBUG
STDFLAG = -std=c++11
debug : CCFLAGS = -g
debug : CXXFLAGS = -g
INCLUDE_FLAGS := -Wno-unused-command-line-argument -I/Library/Frameworks/SDL2.framework/Headers -F/Library/Frameworks -framework SDL2 -I/Library/Frameworks/SDL2_image.framework/Headers -F/Library/Frameworks -framework SDL2_image -I/Library/Frameworks/SDL2_ttf.framework/Headers -F/Library/Frameworks -framework SDL2_ttf -I/Library/Frameworks/SDL2_mixer.framework/Headers -F/Library/Frameworks -framework SDL2_mixer
else ifeq ($(UNAME_S),Linux)
CXX = g++
CC = gcc
CXXFLAGS = -DNDEBUG
CCFLAGS = -DNDEBUG
STDFLAG = -std=c++11
debug : CCFLAGS = -g
debug : CXXFLAGS = -g
INCLUDE_FLAGS = -I/usr/include/SDL2/ -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf
endif
INCLUDE_FLAGS += -I./lib -I./include
all: $(OUTFILE)
ln -sf $(OUTFILE) $(EXE)
debug: $(LIBOBJ)
mkdir -p $(DEBUG_OUTPATH)
$(CXX) $(STDFLAG) $(CXXFLAGS) $(INCLUDE_FLAGS) $(SRC) $(LIBOBJ) -o $(DEBUG_OUTFILE)
ln -sf $(DEBUG_OUTFILE) $(EXE)
$(OUTFILE): $(OBJ) $(LIBOBJ)
mkdir -p $(OUTPATH)
$(CXX) $(STDFLAG) $(CXXFLAGS) $(INCLUDE_FLAGS) $(OBJ) $(LIBOBJ) -o $(OUTFILE)
$(OBJPATH)%.o: src/%.cpp | obj
$(CXX) $(STDFLAG) $(CXXFLAGS) $(INCLUDE_FLAGS) -c $< -o $@
$(OBJPATH)%.o: lib/%.c | obj
$(CC) $(CCFLAGS) $(INCLUDE_FLAGS) -c $< -o $@
obj:
mkdir -p $(OBJPATH)
mkdir -p $(DEBUG_OBJPATH)
clean:
rm -f *.a *.o *.out game.dat pacman
rm -rf obj bin
rm -f .DS_Store lib/.DS_Store src/.DS_Store resources/.DS_Store resources/images/.DS_Store
rm -rf *.dSYM
rm -rf .cache
.PHONY: debug all