]> git.sesse.net Git - stockfish/blob - src/Makefile
Simple implementation of strong YBWC
[stockfish] / src / Makefile
1 # Stockfish, a UCI chess playing engine derived from Glaurung 2.1
2 # Copyright (C) 2004-2007 Tord Romstad
3 # Copyright (C) 2008 Marco Costalba
4
5 # This file is part of Stockfish.
6 #
7 # Stockfish is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Stockfish is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 ### Executable name. Do not change
22 EXE = stockfish
23
24 ### Installation dir definitions
25 PREFIX = /usr/local
26 BINDIR = $(PREFIX)/bin
27
28 ### ==========================================================================
29 ### Compiler speed switches for both GCC and ICC. These settings are generally
30 ### fast on a broad range of systems, but may be changed experimentally
31 ### ==========================================================================
32 GCCFLAGS = -O3 -msse
33 ICCFLAGS = -fast -msse
34 ICCFLAGS-OSX = -fast -mdynamic-no-pic
35
36
37 ### ==========================================================================
38 ### Enable/disable debugging, disabled by default
39 ### ==========================================================================
40 GCCFLAGS += -DNDEBUG
41 ICCFLAGS += -DNDEBUG
42 ICCFLAGS-OSX += -DNDEBUG
43
44
45 ### ==========================================================================
46 ### Remove below comments to compile for a big-endian machine
47 ### ==========================================================================
48 #GCCFLAGS += -DBIGENDIAN
49 #ICCFLAGS += -DBIGENDIAN
50 #ICCFLAGS-OSX += -DBIGENDIAN
51
52
53 ### ==========================================================================
54 ### Run built-in benchmark for pgo-builds with:  32MB hash  1 thread  10 depth
55 ### These settings are generally fast, but may be changed experimentally
56 ### ==========================================================================
57 PGOBENCH = ./$(EXE) bench 32 1 10 default depth
58
59 ### General compiler settings. Do not change
60 GCCFLAGS += -g -Wall -fno-exceptions -fno-rtti
61 ICCFLAGS += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
62 ICCFLAGS-OSX += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
63
64
65 ### General linker settings. Do not change
66 LDFLAGS  = -lpthread
67
68
69 ### Object files. Do not change
70 OBJS = application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
71         misc.o move.o movegen.o history.o movepick.o search.o piece.o \
72         position.o direction.o tt.o value.o uci.o ucioption.o \
73         mersenne.o book.o bitbase.o san.o benchmark.o
74
75
76 ### General rules. Do not change
77 default:
78         $(MAKE) gcc
79
80 help:
81         @echo ""
82         @echo "Makefile options:"
83         @echo ""
84         @echo "make                >  Default: Compiler = g++"
85         @echo "make gcc-profile    >  Compiler = g++ + automatic pgo-build"
86         @echo "make gcc-popcnt     >  Compiler = g++ + popcnt-support"
87         @echo "make icc            >  Compiler = icpc"
88         @echo "make icc-profile    >  Compiler = icpc + automatic pgo-build"
89         @echo "make icc-profile-popcnt >  Compiler = icpc + automatic pgo-build + popcnt-support"
90         @echo "make osx-ppc32      >  PPC-Mac OS X 32 bit. Compiler = g++"
91         @echo "make osx-ppc64      >  PPC-Mac OS X 64 bit. Compiler = g++"
92         @echo "make osx-x86        >  x86-Mac OS X 32 bit. Compiler = g++"
93         @echo "make osx-x86_64     >  x86-Mac OS X 64 bit. Compiler = g++"
94         @echo "make osx-icc32      >  x86-Mac OS X 32 bit. Compiler = icpc"
95         @echo "make osx-icc64      >  x86-Mac OS X 64 bit. Compiler = icpc"
96         @echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
97         @echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
98         @echo "make hpux           >  HP-UX. Compiler = aCC"
99         @echo "make strip          >  Strip executable"
100         @echo "make clean          >  Clean up"
101         @echo ""
102
103 all: $(EXE) .depend
104
105 test check: default
106         @$(PGOBENCH)
107
108 clean:
109         $(RM) *.o .depend *~ $(EXE) core bench.txt
110
111
112 ### Possible targets. You may add your own ones here
113 gcc:
114         $(MAKE) \
115         CXX='g++' \
116         CXXFLAGS="$(GCCFLAGS)" \
117         all
118
119 gcc-profile-make:
120         $(MAKE) \
121         CXX='g++' \
122         CXXFLAGS="$(GCCFLAGS)" \
123         CXXFLAGS+='-fprofile-generate' \
124         LDFLAGS="$(LDFLAGS)" \
125         LDFLAGS+=" -lgcov" \
126         all
127
128 gcc-profile-use:
129         $(MAKE) \
130         CXX='g++' \
131         CXXFLAGS="$(GCCFLAGS)" \
132         CXXFLAGS+='-fprofile-use' \
133         all
134
135 gcc-profile:
136         @touch *.cpp *.h
137         $(MAKE) gcc-profile-make
138         @echo ""
139         @echo "Running benchmark for pgo-build ..."
140         @$(PGOBENCH) > /dev/null
141         @echo "Benchmark finished. Build final executable now ..."
142         @echo ""
143         @touch *.cpp *.h
144         $(MAKE) gcc-profile-use
145         @rm -rf *.gcda bench.txt
146
147 gcc-popcnt:
148         $(MAKE) \
149         CXX='g++' \
150         CXXFLAGS="$(GCCFLAGS) -DUSE_POPCNT" \
151         all
152
153 icc:
154         $(MAKE) \
155         CXX='icpc' \
156         CXXFLAGS="$(ICCFLAGS)" \
157         all
158
159 icc-profile-make:
160         $(MAKE) \
161         CXX='icpc' \
162         CXXFLAGS="$(ICCFLAGS)" \
163         CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
164         all
165
166 icc-profile-use:
167         $(MAKE) \
168         CXX='icpc' \
169         CXXFLAGS="$(ICCFLAGS)" \
170         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
171         all
172
173 icc-profile:
174         @rm -rf profdir
175         @mkdir profdir
176         @touch *.cpp *.h
177         $(MAKE) icc-profile-make
178         @echo ""
179         @echo "Running benchmark for pgo-build ..."
180         @$(PGOBENCH) > /dev/null
181         @echo "Benchmark finished. Build final executable now ..."
182         @echo ""
183         @touch *.cpp *.h
184         $(MAKE) icc-profile-use
185         @rm -rf profdir bench.txt
186
187 icc-profile-make-with-popcnt:
188         $(MAKE) \
189         CXX='icpc' \
190         CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
191         CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
192         all
193
194 icc-profile-use-with-popcnt:
195         $(MAKE) \
196         CXX='icpc' \
197         CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
198         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
199         all
200
201 icc-profile-popcnt:
202         @rm -rf profdir
203         @mkdir profdir
204         @touch *.cpp *.h
205         $(MAKE) icc-profile-make
206         @echo ""
207         @echo "Running benchmark for pgo-build (popcnt disabled)..."
208         @$(PGOBENCH) > /dev/null
209         @touch *.cpp *.h
210         $(MAKE) icc-profile-make-with-popcnt
211         @echo ""
212         @echo "Running benchmark for pgo-build (popcnt enabled)..."
213         @$(PGOBENCH) > /dev/null
214         @echo "Benchmarks finished. Build final executable now ..."
215         @echo ""
216         @touch *.cpp *.h
217         $(MAKE) icc-profile-use-with-popcnt
218         @rm -rf profdir bench.txt
219
220
221 osx-ppc32:
222         $(MAKE) \
223         CXX='g++' \
224         CXXFLAGS="$(GCCFLAGS)" \
225         CXXFLAGS+='-arch ppc' \
226         CXXFLAGS+='-DBIGENDIAN' \
227         LDFLAGS+='-arch ppc' \
228         all
229
230 osx-ppc64:
231         $(MAKE) \
232         CXX='g++' \
233         CXXFLAGS="$(GCCFLAGS)" \
234         CXXFLAGS+='-arch ppc64' \
235         CXXFLAGS+='-DBIGENDIAN' \
236         LDFLAGS+='-arch ppc64' \
237         all
238
239 osx-x86:
240         $(MAKE) \
241         CXX='g++' \
242         CXXFLAGS="$(GCCFLAGS)" \
243         CXXFLAGS+='-arch i386 -mdynamic-no-pic' \
244         LDFLAGS+='-arch i386 -mdynamic-no-pic' \
245         all
246
247 osx-x86_64:
248         $(MAKE) \
249         CXX='g++' \
250         CXXFLAGS="$(GCCFLAGS)" \
251         CXXFLAGS+='-arch x86_64 -mdynamic-no-pic' \
252         LDFLAGS+='-arch x86_64 -mdynamic-no-pic' \
253         all
254
255 osx-icc32:
256         $(MAKE) \
257         CXX='icpc' \
258         CXXFLAGS="$(ICCFLAGS-OSX)" \
259         CXXFLAGS+='-arch i386' \
260         LDFLAGS+='-arch i386' \
261         all
262
263 osx-icc64:
264         $(MAKE) \
265         CXX='icpc' \
266         CXXFLAGS="$(ICCFLAGS-OSX)" \
267         CXXFLAGS+='-arch x86_64' \
268         LDFLAGS+='-arch x86_64' \
269         all
270
271 osx-icc32-profile-make:
272         $(MAKE) \
273         CXX='icpc' \
274         CXXFLAGS="$(ICCFLAGS-OSX)" \
275         CXXFLAGS+='-arch i386' \
276         CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
277         LDFLAGS+='-arch i386' \
278         all
279
280 osx-icc32-profile-use:
281         $(MAKE) \
282         CXX='icpc' \
283         CXXFLAGS="$(ICCFLAGS-OSX)" \
284         CXXFLAGS+='-arch i386' \
285         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
286         LDFLAGS+='-arch i386' \
287         all
288
289 osx-icc32-profile:
290         @rm -rf profdir
291         @mkdir profdir
292         @touch *.cpp *.h
293         $(MAKE) osx-icc32-profile-make
294         @echo ""
295         @echo "Running benchmark for pgo-build ..."
296         @$(PGOBENCH) > /dev/null
297         @echo "Benchmark finished. Build final executable now ..."
298         @echo ""
299         @touch *.cpp *.h
300         $(MAKE) osx-icc32-profile-use
301         @rm -rf profdir bench.txt
302
303 osx-icc64-profile-make:
304         $(MAKE) \
305         CXX='icpc' \
306         CXXFLAGS="$(ICCFLAGS-OSX)" \
307         CXXFLAGS+='-arch x86_64' \
308         CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
309         LDFLAGS+='-arch x86_64' \
310         all
311
312 osx-icc64-profile-use:
313         $(MAKE) \
314         CXX='icpc' \
315         CXXFLAGS="$(ICCFLAGS-OSX)" \
316         CXXFLAGS+='-arch x86_64' \
317         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
318         LDFLAGS+='-arch x86_64' \
319         all
320
321 osx-icc64-profile:
322         @rm -rf profdir
323         @mkdir profdir
324         @touch *.cpp *.h
325         $(MAKE) osx-icc64-profile-make
326         @echo ""
327         @echo "Running benchmark for pgo-build ..."
328         @$(PGOBENCH) > /dev/null
329         @echo "Benchmark finished. Build final executable now ..."
330         @echo ""
331         @touch *.cpp *.h
332         $(MAKE) osx-icc64-profile-use
333         @rm -rf profdir bench.txt
334
335 hpux:
336         $(MAKE) \
337         CXX='/opt/aCC/bin/aCC -AA +hpxstd98 -DBIGENDIAN -mt +O3 -DNDEBUG' \
338         CXXFLAGS="" \
339         LDFLAGS="" \
340         all
341
342
343 strip:
344         strip $(EXE)
345
346
347 ### Compilation. Do not change
348 $(EXE): $(OBJS)
349         $(CXX) -o $@ $(OBJS) $(LDFLAGS)
350
351 ### Installation
352 install: default
353         -mkdir -p -m 755 $(BINDIR)
354         -cp $(EXE) $(BINDIR)
355         -strip $(BINDIR)/$(EXE)
356
357 ### Dependencies. Do not change
358 .depend:
359         -@$(CXX) -msse -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null
360
361 -include .depend