Merge branch 'patterns'
[pachi/nmclean.git] / Makefile
blobb6b45aba0d6f3261986a48f13cedb5176be99aa6
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=-pthread -rdynamic
55 LIBS=-lm -ldl
56 else
57 SYS_CFLAGS=-march=native
58 LDFLAGS=-pthread -rdynamic
59 LIBS=-lm -lrt -ldl
60 endif
62 ifdef DOUBLE
63 CUSTOM_CFLAGS+=-DDOUBLE
64 endif
66 ifeq ($(PROFILING), gprof)
67 LDFLAGS+=-pg
68 CUSTOM_CFLAGS+=-pg -fno-inline
69 else
70 # Whee, an extra register!
71 CUSTOM_CFLAGS+=-fomit-frame-pointer
72 ifeq ($(PROFILING), perftools)
73 LIBS+=-lprofiler
74 endif
75 endif
77 ifndef LD
78 LD=ld
79 endif
81 ifndef AR
82 AR=ar
83 endif
85 ifndef INSTALL
86 INSTALL=/usr/bin/install
87 endif
89 export
90 unexport INCLUDES
91 INCLUDES=-I.
94 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
95 SUBDIRS=random replay patternscan patternplay joseki montecarlo uct uct/policy playout tactics t-unit distributed
97 all: all-recursive pachi
99 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
100 $(LOCALLIBS): all-recursive
102 pachi: $(OBJS) pachi.o $(LOCALLIBS)
103 $(call cmd,link)
105 # Use runtime gcc profiling for extra optimization. This used to be a large
106 # bonus but nowadays, it's rarely worth the trouble.
107 .PHONY: pachi-profiled
108 pachi-profiled:
109 @make clean all XLDFLAGS=-fprofile-generate XCFLAGS="-fprofile-generate -fomit-frame-pointer -frename-registers"
110 ./pachi -t =5000 no_tbook <tools/genmove19.gtp
111 @make clean all clean-profiled XLDFLAGS=-fprofile-use XCFLAGS="-fprofile-use -fomit-frame-pointer -frename-registers"
113 # install-recursive?
114 install:
115 $(INSTALL) ./pachi $(DESTDIR)$(BINDIR)
118 clean: clean-recursive
119 rm -f pachi *.o
121 clean-profiled: clean-profiled-recursive
122 rm -f *.gcda *.gcno
124 -include Makefile.lib