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
29 ### NOTE: Some versions of gcc miscompile value.h with -O2 or -O3, this is the
30 ### safe setup, try changing to -O3 or -O2 and verify it works for you.
31 ### ==========================================================================
33 ICCFLAGS = -fast -msse
34 ICCFLAGS-OSX = -fast -mdynamic-no-pic
37 ### ==========================================================================
38 ### Enable/disable debugging, disabled by default
39 ### ==========================================================================
42 ICCFLAGS-OSX += -DNDEBUG
45 ### ==========================================================================
46 ### Remove below comments to compile for a big-endian machine
47 ### ==========================================================================
48 #GCCFLAGS += -DBIGENDIAN
49 #ICCFLAGS += -DBIGENDIAN
50 #ICCFLAGS-OSX += -DBIGENDIAN
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
60 ### General compiler settings. Do not change
61 GCCFLAGS += -g -Wall -fno-exceptions -fno-rtti
62 ICCFLAGS += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
63 ICCFLAGS-OSX += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
66 ### General linker settings. Do not change
70 ### Object files. Do not change
71 OBJS = application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
72 misc.o move.o movegen.o history.o movepick.o search.o piece.o \
73 position.o direction.o tt.o value.o uci.o ucioption.o \
74 mersenne.o book.o bitbase.o san.o benchmark.o
77 ### General rules. Do not change
83 @echo "Makefile options:"
85 @echo "make > Default: Compiler = g++"
86 @echo "make icc > Compiler = icpc"
87 @echo "make icc-profile > Compiler = icpc + automatic pgo-build"
88 @echo "make icc-profile-popcnt > Compiler = icpc + automatic pgo-build + popcnt-support"
89 @echo "make osx-ppc32 > PPC-Mac OS X 32 bit. Compiler = g++"
90 @echo "make osx-ppc64 > PPC-Mac OS X 64 bit. Compiler = g++"
91 @echo "make osx-x86 > x86-Mac OS X 32 bit. Compiler = g++"
92 @echo "make osx-x86_64 > x86-Mac OS X 64 bit. Compiler = g++"
93 @echo "make osx-icc32 > x86-Mac OS X 32 bit. Compiler = icpc"
94 @echo "make osx-icc64 > x86-Mac OS X 64 bit. Compiler = icpc"
95 @echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
96 @echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
97 @echo "make strip > Strip executable"
98 @echo "make clean > Clean up"
104 $(RM) *.o .depend *~ $(EXE)
107 ### Possible targets. You may add your own ones here
111 CXXFLAGS="$(GCCFLAGS)" \
117 CXXFLAGS="$(ICCFLAGS)" \
123 CXXFLAGS="$(ICCFLAGS)" \
124 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
130 CXXFLAGS="$(ICCFLAGS)" \
131 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
138 $(MAKE) icc-profile-make
140 @echo "Running benchmark for pgo-build ..."
141 @$(PGOBENCH) > /dev/null
142 @echo "Benchmark finished. Build final executable now ..."
145 $(MAKE) icc-profile-use
146 @rm -rf profdir bench.txt
148 icc-profile-make-with-popcnt:
151 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
152 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
155 icc-profile-use-with-popcnt:
158 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
159 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
166 $(MAKE) icc-profile-make
168 @echo "Running benchmark for pgo-build (popcnt disabled)..."
169 @$(PGOBENCH) > /dev/null
171 $(MAKE) icc-profile-make-with-popcnt
173 @echo "Running benchmark for pgo-build (popcnt enabled)..."
174 @$(PGOBENCH) > /dev/null
175 @echo "Benchmarks finished. Build final executable now ..."
178 $(MAKE) icc-profile-use-with-popcnt
179 @rm -rf profdir bench.txt
185 CXXFLAGS="$(GCCFLAGS)" \
186 CXXFLAGS+='-arch ppc' \
187 LDFLAGS+='-arch ppc' \
193 CXXFLAGS="$(GCCFLAGS)" \
194 CXXFLAGS+='-arch ppc64' \
195 LDFLAGS+='-arch ppc64' \
201 CXXFLAGS="$(GCCFLAGS)" \
202 CXXFLAGS+='-arch i386' \
203 LDFLAGS+='-arch i386' \
209 CXXFLAGS="$(GCCFLAGS)" \
210 CXXFLAGS+='-arch x86_64' \
211 LDFLAGS+='-arch x86_64' \
217 CXXFLAGS="$(ICCFLAGS-OSX)" \
218 CXXFLAGS+='-arch i386' \
219 LDFLAGS+='-arch i386' \
225 CXXFLAGS="$(ICCFLAGS-OSX)" \
226 CXXFLAGS+='-arch x86_64' \
227 LDFLAGS+='-arch x86_64' \
230 osx-icc32-profile-make:
233 CXXFLAGS="$(ICCFLAGS-OSX)" \
234 CXXFLAGS+='-arch i386' \
235 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
236 LDFLAGS+='-arch i386' \
239 osx-icc32-profile-use:
242 CXXFLAGS="$(ICCFLAGS-OSX)" \
243 CXXFLAGS+='-arch i386' \
244 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
245 LDFLAGS+='-arch i386' \
252 $(MAKE) osx-icc32-profile-make
254 @echo "Running benchmark for pgo-build ..."
255 @$(PGOBENCH) > /dev/null
256 @echo "Benchmark finished. Build final executable now ..."
259 $(MAKE) osx-icc32-profile-use
260 @rm -rf profdir bench.txt
262 osx-icc64-profile-make:
265 CXXFLAGS="$(ICCFLAGS-OSX)" \
266 CXXFLAGS+='-arch x86_64' \
267 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
268 LDFLAGS+='-arch x86_64' \
271 osx-icc64-profile-use:
274 CXXFLAGS="$(ICCFLAGS-OSX)" \
275 CXXFLAGS+='-arch x86_64' \
276 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
277 LDFLAGS+='-arch x86_64' \
284 $(MAKE) osx-icc64-profile-make
286 @echo "Running benchmark for pgo-build ..."
287 @$(PGOBENCH) > /dev/null
288 @echo "Benchmark finished. Build final executable now ..."
291 $(MAKE) osx-icc64-profile-use
292 @rm -rf profdir bench.txt
300 ### Compilation. Do not change
302 $(CXX) $(LDFLAGS) -o $@ $(OBJS)
305 ### Dependencies. Do not change
307 $(CXX) -msse -MM $(OBJS:.o=.cpp) > $@