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
5 # This file is part of Stockfish.
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.
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.
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/>.
21 ### Executable name. Do not change
25 ### ==========================================================================
26 ### Compiler speed switches for both GCC and ICC. These settings are generally
27 ### fast on a broad range of systems, but may be changed experimentally
28 ### ==========================================================================
30 ICCFLAGS = -fast -msse
31 ICCFLAGS-OSX = -fast -mdynamic-no-pic
34 ### ==========================================================================
35 ### Enable/disable debugging, disabled by default
36 ### ==========================================================================
39 ICCFLAGS-OSX += -DNDEBUG
42 ### ==========================================================================
43 ### Remove below comments to compile for a big-endian machine
44 ### ==========================================================================
45 #GCCFLAGS += -DBIGENDIAN
46 #ICCFLAGS += -DBIGENDIAN
47 #ICCFLAGS-OSX += -DBIGENDIAN
50 ### ==========================================================================
51 ### Run built-in benchmark for pgo-builds with: 32MB hash 1 thread 10 depth
52 ### These settings are generally fast, but may be changed experimentally
53 ### ==========================================================================
54 PGOBENCH = ./$(EXE) bench 32 1 10 default depth
57 ### General compiler settings. Do not change
58 GCCFLAGS += -g -Wall -fno-exceptions -fno-rtti
59 ICCFLAGS += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
60 ICCFLAGS-OSX += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
63 ### General linker settings. Do not change
67 ### Object files. Do not change
68 OBJS = application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
69 misc.o move.o movegen.o history.o movepick.o search.o piece.o \
70 position.o direction.o tt.o value.o uci.o ucioption.o \
71 mersenne.o book.o bitbase.o san.o benchmark.o
74 ### General rules. Do not change
80 @echo "Makefile options:"
82 @echo "make > Default: Compiler = g++"
83 @echo "make gcc-popcnt > Compiler = g++ + popcnt-support"
84 @echo "make icc > Compiler = icpc"
85 @echo "make icc-profile > Compiler = icpc + automatic pgo-build"
86 @echo "make icc-profile-popcnt > Compiler = icpc + automatic pgo-build + popcnt-support"
87 @echo "make osx-ppc32 > PPC-Mac OS X 32 bit. Compiler = g++"
88 @echo "make osx-ppc64 > PPC-Mac OS X 64 bit. Compiler = g++"
89 @echo "make osx-x86 > x86-Mac OS X 32 bit. Compiler = g++"
90 @echo "make osx-x86_64 > x86-Mac OS X 64 bit. Compiler = g++"
91 @echo "make osx-icc32 > x86-Mac OS X 32 bit. Compiler = icpc"
92 @echo "make osx-icc64 > x86-Mac OS X 64 bit. Compiler = icpc"
93 @echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
94 @echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
95 @echo "make strip > Strip executable"
96 @echo "make clean > Clean up"
102 $(RM) *.o .depend *~ $(EXE)
105 ### Possible targets. You may add your own ones here
109 CXXFLAGS="$(GCCFLAGS)" \
115 CXXFLAGS="$(GCCFLAGS) -DUSE_POPCNT" \
122 CXXFLAGS="$(ICCFLAGS)" \
128 CXXFLAGS="$(ICCFLAGS)" \
129 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
135 CXXFLAGS="$(ICCFLAGS)" \
136 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
143 $(MAKE) icc-profile-make
145 @echo "Running benchmark for pgo-build ..."
146 @$(PGOBENCH) > /dev/null
147 @echo "Benchmark finished. Build final executable now ..."
150 $(MAKE) icc-profile-use
151 @rm -rf profdir bench.txt
153 icc-profile-make-with-popcnt:
156 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
157 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
160 icc-profile-use-with-popcnt:
163 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
164 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
171 $(MAKE) icc-profile-make
173 @echo "Running benchmark for pgo-build (popcnt disabled)..."
174 @$(PGOBENCH) > /dev/null
176 $(MAKE) icc-profile-make-with-popcnt
178 @echo "Running benchmark for pgo-build (popcnt enabled)..."
179 @$(PGOBENCH) > /dev/null
180 @echo "Benchmarks finished. Build final executable now ..."
183 $(MAKE) icc-profile-use-with-popcnt
184 @rm -rf profdir bench.txt
190 CXXFLAGS="$(GCCFLAGS)" \
191 CXXFLAGS+='-arch ppc' \
192 LDFLAGS+='-arch ppc' \
198 CXXFLAGS="$(GCCFLAGS)" \
199 CXXFLAGS+='-arch ppc64' \
200 LDFLAGS+='-arch ppc64' \
206 CXXFLAGS="$(GCCFLAGS)" \
207 CXXFLAGS+='-arch i386' \
208 LDFLAGS+='-arch i386' \
214 CXXFLAGS="$(GCCFLAGS)" \
215 CXXFLAGS+='-arch x86_64' \
216 LDFLAGS+='-arch x86_64' \
222 CXXFLAGS="$(ICCFLAGS-OSX)" \
223 CXXFLAGS+='-arch i386' \
224 LDFLAGS+='-arch i386' \
230 CXXFLAGS="$(ICCFLAGS-OSX)" \
231 CXXFLAGS+='-arch x86_64' \
232 LDFLAGS+='-arch x86_64' \
235 osx-icc32-profile-make:
238 CXXFLAGS="$(ICCFLAGS-OSX)" \
239 CXXFLAGS+='-arch i386' \
240 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
241 LDFLAGS+='-arch i386' \
244 osx-icc32-profile-use:
247 CXXFLAGS="$(ICCFLAGS-OSX)" \
248 CXXFLAGS+='-arch i386' \
249 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
250 LDFLAGS+='-arch i386' \
257 $(MAKE) osx-icc32-profile-make
259 @echo "Running benchmark for pgo-build ..."
260 @$(PGOBENCH) > /dev/null
261 @echo "Benchmark finished. Build final executable now ..."
264 $(MAKE) osx-icc32-profile-use
265 @rm -rf profdir bench.txt
267 osx-icc64-profile-make:
270 CXXFLAGS="$(ICCFLAGS-OSX)" \
271 CXXFLAGS+='-arch x86_64' \
272 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
273 LDFLAGS+='-arch x86_64' \
276 osx-icc64-profile-use:
279 CXXFLAGS="$(ICCFLAGS-OSX)" \
280 CXXFLAGS+='-arch x86_64' \
281 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
282 LDFLAGS+='-arch x86_64' \
289 $(MAKE) osx-icc64-profile-make
291 @echo "Running benchmark for pgo-build ..."
292 @$(PGOBENCH) > /dev/null
293 @echo "Benchmark finished. Build final executable now ..."
296 $(MAKE) osx-icc64-profile-use
297 @rm -rf profdir bench.txt
305 ### Compilation. Do not change
307 $(CXX) $(LDFLAGS) -o $@ $(OBJS)
310 ### Dependencies. Do not change
312 $(CXX) -msse -MM $(OBJS:.o=.cpp) > $@