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 maxgain.o 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 icc > Compiler = icpc"
84 @echo "make icc-profile > Compiler = icpc + automatic pgo-build"
85 @echo "make icc-profile-popcnt > Compiler = icpc + automatic pgo-build + popcnt-support"
86 @echo "make osx-ppc32 > PPC-Mac OS X 32 bit. Compiler = g++"
87 @echo "make osx-ppc64 > PPC-Mac OS X 64 bit. Compiler = g++"
88 @echo "make osx-x86 > x86-Mac OS X 32 bit. Compiler = g++"
89 @echo "make osx-x86_64 > x86-Mac OS X 64 bit. Compiler = g++"
90 @echo "make osx-icc32 > x86-Mac OS X 32 bit. Compiler = icpc"
91 @echo "make osx-icc64 > x86-Mac OS X 64 bit. Compiler = icpc"
92 @echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
93 @echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
94 @echo "make strip > Strip executable"
95 @echo "make clean > Clean up"
101 $(RM) *.o .depend *~ $(EXE)
104 ### Possible targets. You may add your own ones here
108 CXXFLAGS="$(GCCFLAGS)" \
114 CXXFLAGS="$(ICCFLAGS)" \
120 CXXFLAGS="$(ICCFLAGS)" \
121 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
127 CXXFLAGS="$(ICCFLAGS)" \
128 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
135 $(MAKE) icc-profile-make
137 @echo "Running benchmark for pgo-build ..."
138 @$(PGOBENCH) > /dev/null
139 @echo "Benchmark finished. Build final executable now ..."
142 $(MAKE) icc-profile-use
143 @rm -rf profdir bench.txt
145 icc-profile-make-with-popcnt:
148 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
149 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
152 icc-profile-use-with-popcnt:
155 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
156 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
163 $(MAKE) icc-profile-make
165 @echo "Running benchmark for pgo-build (popcnt disabled)..."
166 @$(PGOBENCH) > /dev/null
168 $(MAKE) icc-profile-make-with-popcnt
170 @echo "Running benchmark for pgo-build (popcnt enabled)..."
171 @$(PGOBENCH) > /dev/null
172 @echo "Benchmarks finished. Build final executable now ..."
175 $(MAKE) icc-profile-use-with-popcnt
176 @rm -rf profdir bench.txt
182 CXXFLAGS="$(GCCFLAGS)" \
183 CXXFLAGS+='-arch ppc' \
184 LDFLAGS+='-arch ppc' \
190 CXXFLAGS="$(GCCFLAGS)" \
191 CXXFLAGS+='-arch ppc64' \
192 LDFLAGS+='-arch ppc64' \
198 CXXFLAGS="$(GCCFLAGS)" \
199 CXXFLAGS+='-arch i386' \
200 LDFLAGS+='-arch i386' \
206 CXXFLAGS="$(GCCFLAGS)" \
207 CXXFLAGS+='-arch x86_64' \
208 LDFLAGS+='-arch x86_64' \
214 CXXFLAGS="$(ICCFLAGS-OSX)" \
215 CXXFLAGS+='-arch i386' \
216 LDFLAGS+='-arch i386' \
222 CXXFLAGS="$(ICCFLAGS-OSX)" \
223 CXXFLAGS+='-arch x86_64' \
224 LDFLAGS+='-arch x86_64' \
227 osx-icc32-profile-make:
230 CXXFLAGS="$(ICCFLAGS-OSX)" \
231 CXXFLAGS+='-arch i386' \
232 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
233 LDFLAGS+='-arch i386' \
236 osx-icc32-profile-use:
239 CXXFLAGS="$(ICCFLAGS-OSX)" \
240 CXXFLAGS+='-arch i386' \
241 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
242 LDFLAGS+='-arch i386' \
249 $(MAKE) osx-icc32-profile-make
251 @echo "Running benchmark for pgo-build ..."
252 @$(PGOBENCH) > /dev/null
253 @echo "Benchmark finished. Build final executable now ..."
256 $(MAKE) osx-icc32-profile-use
257 @rm -rf profdir bench.txt
259 osx-icc64-profile-make:
262 CXXFLAGS="$(ICCFLAGS-OSX)" \
263 CXXFLAGS+='-arch x86_64' \
264 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
265 LDFLAGS+='-arch x86_64' \
268 osx-icc64-profile-use:
271 CXXFLAGS="$(ICCFLAGS-OSX)" \
272 CXXFLAGS+='-arch x86_64' \
273 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
274 LDFLAGS+='-arch x86_64' \
281 $(MAKE) osx-icc64-profile-make
283 @echo "Running benchmark for pgo-build ..."
284 @$(PGOBENCH) > /dev/null
285 @echo "Benchmark finished. Build final executable now ..."
288 $(MAKE) osx-icc64-profile-use
289 @rm -rf profdir bench.txt
297 ### Compilation. Do not change
299 $(CXX) $(LDFLAGS) -o $@ $(OBJS)
302 ### Dependencies. Do not change
304 $(CXX) -MM $(OBJS:.o=.cpp) > $@