-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (54 loc) · 2 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
NAME = Server/drchao
DEBUGNAME = Server/drchao-debug
ECHO = @echo
CC = clang++
BINBASE = -O3 -DNDEBUG
BINFLAGS = -flto $(BINBASE)
LDBINFLAGS= -flto $(BINBASE)
#possible optimizations to consider: fmodulo-sched fmodulo-sched-allow-regmoves
# fgcse-sm fgcse-las fgcse-after-reload
# (funsafe-loop-optimizations Wfunsafe-loop-optimizations)
# fsched-pressure fsched-spec-load fsched-spec-load-dangerous
# fipa-pta (excessive memory) Ofast mfpmath (architecture related, for SSE)
#list all optimizations enabled: -Q --help=optimizers
#diagnostic flags: -fmudflap
#there's also profling optimization options
DEBUGFLAGS= -g -DGRAPHICSDEBUG
WARNINGS = -Wall -Wextra -Wstrict-overflow=5 -Wshadow -Wconversion
INCLUDE = -IServer/
CCFLAGS = $(WARNINGS) $(INCLUDE) -std=c++11
LDSFML = -lsfml-window -lsfml-system -lsfml-audio -lsfml-network -lsfml-graphics
LDFLAGS = $(CCFLAGS) $(LDSFML) -lGL -lGLEW -lassimp
OBJDIR = obj/
DEBUGDIR = $(OBJDIR)debug/
SRCDIRS = Server/ Server/graphics/
SOURCES = $(foreach dir, $(SRCDIRS), $(wildcard $(dir)*.cpp))
OBJS = $(patsubst %.cpp, $(OBJDIR)%.o, $(SOURCES))
DEBUGOBJS = $(patsubst %.cpp, $(DEBUGDIR)%.o, $(SOURCES))
DEPENDENCIES = $(patsubst %.o, %.d, $(OBJS)) $(patsubst %.o, %.d, $(DEBUGOBJS))
.PHONY: all debug clean new
all: $(NAME)
debug: $(DEBUGNAME)
$(DEBUGOBJS): $(DEBUGDIR)%.o: %.cpp
$(ECHO) "Compiling $< debug"
@$(CC) -MMD -MP $(DEBUGFLAGS) $(CCFLAGS) -c -o $@ $<
$(DEBUGNAME): $(DEBUGOBJS)
$(ECHO) "Linking $@..."
# $(ECHO) $(CC) -o $@ $(DEBUGOBJS) -g $(LDFLAGS)
$(CC) -o $@ $(DEBUGOBJS) $(DEBUGFLAGS) $(LDFLAGS)
$(ECHO) "Built $@!"
$(OBJS): $(OBJDIR)%.o: %.cpp
$(ECHO) "Compiling $<"
@$(CC) -MMD -MP $(BINFLAGS) $(CCFLAGS) -c -o $@ $<
-include $(DEPENDENCIES)
$(NAME): $(OBJS)
$(ECHO) "Linking $@..."
# $(ECHO) $(CC) -o $@ $(OBJS) $(LDBINFLAGS) $(LDFLAGS)
$(CC) -o $@ $(OBJS) $(LDBINFLAGS) $(LDFLAGS)
$(ECHO) "Built $@!"
clean:
$(RM) core $(OBJS) $(DEBUGOBJS) $(DEPENDENCIES) $(NAME) $(DEBUGNAME)
$(ECHO) "All clean!"
new:
make clean
make