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
24 ### Installation dir definitions
26 BINDIR = $(PREFIX)/bin
29 ### ==========================================================================
30 ### Compiler speed switches for both GCC and ICC. These settings are generally
31 ### fast on a broad range of systems, but may be changed experimentally
32 ### ==========================================================================
34 ICCFLAGS = -fast -msse
35 ICCFLAGS-OSX = -fast -mdynamic-no-pic
38 ### ==========================================================================
39 ### Enable/disable debugging, disabled by default
40 ### ==========================================================================
43 ICCFLAGS-OSX += -DNDEBUG
46 ### ==========================================================================
47 ### Remove below comments to compile for a big-endian machine
48 ### ==========================================================================
49 #GCCFLAGS += -DBIGENDIAN
50 #ICCFLAGS += -DBIGENDIAN
51 #ICCFLAGS-OSX += -DBIGENDIAN
54 ### ==========================================================================
55 ### Run built-in benchmark for pgo-builds with: 32MB hash 1 thread 10 depth
56 ### These settings are generally fast, but may be changed experimentally
57 ### ==========================================================================
58 PGOBENCH = ./$(EXE) bench 32 1 10 default depth
61 ### General compiler settings. Do not change
62 GCCFLAGS += -g -Wall -fno-exceptions -fno-rtti
63 ICCFLAGS += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
64 ICCFLAGS-OSX += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
67 ### General linker settings. Do not change
71 ### Object files. Do not change
72 OBJS = application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
73 misc.o move.o movegen.o history.o movepick.o search.o piece.o \
74 position.o direction.o tt.o value.o uci.o ucioption.o \
75 mersenne.o book.o bitbase.o san.o benchmark.o
78 ### General rules. Do not change
84 @echo "Makefile options:"
86 @echo "make > Default: Compiler = g++"
87 @echo "make gcc-popcnt > Compiler = g++ + popcnt-support"
88 @echo "make icc > Compiler = icpc"
89 @echo "make icc-profile > Compiler = icpc + automatic pgo-build"
90 @echo "make icc-profile-popcnt > Compiler = icpc + automatic pgo-build + popcnt-support"
91 @echo "make osx-ppc32 > PPC-Mac OS X 32 bit. Compiler = g++"
92 @echo "make osx-ppc64 > PPC-Mac OS X 64 bit. Compiler = g++"
93 @echo "make osx-x86 > x86-Mac OS X 32 bit. Compiler = g++"
94 @echo "make osx-x86_64 > x86-Mac OS X 64 bit. Compiler = g++"
95 @echo "make osx-icc32 > x86-Mac OS X 32 bit. Compiler = icpc"
96 @echo "make osx-icc64 > x86-Mac OS X 64 bit. Compiler = icpc"
97 @echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
98 @echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
99 @echo "make hpux > HP-UX. Compiler = aCC"
100 @echo "make strip > Strip executable"
101 @echo "make clean > Clean up"
110 $(RM) *.o .depend *~ $(EXE) core bench.txt
113 ### Possible targets. You may add your own ones here
117 CXXFLAGS="$(GCCFLAGS)" \
123 CXXFLAGS="$(GCCFLAGS) -DUSE_POPCNT" \
130 CXXFLAGS="$(ICCFLAGS)" \
136 CXXFLAGS="$(ICCFLAGS)" \
137 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
143 CXXFLAGS="$(ICCFLAGS)" \
144 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
151 $(MAKE) icc-profile-make
153 @echo "Running benchmark for pgo-build ..."
154 @$(PGOBENCH) > /dev/null
155 @echo "Benchmark finished. Build final executable now ..."
158 $(MAKE) icc-profile-use
159 @rm -rf profdir bench.txt
161 icc-profile-make-with-popcnt:
164 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
165 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
168 icc-profile-use-with-popcnt:
171 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
172 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
179 $(MAKE) icc-profile-make
181 @echo "Running benchmark for pgo-build (popcnt disabled)..."
182 @$(PGOBENCH) > /dev/null
184 $(MAKE) icc-profile-make-with-popcnt
186 @echo "Running benchmark for pgo-build (popcnt enabled)..."
187 @$(PGOBENCH) > /dev/null
188 @echo "Benchmarks finished. Build final executable now ..."
191 $(MAKE) icc-profile-use-with-popcnt
192 @rm -rf profdir bench.txt
198 CXXFLAGS="$(GCCFLAGS)" \
199 CXXFLAGS+='-arch ppc' \
200 CXXFLAGS+='-DBIGENDIAN' \
201 LDFLAGS+='-arch ppc' \
207 CXXFLAGS="$(GCCFLAGS)" \
208 CXXFLAGS+='-arch ppc64' \
209 CXXFLAGS+='-DBIGENDIAN' \
210 LDFLAGS+='-arch ppc64' \
216 CXXFLAGS="$(GCCFLAGS)" \
217 CXXFLAGS+='-arch i386 -mdynamic-no-pic' \
218 LDFLAGS+='-arch i386 -mdynamic-no-pic' \
224 CXXFLAGS="$(GCCFLAGS)" \
225 CXXFLAGS+='-arch x86_64 -mdynamic-no-pic' \
226 LDFLAGS+='-arch x86_64 -mdynamic-no-pic' \
232 CXXFLAGS="$(ICCFLAGS-OSX)" \
233 CXXFLAGS+='-arch i386' \
234 LDFLAGS+='-arch i386' \
240 CXXFLAGS="$(ICCFLAGS-OSX)" \
241 CXXFLAGS+='-arch x86_64' \
242 LDFLAGS+='-arch x86_64' \
245 osx-icc32-profile-make:
248 CXXFLAGS="$(ICCFLAGS-OSX)" \
249 CXXFLAGS+='-arch i386' \
250 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
251 LDFLAGS+='-arch i386' \
254 osx-icc32-profile-use:
257 CXXFLAGS="$(ICCFLAGS-OSX)" \
258 CXXFLAGS+='-arch i386' \
259 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
260 LDFLAGS+='-arch i386' \
267 $(MAKE) osx-icc32-profile-make
269 @echo "Running benchmark for pgo-build ..."
270 @$(PGOBENCH) > /dev/null
271 @echo "Benchmark finished. Build final executable now ..."
274 $(MAKE) osx-icc32-profile-use
275 @rm -rf profdir bench.txt
277 osx-icc64-profile-make:
280 CXXFLAGS="$(ICCFLAGS-OSX)" \
281 CXXFLAGS+='-arch x86_64' \
282 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
283 LDFLAGS+='-arch x86_64' \
286 osx-icc64-profile-use:
289 CXXFLAGS="$(ICCFLAGS-OSX)" \
290 CXXFLAGS+='-arch x86_64' \
291 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
292 LDFLAGS+='-arch x86_64' \
299 $(MAKE) osx-icc64-profile-make
301 @echo "Running benchmark for pgo-build ..."
302 @$(PGOBENCH) > /dev/null
303 @echo "Benchmark finished. Build final executable now ..."
306 $(MAKE) osx-icc64-profile-use
307 @rm -rf profdir bench.txt
311 CXX='/opt/aCC/bin/aCC -AA +hpxstd98 -DBIGENDIAN -mt +O3 -DNDEBUG' \
321 ### Compilation. Do not change
323 $(CXX) $(LDFLAGS) -o $@ $(OBJS)
327 -mkdir -p -m 755 $(BINDIR)
329 -strip $(BINDIR)/$(EXE)
331 ### Dependencies. Do not change
333 -@$(CXX) -msse -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null