Merge pull request #28 from lemonsqueeze/dcnn
[pachi.git] / Makefile
blob31c6f768e3b3e1a6fa0f1e1bb04806206b4b8736
1 #### CONFIGURATION
3 # Uncomment one of the options below to change the way Pachi is built.
4 # Alternatively, you can pass the option to make itself, like:
5 # make MAC=1 DOUBLE=1
8 # Do you compile on Windows instead of Linux? Please note that the
9 # performance may not be optimal.
10 # (XXX: For now, only the mingw target is supported on Windows.
11 # Patches for others are welcome!)
13 # WIN=1
15 # Do you compile on MacOS/X instead of Linux? Please note that the
16 # performance may not be optimal.
17 # (XXX: We are looking for volunteers contributing support for other
18 # targets, like mingw/Windows.)
20 # MAC=1
22 # Compile Pachi with dcnn support ?
23 # You'll need to install Boost and Caffe libraries.
24 # If Caffe is in a custom directory you can set it here.
26 #DCNN=1
27 #CAFFE_LIB=/usr/local/lib
29 # By default, Pachi uses low-precision numbers within the game tree to
30 # conserve memory. This can become an issue with playout counts >1M,
31 # e.g. with extremely long thinking times or massive parallelization;
32 # 24 bits of floating_t mantissa become insufficient then.
34 # DOUBLE=1
36 # Enable performance profiling using gprof. Note that this also disables
37 # inlining, which allows more fine-grained profile, but may also distort
38 # it somewhat.
40 # PROFILING=gprof
42 # Enable performance profiling using google-perftools. This is much
43 # more accurate, fine-grained and nicer than gprof and does not change
44 # the way the actual binary is compiled and runs.
46 # PROFILING=perftools
49 # Target directories when running `make install`. Note that this is NOT
50 # quite supported yet - Pachi will work fine, but will always look for
51 # extra data files (such as pattern, joseki or fuseki database) only
52 # in the current directory, bundled database files will not be installed
53 # in a system directory or loaded from there.
54 PREFIX=/usr/local
55 BINDIR=$(PREFIX)/bin
57 # Generic compiler options. You probably do not really want to twiddle
58 # any of this.
59 # (N.B. -ffast-math breaks us; -fomit-frame-pointer is added below
60 # unless PROFILING=gprof.)
61 CUSTOM_CFLAGS?=-Wall -ggdb3 -O3 -std=gnu99 -frename-registers -pthread -Wsign-compare -D_GNU_SOURCE
62 CUSTOM_CXXFLAGS?=-Wall -ggdb3 -O3
64 ### CONFIGURATION END
67 ifdef WIN
68 SYS_CFLAGS?=
69 SYS_LDFLAGS?=-pthread
70 SYS_LIBS?=-lm -lws2_32
72 ifdef WIN_HAVE_NO_REGEX_SUPPORT
73 SYS_CFLAGS += -DHAVE_NO_REGEX_SUPPORT
74 else
75 SYS_LIBS += -lregex
76 endif
78 else
79 ifdef MAC
80 SYS_CFLAGS?=-DNO_THREAD_LOCAL
81 SYS_LDFLAGS?=-pthread -rdynamic
82 SYS_LIBS?=-lm -ldl
83 else
84 SYS_CFLAGS?=-march=native
85 SYS_LDFLAGS?=-pthread -rdynamic
86 SYS_LIBS?=-lm -lrt -ldl
87 endif
88 endif
90 ifdef CAFFE_LIB
91 SYS_LDFLAGS+=-L$(CAFFE_LIB)
92 endif
94 ifdef DCNN
95 CUSTOM_CFLAGS+=-DDCNN
96 CUSTOM_CXXFLAGS+=-DDCNN
97 SYS_LIBS:=-lcaffe -lboost_system -lstdc++ $(SYS_LIBS)
98 endif
100 ifdef DOUBLE
101 CUSTOM_CFLAGS+=-DDOUBLE
102 endif
104 ifeq ($(PROFILING), gprof)
105 CUSTOM_LDFLAGS+=-pg
106 CUSTOM_CFLAGS+=-pg -fno-inline
107 else
108 # Whee, an extra register!
109 CUSTOM_CFLAGS+=-fomit-frame-pointer
110 ifeq ($(PROFILING), perftools)
111 SYS_LIBS+=-lprofiler
112 endif
113 endif
115 ifndef LD
116 LD=ld
117 endif
119 ifndef AR
120 AR=ar
121 endif
123 ifndef INSTALL
124 INSTALL=/usr/bin/install
125 endif
127 export
128 unexport INCLUDES
129 INCLUDES=-I.
132 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
133 ifdef DCNN
134 OBJS+=dcnn.o
135 endif
136 SUBDIRS=random replay patternscan patternplay joseki montecarlo uct uct/policy playout tactics t-unit distributed
138 all: all-recursive pachi
140 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 tactics/tactics.a t-unit/test.a distributed/distributed.a
141 $(LOCALLIBS): all-recursive
143 pachi: $(OBJS) pachi.o $(LOCALLIBS)
144 $(call cmd,link)
146 # Use runtime gcc profiling for extra optimization. This used to be a large
147 # bonus but nowadays, it's rarely worth the trouble.
148 .PHONY: pachi-profiled
149 pachi-profiled:
150 @make clean all XLDFLAGS=-fprofile-generate XCFLAGS="-fprofile-generate -fomit-frame-pointer -frename-registers"
151 ./pachi -t =5000 no_tbook <tools/genmove19.gtp
152 @make clean all clean-profiled XLDFLAGS=-fprofile-use XCFLAGS="-fprofile-use -fomit-frame-pointer -frename-registers"
154 # install-recursive?
155 install:
156 $(INSTALL) ./pachi $(DESTDIR)$(BINDIR)
159 clean: clean-recursive
160 rm -f pachi *.o
162 clean-profiled: clean-profiled-recursive
163 rm -f *.gcda *.gcno
165 -include Makefile.lib