forked from sangmichaelxie/giraffe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (85 loc) · 2.27 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
CXX=g++-4.9
# this is used to build gtb only
CC=gcc-4.9
HGVERSION:= $(shell hg parents --template '{node|short}')
CXXFLAGS_BASE = \
-Wall -Wextra -Wno-unused-function -std=gnu++11 -mtune=native -Wa,-q -ffast-math \
-pthread -fopenmp -DHGVERSION="\"${HGVERSION}\""
# we will then extend this one with optimization flags
CXXFLAGS:= $(CXXFLAGS_BASE)
CXXFLAGS_DEP = \
-std=gnu++11
#LDFLAGS=-L. -Lgtb -lm -ltcmalloc -lgtb
LDFLAGS=-L. -Lgtb -lm -lgtb
ifeq ($(PG), 1)
CXXFLAGS += -g -O2 -pg
else ifeq ($(DEBUG),1)
CXXFLAGS += -g -O0
else
CXXFLAGS += -O3 -flto
endif
ifeq ($(CLUSTER), 1)
CXXFLAGS += -march=sandybridge -static
LDFLAGS += -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
LDFLAGS := $(filter-out -ltcmalloc,$(LDFLAGS))
else
CXXFLAGS += -march=native
endif
CXXFILES := \
$(wildcard *.cpp) \
$(wildcard ann/*.cpp) \
$(wildcard eval/*.cpp)
INCLUDES=-I.
EXE=giraffe
OBJS := $(CXXFILES:%.cpp=obj/%.o)
DEPS := $(CXXFILES:%.cpp=dep/%.d)
ifeq ($(V),0)
Q = @
else
Q =
endif
ifeq ($(OS),Windows_NT)
# mingw builds crash with LTO
CXXFLAGS := $(filter-out -flto,$(CXXFLAGS))
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
endif
ifeq ($(UNAME_S),Darwin)
# OSX needs workaround for AVX, and LTO is broken
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47785
CXXFLAGS += -Wa,-q
CXXFLAGS := $(filter-out -flto,$(CXXFLAGS))
endif
endif
.PHONY: clean test windows
default: $(EXE)
dep/%.d: %.cpp
$(Q) $(CXX) $(CXXFLAGS_DEP) $(INCLUDES) $< -MM -MT $(@:dep/%.d=obj/%.o) > $@
obj/%.o :
$(Q) $(CXX) $(CXXFLAGS) $(INCLUDES) -c $(@:obj/%.o=%.cpp) -o $@
$(EXE): $(OBJS) gtb/libgtb.a
$(Q) $(CXX) $(CXXFLAGS) $(OBJS) -o $(EXE) $(LDFLAGS)
gtb/libgtb.a:
$(Q) cd gtb && CC=$(CC) make
test:
$(Q) echo $(DEPS)
clean:
-$(Q) rm -f $(DEPS) $(OBJS) $(EXE)
windows:
$(Q) cd gtb && make windows_clean && make CFLAGS=-m32
g++ $(CXXFLAGS_BASE) -m32 $(INCLUDES) -O3 -static $(CXXFILES) -o giraffe_w32.exe -Lgtb -lgtb
strip -g -s giraffe_w32.exe
$(Q) cd gtb && make windows_clean && make CFLAGS=-m64
g++ $(CXXFLAGS_BASE) -m64 $(INCLUDES) -O3 -static $(CXXFILES) -o giraffe_w64.exe -Lgtb -lgtb
strip -g -s giraffe_w64.exe
no_deps =
ifneq ($(MAKECMDGOALS),clean)
no_deps = yes
endif
ifneq ($(MAKECMDGOALS),windows)
no_deps = yes
endif
ifndef no_deps
-include $(DEPS)
endif