]> git.sesse.net Git - stockfish/blob - src/Makefile
748a739e254551daedf022a8efbe0b3e53e21b77
[stockfish] / src / Makefile
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
4
5 # This file is part of Stockfish.
6 #
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.
11 #
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.
16 #
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/>.
19
20
21 ### Executable name. Do not change
22 EXE = stockfish
23
24 ### Installation dir definitions
25 PREFIX = /usr/local
26 BINDIR = $(PREFIX)/bin
27
28
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 ### ==========================================================================
33 GCCFLAGS = -O3 -msse
34 ICCFLAGS = -fast -msse
35 ICCFLAGS-OSX = -fast -mdynamic-no-pic
36
37
38 ### ==========================================================================
39 ### Enable/disable debugging, disabled by default
40 ### ==========================================================================
41 GCCFLAGS += -DNDEBUG
42 ICCFLAGS += -DNDEBUG
43 ICCFLAGS-OSX += -DNDEBUG
44
45
46 ### ==========================================================================
47 ### Remove below comments to compile for a big-endian machine
48 ### ==========================================================================
49 #GCCFLAGS += -DBIGENDIAN
50 #ICCFLAGS += -DBIGENDIAN
51 #ICCFLAGS-OSX += -DBIGENDIAN
52
53
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
59
60
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
65
66
67 ### General linker settings. Do not change
68 LDFLAGS  = -lpthread
69
70
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
76
77
78 ### General rules. Do not change
79 default:
80         $(MAKE) gcc
81
82 help:
83         @echo ""
84         @echo "Makefile options:"
85         @echo ""
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"
102         @echo ""
103
104 all: $(EXE) .depend
105
106 test check: default
107         @$(PGOBENCH)
108
109 clean:
110         $(RM) *.o .depend *~ $(EXE) core bench.txt
111
112
113 ### Possible targets. You may add your own ones here
114 gcc:
115         $(MAKE) \
116         CXX='g++' \
117         CXXFLAGS="$(GCCFLAGS)" \
118         all
119
120 gcc-popcnt:
121         $(MAKE) \
122         CXX='g++' \
123         CXXFLAGS="$(GCCFLAGS) -DUSE_POPCNT" \
124         all
125
126
127 icc:
128         $(MAKE) \
129         CXX='icpc' \
130         CXXFLAGS="$(ICCFLAGS)" \
131         all
132
133 icc-profile-make:
134         $(MAKE) \
135         CXX='icpc' \
136         CXXFLAGS="$(ICCFLAGS)" \
137         CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
138         all
139
140 icc-profile-use:
141         $(MAKE) \
142         CXX='icpc' \
143         CXXFLAGS="$(ICCFLAGS)" \
144         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
145         all
146
147 icc-profile:
148         @rm -rf profdir
149         @mkdir profdir
150         @touch *.cpp *.h
151         $(MAKE) icc-profile-make
152         @echo ""
153         @echo "Running benchmark for pgo-build ..."
154         @$(PGOBENCH) > /dev/null
155         @echo "Benchmark finished. Build final executable now ..."
156         @echo ""
157         @touch *.cpp *.h
158         $(MAKE) icc-profile-use
159         @rm -rf profdir bench.txt
160
161 icc-profile-make-with-popcnt:
162         $(MAKE) \
163         CXX='icpc' \
164         CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
165         CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
166         all
167
168 icc-profile-use-with-popcnt:
169         $(MAKE) \
170         CXX='icpc' \
171         CXXFLAGS="$(ICCFLAGS) -DUSE_POPCNT" \
172         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
173         all
174
175 icc-profile-popcnt:
176         @rm -rf profdir
177         @mkdir profdir
178         @touch *.cpp *.h
179         $(MAKE) icc-profile-make
180         @echo ""
181         @echo "Running benchmark for pgo-build (popcnt disabled)..."
182         @$(PGOBENCH) > /dev/null
183         @touch *.cpp *.h
184         $(MAKE) icc-profile-make-with-popcnt
185         @echo ""
186         @echo "Running benchmark for pgo-build (popcnt enabled)..."
187         @$(PGOBENCH) > /dev/null
188         @echo "Benchmarks finished. Build final executable now ..."
189         @echo ""
190         @touch *.cpp *.h
191         $(MAKE) icc-profile-use-with-popcnt
192         @rm -rf profdir bench.txt
193
194
195 osx-ppc32:
196         $(MAKE) \
197         CXX='g++' \
198         CXXFLAGS="$(GCCFLAGS)" \
199         CXXFLAGS+='-arch ppc' \
200         LDFLAGS+='-arch ppc' \
201         all
202
203 osx-ppc64:
204         $(MAKE) \
205         CXX='g++' \
206         CXXFLAGS="$(GCCFLAGS)" \
207         CXXFLAGS+='-arch ppc64' \
208         LDFLAGS+='-arch ppc64' \
209         all
210
211 osx-x86:
212         $(MAKE) \
213         CXX='g++' \
214         CXXFLAGS="$(GCCFLAGS)" \
215         CXXFLAGS+='-arch i386' \
216         LDFLAGS+='-arch i386' \
217         all
218
219 osx-x86_64:
220         $(MAKE) \
221         CXX='g++' \
222         CXXFLAGS="$(GCCFLAGS)" \
223         CXXFLAGS+='-arch x86_64' \
224         LDFLAGS+='-arch x86_64' \
225         all
226         
227 osx-icc32:
228         $(MAKE) \
229         CXX='icpc' \
230         CXXFLAGS="$(ICCFLAGS-OSX)" \
231         CXXFLAGS+='-arch i386' \
232         LDFLAGS+='-arch i386' \
233         all
234
235 osx-icc64:
236         $(MAKE) \
237         CXX='icpc' \
238         CXXFLAGS="$(ICCFLAGS-OSX)" \
239         CXXFLAGS+='-arch x86_64' \
240         LDFLAGS+='-arch x86_64' \
241         all
242
243 osx-icc32-profile-make:
244         $(MAKE) \
245         CXX='icpc' \
246         CXXFLAGS="$(ICCFLAGS-OSX)" \
247         CXXFLAGS+='-arch i386' \
248         CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
249         LDFLAGS+='-arch i386' \
250         all
251
252 osx-icc32-profile-use:
253         $(MAKE) \
254         CXX='icpc' \
255         CXXFLAGS="$(ICCFLAGS-OSX)" \
256         CXXFLAGS+='-arch i386' \
257         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
258         LDFLAGS+='-arch i386' \
259         all
260
261 osx-icc32-profile:
262         @rm -rf profdir
263         @mkdir profdir
264         @touch *.cpp *.h
265         $(MAKE) osx-icc32-profile-make
266         @echo ""
267         @echo "Running benchmark for pgo-build ..."
268         @$(PGOBENCH) > /dev/null
269         @echo "Benchmark finished. Build final executable now ..."
270         @echo ""
271         @touch *.cpp *.h
272         $(MAKE) osx-icc32-profile-use
273         @rm -rf profdir bench.txt
274
275 osx-icc64-profile-make:
276         $(MAKE) \
277         CXX='icpc' \
278         CXXFLAGS="$(ICCFLAGS-OSX)" \
279         CXXFLAGS+='-arch x86_64' \
280         CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
281         LDFLAGS+='-arch x86_64' \
282         all
283
284 osx-icc64-profile-use:
285         $(MAKE) \
286         CXX='icpc' \
287         CXXFLAGS="$(ICCFLAGS-OSX)" \
288         CXXFLAGS+='-arch x86_64' \
289         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
290         LDFLAGS+='-arch x86_64' \
291         all
292
293 osx-icc64-profile:
294         @rm -rf profdir
295         @mkdir profdir
296         @touch *.cpp *.h
297         $(MAKE) osx-icc64-profile-make
298         @echo ""
299         @echo "Running benchmark for pgo-build ..."
300         @$(PGOBENCH) > /dev/null
301         @echo "Benchmark finished. Build final executable now ..."
302         @echo ""
303         @touch *.cpp *.h
304         $(MAKE) osx-icc64-profile-use
305         @rm -rf profdir bench.txt
306
307 hpux:
308         $(MAKE) \
309         CXX='/opt/aCC/bin/aCC -AA +hpxstd98 -DBIGENDIAN -mt +O3 -DNDEBUG' \
310         CXXFLAGS="" \
311         LDFLAGS="" \
312         all
313
314
315 strip:
316         strip $(EXE)
317
318
319 ### Compilation. Do not change
320 $(EXE): $(OBJS)
321         $(CXX) $(LDFLAGS) -o $@ $(OBJS)
322
323 ### Installation
324 install: default
325         -mkdir -p -m 755 $(BINDIR)
326         -cp $(EXE) $(BINDIR)
327         -strip $(BINDIR)/$(EXE)
328
329 ### Dependencies. Do not change
330 .depend:
331         -@$(CXX) -msse -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null
332
333 -include .depend