]> git.sesse.net Git - stockfish/blob - src/Makefile
d7de76c391d9b875cb33a46281266cb230136f0f
[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
30 ICCFLAGS = -fast
31
32
33 ### ==========================================================================
34 ### Run built-in benchmark for pgo-builds with:  32MB hash  1 thread  10 depth
35 ### These settings are generally fast, but may be changed experimentally
36 ### ==========================================================================
37 PGOBENCH = ./$(EXE) bench 32 1 10 default depth
38
39
40 ### General compiler settings. Do not change
41 GCCFLAGS += -s -Wall -fno-exceptions -fno-rtti -fno-strict-aliasing
42 ICCFLAGS += -s -Wall -fno-exceptions -fno-rtti -fno-strict-aliasing -wd383,869,981,10187,10188,11505,11503
43
44
45 ### General linker settings. Do not change
46 LDFLAGS  = -lpthread
47
48
49 ### Object files. Do not change
50 OBJS = application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
51         misc.o move.o movegen.o history.o movepick.o search.o piece.o \
52         position.o direction.o tt.o value.o uci.o ucioption.o \
53         mersenne.o book.o bitbase.o san.o benchmark.o
54
55
56 ### General rules. Do not change
57 default:
58         $(MAKE) gcc
59
60 help:
61         @echo ""
62         @echo "Makefile options:"
63         @echo ""
64         @echo "make                >  Default: Compiler = g++"
65         @echo "make icc            >  Compiler = icpc"
66         @echo "make icc-profile    >  Compiler = icpc + automatic pgo-build"
67         @echo "make osx-ppc32      >  PPC-Mac OS X 32 bit. Compiler = g++"
68         @echo "make osx-ppc64      >  PPC-Mac OS X 64 bit. Compiler = g++"
69         @echo "make osx-x86        >  x86-Mac OS X 32 bit. Compiler = g++"
70         @echo "make osx-x86_64     >  x86-Mac OS X 64 bit. Compiler = g++"
71         @echo "make clean          >  Clean up"
72         @echo ""
73
74 all: $(EXE) .depend
75
76 clean:
77         $(RM) *.o .depend *~ $(EXE)
78
79
80 ### Possible targets. You may add your own ones here
81 gcc:
82         $(MAKE) \
83         CXX='g++' \
84         CXXFLAGS="$(GCCFLAGS)" \
85         all
86
87 icc:
88         $(MAKE) \
89         CXX='icpc' \
90         CXXFLAGS="$(ICCFLAGS)" \
91         all
92
93 icc-profile-make:
94         $(MAKE) \
95         CXX='icpc' \
96         CXXFLAGS="$(ICCFLAGS)" \
97         CXXFLAGS+='-prof-gen=srcpos -prof_dir ./profdir' \
98         all
99
100 icc-profile-use:
101         $(MAKE) \
102         CXX='icpc' \
103         CXXFLAGS="$(ICCFLAGS)" \
104         CXXFLAGS+='-prof_use -prof_dir ./profdir' \
105         all
106
107 icc-profile:
108         @rm -rf profdir
109         @mkdir profdir
110         @touch *.cpp *.h
111         $(MAKE) icc-profile-make
112         @echo ""
113         @echo "Running benchmark for pgo-build ..."
114         @$(PGOBENCH) > /dev/null
115         @echo "Benchmark finished. Build final executable now ..."
116         @echo ""
117         @touch *.cpp *.h
118         $(MAKE) icc-profile-use
119         @rm -rf profdir bench.txt
120
121 osx-ppc32:
122         $(MAKE) \
123         CXX='g++' \
124         CXXFLAGS="$(GCCFLAGS)" \
125         CXXFLAGS+='-arch ppc' \
126         LDFLAGS+='-arch ppc' \
127         all
128
129 osx-ppc64:
130         $(MAKE) \
131         CXX='g++' \
132         CXXFLAGS="$(GCCFLAGS)" \
133         CXXFLAGS+='-arch ppc64' \
134         LDFLAGS+='-arch ppc64' \
135         all
136
137 osx-x86:
138         $(MAKE) \
139         CXX='g++' \
140         CXXFLAGS="$(GCCFLAGS)" \
141         CXXFLAGS+='-arch i386' \
142         LDFLAGS+='-arch i386' \
143         all
144
145 osx-x86_64:
146         $(MAKE) \
147         CXX='g++' \
148         CXXFLAGS="$(GCCFLAGS)" \
149         CXXFLAGS+='-arch x86_64' \
150         LDFLAGS+='-arch x86_64' \
151         all
152
153
154 ### Compilation. Do not change
155 $(EXE): $(OBJS)
156         $(CXX) $(LDFLAGS) -o $@ $(OBJS)
157
158
159 ### Dependencies. Do not change
160 .depend:
161         $(CXX) -MM $(OBJS:.o=.cpp) > $@
162
163 include .depend