]> git.sesse.net Git - stockfish/blob - src/Makefile
5fa29c0a01a35226c421de301a134210be264c1d
[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
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 ### ==========================================================================
29 GCCFLAGS = -O3 -msse
30 ICCFLAGS = -fast -msse
31 ICCFLAGS-OSX = -fast -mdynamic-no-pic
32
33
34 ### ==========================================================================
35 ### Enable/disable debugging, disabled by default
36 ### ==========================================================================
37 GCCFLAGS += -DNDEBUG
38 ICCFLAGS += -DNDEBUG
39 ICCFLAGS-OSX += -DNDEBUG
40
41
42 ### ==========================================================================
43 ### Enable/disable compile for a big-endian CPU, disabled by default
44 ### ==========================================================================
45 GCCFLAGS += -DNBIGENDIAN
46 ICCFLAGS += -DNBIGENDIAN
47 ICCFLAGS-OSX += -DNBIGENDIAN
48
49
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
55
56
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
61
62
63 ### General linker settings. Do not change
64 LDFLAGS  = -lpthread
65
66
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         mersenne.o book.o bitbase.o san.o benchmark.o
72
73
74 ### General rules. Do not change
75 default:
76         $(MAKE) gcc
77
78 help:
79         @echo ""
80         @echo "Makefile options:"
81         @echo ""
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 osx-ppc32      >  PPC-Mac OS X 32 bit. Compiler = g++"
86         @echo "make osx-ppc64      >  PPC-Mac OS X 64 bit. Compiler = g++"
87         @echo "make osx-x86        >  x86-Mac OS X 32 bit. Compiler = g++"
88         @echo "make osx-x86_64     >  x86-Mac OS X 64 bit. Compiler = g++"
89         @echo "make osx-icc32      >  x86-Mac OS X 32 bit. Compiler = icpc"
90         @echo "make osx-icc64      >  x86-Mac OS X 64 bit. Compiler = icpc"
91         @echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
92         @echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
93         @echo "make strip          >  Strip executable"
94         @echo "make clean          >  Clean up"
95         @echo ""
96
97 all: $(EXE) .depend
98
99 clean:
100         $(RM) *.o .depend *~ $(EXE)
101
102
103 ### Possible targets. You may add your own ones here
104 gcc:
105         $(MAKE) \
106         CXX='g++' \
107         CXXFLAGS="$(GCCFLAGS)" \
108         all
109
110 icc:
111         $(MAKE) \
112         CXX='icpc' \
113         CXXFLAGS="$(ICCFLAGS)" \
114         all
115
116 icc-profile-make:
117         $(MAKE) \
118         CXX='icpc' \
119         CXXFLAGS="$(ICCFLAGS)" \
120         CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
121         all
122
123 icc-profile-use:
124         $(MAKE) \
125         CXX='icpc' \
126         CXXFLAGS="$(ICCFLAGS)" \
127         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
128         all
129
130 icc-profile:
131         @rm -rf profdir
132         @mkdir profdir
133         @touch *.cpp *.h
134         $(MAKE) icc-profile-make
135         @echo ""
136         @echo "Running benchmark for pgo-build ..."
137         @$(PGOBENCH) > /dev/null
138         @echo "Benchmark finished. Build final executable now ..."
139         @echo ""
140         @touch *.cpp *.h
141         $(MAKE) icc-profile-use
142         @rm -rf profdir bench.txt
143
144 osx-ppc32:
145         $(MAKE) \
146         CXX='g++' \
147         CXXFLAGS="$(GCCFLAGS)" \
148         CXXFLAGS+='-arch ppc' \
149         LDFLAGS+='-arch ppc' \
150         all
151
152 osx-ppc64:
153         $(MAKE) \
154         CXX='g++' \
155         CXXFLAGS="$(GCCFLAGS)" \
156         CXXFLAGS+='-arch ppc64' \
157         LDFLAGS+='-arch ppc64' \
158         all
159
160 osx-x86:
161         $(MAKE) \
162         CXX='g++' \
163         CXXFLAGS="$(GCCFLAGS)" \
164         CXXFLAGS+='-arch i386' \
165         LDFLAGS+='-arch i386' \
166         all
167
168 osx-x86_64:
169         $(MAKE) \
170         CXX='g++' \
171         CXXFLAGS="$(GCCFLAGS)" \
172         CXXFLAGS+='-arch x86_64' \
173         LDFLAGS+='-arch x86_64' \
174         all
175         
176 osx-icc32:
177         $(MAKE) \
178         CXX='icpc' \
179         CXXFLAGS="$(ICCFLAGS-OSX)" \
180         CXXFLAGS+='-arch i386' \
181         LDFLAGS+='-arch i386' \
182         all
183
184 osx-icc64:
185         $(MAKE) \
186         CXX='icpc' \
187         CXXFLAGS="$(ICCFLAGS-OSX)" \
188         CXXFLAGS+='-arch x86_64' \
189         LDFLAGS+='-arch x86_64' \
190         all
191
192 osx-icc32-profile-make:
193         $(MAKE) \
194         CXX='icpc' \
195         CXXFLAGS="$(ICCFLAGS-OSX)" \
196         CXXFLAGS+='-arch i386' \
197         CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
198         LDFLAGS+='-arch i386' \
199         all
200
201 osx-icc32-profile-use:
202         $(MAKE) \
203         CXX='icpc' \
204         CXXFLAGS="$(ICCFLAGS-OSX)" \
205         CXXFLAGS+='-arch i386' \
206         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
207         LDFLAGS+='-arch i386' \
208         all
209
210 osx-icc32-profile:
211         @rm -rf profdir
212         @mkdir profdir
213         @touch *.cpp *.h
214         $(MAKE) osx-icc32-profile-make
215         @echo ""
216         @echo "Running benchmark for pgo-build ..."
217         @$(PGOBENCH) > /dev/null
218         @echo "Benchmark finished. Build final executable now ..."
219         @echo ""
220         @touch *.cpp *.h
221         $(MAKE) osx-icc32-profile-use
222         @rm -rf profdir bench.txt
223
224 osx-icc64-profile-make:
225         $(MAKE) \
226         CXX='icpc' \
227         CXXFLAGS="$(ICCFLAGS-OSX)" \
228         CXXFLAGS+='-arch x86_64' \
229         CXXFLAGS+='-prof_gen -prof_dir ./profdir' \
230         LDFLAGS+='-arch x86_64' \
231         all
232
233 osx-icc64-profile-use:
234         $(MAKE) \
235         CXX='icpc' \
236         CXXFLAGS="$(ICCFLAGS-OSX)" \
237         CXXFLAGS+='-arch x86_64' \
238         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
239         LDFLAGS+='-arch x86_64' \
240         all
241
242 osx-icc64-profile:
243         @rm -rf profdir
244         @mkdir profdir
245         @touch *.cpp *.h
246         $(MAKE) osx-icc64-profile-make
247         @echo ""
248         @echo "Running benchmark for pgo-build ..."
249         @$(PGOBENCH) > /dev/null
250         @echo "Benchmark finished. Build final executable now ..."
251         @echo ""
252         @touch *.cpp *.h
253         $(MAKE) osx-icc64-profile-use
254         @rm -rf profdir bench.txt
255
256
257
258 strip:
259         strip $(EXE)
260
261
262 ### Compilation. Do not change
263 $(EXE): $(OBJS)
264         $(CXX) $(LDFLAGS) -o $@ $(OBJS)
265
266
267 ### Dependencies. Do not change
268 .depend:
269         $(CXX) -msse -MM $(OBJS:.o=.cpp) > $@
270
271 include .depend