forked from pasky/pachi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
175 lines (134 loc) · 4.6 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#### CONFIGURATION
# Uncomment one of the options below to change the way Pachi is built.
# Alternatively, you can pass the option to make itself, like:
# make MAC=1 DOUBLE_FLOATING=1
# Do you compile on Windows instead of Linux? Please note that the
# performance may not be optimal.
# (XXX: For now, only the mingw target is supported on Windows.
# Patches for others are welcome!)
# WIN=1
# To compile 64-bit version in msys2 with mingw64, uncomment the
# following line
# MSYS2_64=1
# Do you compile on MacOS/X instead of Linux? Please note that the
# performance may not be optimal.
# (XXX: We are looking for volunteers contributing support for other
# targets, like mingw/Windows.)
# MAC=1
# Compile Pachi with dcnn support ?
# You'll need to install Boost and Caffe libraries.
# If Caffe is in a custom directory you can set it here.
#DCNN=1
#CAFFE_PREFIX=/usr/local
# By default, Pachi uses low-precision numbers within the game tree to
# conserve memory. This can become an issue with playout counts >1M,
# e.g. with extremely long thinking times or massive parallelization;
# 24 bits of floating_t mantissa become insufficient then.
# DOUBLE_FLOATING=1
# Enable performance profiling using gprof. Note that this also disables
# inlining, which allows more fine-grained profile, but may also distort
# it somewhat.
# PROFILING=gprof
# Enable performance profiling using google-perftools. This is much
# more accurate, fine-grained and nicer than gprof and does not change
# the way the actual binary is compiled and runs.
# PROFILING=perftools
# Target directories when running `make install`. Note that this is NOT
# quite supported yet - Pachi will work fine, but will always look for
# extra data files (such as pattern, joseki or fuseki database) only
# in the current directory, bundled database files will not be installed
# in a system directory or loaded from there.
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
# Generic compiler options. You probably do not really want to twiddle
# any of this.
# (N.B. -ffast-math breaks us; -fomit-frame-pointer is added below
# unless PROFILING=gprof.)
CUSTOM_CFLAGS?=-Wall -ggdb3 -O3 -std=gnu99 -frename-registers -pthread -Wsign-compare -D_GNU_SOURCE
CUSTOM_CXXFLAGS?=-Wall -ggdb3 -O3
### CONFIGURATION END
ifdef MSYS2_64
WIN=1
WIN_HAVE_NO_REGEX_SUPPORT=1
DOUBLE_FLOATING=1
endif
ifdef WIN
SYS_CFLAGS?=
SYS_LDFLAGS?=-pthread
SYS_LIBS?=-lm -lws2_32
ifdef WIN_HAVE_NO_REGEX_SUPPORT
SYS_CFLAGS += -DHAVE_NO_REGEX_SUPPORT
else
SYS_LIBS += -lregex
endif
else
ifdef MAC
SYS_CFLAGS?=-DNO_THREAD_LOCAL
SYS_LDFLAGS?=-pthread -rdynamic
SYS_LIBS?=-lm -ldl
else
SYS_CFLAGS?=-march=native
SYS_LDFLAGS?=-pthread -rdynamic
SYS_LIBS?=-lm -lrt -ldl
endif
endif
ifdef CAFFE_PREFIX
SYS_LDFLAGS+=-L$(CAFFE_PREFIX)/lib -Wl,-rpath=$(CAFFE_PREFIX)/lib
CXXFLAGS+=-I$(CAFFE_PREFIX)/include
endif
ifdef DCNN
CUSTOM_CFLAGS+=-DDCNN
CUSTOM_CXXFLAGS+=-DDCNN
SYS_LIBS:=-lcaffe -lboost_system -lstdc++ $(SYS_LIBS)
endif
ifdef DOUBLE_FLOATING
CUSTOM_CFLAGS+=-DDOUBLE_FLOATING
endif
ifeq ($(PROFILING), gprof)
CUSTOM_LDFLAGS+=-pg
CUSTOM_CFLAGS+=-pg -fno-inline
else
# Whee, an extra register!
CUSTOM_CFLAGS+=-fomit-frame-pointer
ifeq ($(PROFILING), perftools)
SYS_LIBS+=-lprofiler
endif
endif
ifndef LD
LD=ld
endif
ifndef AR
AR=ar
endif
ifndef INSTALL
INSTALL=/usr/bin/install
endif
export
unexport INCLUDES
INCLUDES=-I.
OBJS=board.o gtp.o move.o ownermap.o pattern3.o pattern.o patternsp.o patternprob.o playout.o probdist.o random.o stone.o timeinfo.o network.o fbook.o chat.o
ifdef DCNN
OBJS+=dcnn.o
endif
SUBDIRS=random replay patternscan patternplay joseki montecarlo uct uct/policy playout tactics t-unit distributed
all: all-recursive pachi
LOCALLIBS=random/random.a replay/replay.a patternscan/patternscan.a patternplay/patternplay.a joseki/joseki.a montecarlo/montecarlo.a uct/uct.a uct/policy/uctpolicy.a playout/playout.a t-unit/test.a tactics/tactics.a distributed/distributed.a
$(LOCALLIBS): all-recursive
@
pachi: $(OBJS) pachi.o $(LOCALLIBS)
$(call cmd,link)
# Use runtime gcc profiling for extra optimization. This used to be a large
# bonus but nowadays, it's rarely worth the trouble.
.PHONY: pachi-profiled
pachi-profiled:
@make clean all XLDFLAGS=-fprofile-generate XCFLAGS="-fprofile-generate -fomit-frame-pointer -frename-registers"
./pachi -t =5000 no_tbook <tools/genmove19.gtp
@make clean all clean-profiled XLDFLAGS=-fprofile-use XCFLAGS="-fprofile-use -fomit-frame-pointer -frename-registers"
# install-recursive?
install:
$(INSTALL) ./pachi $(DESTDIR)$(BINDIR)
clean: clean-recursive
rm -f pachi *.o
clean-profiled: clean-profiled-recursive
rm -f *.gcda *.gcno
-include Makefile.lib