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
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 ### ==========================================================================
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
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
65 ### General linker settings. Do not change
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
76 ### General rules. Do not change
82 @echo "Makefile options:"
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"
109 $(RM) *.o .depend *~ $(EXE) core bench.txt
112 ### Possible targets. You may add your own ones here
116 CXXFLAGS="$(GCCFLAGS)" \
122 CXXFLAGS="$(GCCFLAGS)" \
123 CXXFLAGS+='-fprofile-generate' \
124 LDFLAGS="$(LDFLAGS)" \
131 CXXFLAGS="$(GCCFLAGS)" \
132 CXXFLAGS+='-fprofile-use' \
137 $(MAKE) gcc-profile-make
139 @echo "Running benchmark for pgo-build ..."
140 @$(PGOBENCH) > /dev/null
141 @echo "Benchmark finished. Build final executable now ..."
144 $(MAKE) gcc-profile-use
145 @rm -rf *.gcda bench.txt
150 CXXFLAGS="$(GCCFLAGS) -DUSE_POPCNT" \
156 CXXFLAGS="$(ICCFLAGS)" \
162 CXXFLAGS="$(ICCFLAGS)" \
163 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
169 CXXFLAGS="$(ICCFLAGS)" \
170 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
177 $(MAKE) icc-profile-make
179 @echo "Running benchmark for pgo-build ..."
180 @$(PGOBENCH) > /dev/null
181 @echo "Benchmark finished. Build final executable now ..."
184 $(MAKE) icc-profile-use
185 @rm -rf profdir bench.txt
187 icc-profile-make-with-popcnt:
190 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
191 CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
194 icc-profile-use-with-popcnt:
197 CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
198 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
205 $(MAKE) icc-profile-make
207 @echo "Running benchmark for pgo-build (popcnt disabled)..."
208 @$(PGOBENCH) > /dev/null
210 $(MAKE) icc-profile-make-with-popcnt
212 @echo "Running benchmark for pgo-build (popcnt enabled)..."
213 @$(PGOBENCH) > /dev/null
214 @echo "Benchmarks finished. Build final executable now ..."
217 $(MAKE) icc-profile-use-with-popcnt
218 @rm -rf profdir bench.txt
224 CXXFLAGS="$(GCCFLAGS)" \
225 CXXFLAGS+='-arch ppc' \
226 CXXFLAGS+='-DBIGENDIAN' \
227 LDFLAGS+='-arch ppc' \
233 CXXFLAGS="$(GCCFLAGS)" \
234 CXXFLAGS+='-arch ppc64' \
235 CXXFLAGS+='-DBIGENDIAN' \
236 LDFLAGS+='-arch ppc64' \
242 CXXFLAGS="$(GCCFLAGS)" \
243 CXXFLAGS+='-arch i386 -mdynamic-no-pic' \
244 LDFLAGS+='-arch i386 -mdynamic-no-pic' \
250 CXXFLAGS="$(GCCFLAGS)" \
251 CXXFLAGS+='-arch x86_64 -mdynamic-no-pic' \
252 LDFLAGS+='-arch x86_64 -mdynamic-no-pic' \
258 CXXFLAGS="$(ICCFLAGS-OSX)" \
259 CXXFLAGS+='-arch i386' \
260 LDFLAGS+='-arch i386' \
266 CXXFLAGS="$(ICCFLAGS-OSX)" \
267 CXXFLAGS+='-arch x86_64' \
268 LDFLAGS+='-arch x86_64' \
271 osx-icc32-profile-make:
274 CXXFLAGS="$(ICCFLAGS-OSX)" \
275 CXXFLAGS+='-arch i386' \
276 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
277 LDFLAGS+='-arch i386' \
280 osx-icc32-profile-use:
283 CXXFLAGS="$(ICCFLAGS-OSX)" \
284 CXXFLAGS+='-arch i386' \
285 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
286 LDFLAGS+='-arch i386' \
293 $(MAKE) osx-icc32-profile-make
295 @echo "Running benchmark for pgo-build ..."
296 @$(PGOBENCH) > /dev/null
297 @echo "Benchmark finished. Build final executable now ..."
300 $(MAKE) osx-icc32-profile-use
301 @rm -rf profdir bench.txt
303 osx-icc64-profile-make:
306 CXXFLAGS="$(ICCFLAGS-OSX)" \
307 CXXFLAGS+='-arch x86_64' \
308 CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
309 LDFLAGS+='-arch x86_64' \
312 osx-icc64-profile-use:
315 CXXFLAGS="$(ICCFLAGS-OSX)" \
316 CXXFLAGS+='-arch x86_64' \
317 CXXFLAGS+='-prof_use -prof_dir ./profdir' \
318 LDFLAGS+='-arch x86_64' \
325 $(MAKE) osx-icc64-profile-make
327 @echo "Running benchmark for pgo-build ..."
328 @$(PGOBENCH) > /dev/null
329 @echo "Benchmark finished. Build final executable now ..."
332 $(MAKE) osx-icc64-profile-use
333 @rm -rf profdir bench.txt
337 CXX='/opt/aCC/bin/aCC -AA +hpxstd98 -DBIGENDIAN -mt +O3 -DNDEBUG' \
347 ### Compilation. Do not change
349 $(CXX) -o $@ $(OBJS) $(LDFLAGS)
353 -mkdir -p -m 755 $(BINDIR)
355 -strip $(BINDIR)/$(EXE)
357 ### Dependencies. Do not change
359 -@$(CXX) -msse -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null