Merge branch 'master' into dynk2
[pachi.git] / Makefile
blob44515f0b0582b933f37efc687495827a7ff0ed02
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 MacOS/X instead of Linux? Please note that the
9 # performance may not be optimal.
10 # (XXX: We are looking for volunteers contributing support for other
11 # targets, like mingw/Windows.)
13 # MAC=1
15 # By default, Pachi uses low-precision numbers within the game tree to
16 # conserve memory. This can become an issue with playout counts >1M,
17 # e.g. with extremely long thinking times or massive parallelization;
18 # 24 bits of floating_t mantissa become insufficient then.
20 # DOUBLE=1
22 # Enable performance profiling using gprof. Note that this also disables
23 # inlining, which allows more fine-grained profile, but may also distort
24 # it somewhat.
26 # PROFILING=gprof
28 # Enable performance profiling using google-perftools. This is much
29 # more accurate, fine-grained and nicer than gprof and does not change
30 # the way the actual binary is compiled and runs.
32 # PROFILING=perftools
35 # Target directories when running `make install`. Note that this is NOT
36 # quite supported yet - Pachi will work fine, but will always look for
37 # extra data files (such as pattern, joseki or fuseki database) only
38 # in the current directory, bundled database files will not be installed
39 # in a system directory or loaded from there.
40 PREFIX=/usr/local
41 BINDIR=$(PREFIX)/bin
43 # Generic compiler options. You probably do not really want to twiddle
44 # any of this.
45 # (N.B. -ffast-math breaks us; -fomit-frame-pointer is added below
46 # unless PROFILING=gprof.)
47 CUSTOM_CFLAGS=-Wall -ggdb3 -O3 -std=gnu99 -frename-registers -pthread -Wsign-compare -D_GNU_SOURCE
49 ### CONFIGURATION END
52 ifdef MAC
53 SYS_CFLAGS=-DNO_THREAD_LOCAL
54 LDFLAGS=-lm -pthread -ldl -rdynamic
55 else
56 SYS_CFLAGS=-march=native
57 LDFLAGS=-lm -pthread -lrt -ldl -rdynamic
58 endif
60 ifdef DOUBLE
61 CUSTOM_CFLAGS+=-DDOUBLE
62 endif
64 ifeq ($(PROFILING), gprof)
65 LDFLAGS+=-pg
66 CUSTOM_CFLAGS+=-pg -fno-inline
67 else
68 # Whee, an extra register!
69 CUSTOM_CFLAGS+=-fomit-frame-pointer
70 ifeq ($(PROFILING), perftools)
71 LDFLAGS+=-lprofiler
72 endif
73 endif
75 ifndef LD
76 LD=ld
77 endif
79 ifndef AR
80 AR=ar
81 endif
83 ifndef INSTALL
84 INSTALL=/usr/bin/install
85 endif
87 export
88 unexport INCLUDES
89 INCLUDES=-I.
92 OBJS=board.o gtp.o move.o ownermap.o pattern3.o playout.o probdist.o random.o stone.o timeinfo.o network.o fbook.o
93 SUBDIRS=random replay joseki montecarlo uct uct/policy playout tactics t-unit distributed
95 all: all-recursive pachi
97 LOCALLIBS=random/random.a replay/replay.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
98 $(LOCALLIBS): all-recursive
100 pachi: $(OBJS) pachi.o $(LOCALLIBS)
101 $(call cmd,link)
103 # Use runtime gcc profiling for extra optimization. This used to be a large
104 # bonus but nowadays, it's rarely worth the trouble.
105 .PHONY: pachi-profiled
106 pachi-profiled:
107 @make clean all XLDFLAGS=-fprofile-generate XCFLAGS="-fprofile-generate -fomit-frame-pointer -frename-registers"
108 ./pachi -t =5000 no_tbook <tools/genmove19.gtp
109 @make clean all clean-profiled XLDFLAGS=-fprofile-use XCFLAGS="-fprofile-use -fomit-frame-pointer -frename-registers"
111 # install-recursive?
112 install:
113 $(INSTALL) ./pachi $(DESTDIR)$(BINDIR)
116 clean: clean-recursive
117 rm -f pachi *.o
119 clean-profiled: clean-profiled-recursive
120 rm -f *.gcda *.gcno
122 -include Makefile.lib