### Executable name. Do not change
EXE = stockfish
+### Installation dir definitions
+PREFIX = /usr/local
+BINDIR = $(PREFIX)/bin
### ==========================================================================
### Compiler speed switches for both GCC and ICC. These settings are generally
### ==========================================================================
PGOBENCH = ./$(EXE) bench 32 1 10 default depth
-
### General compiler settings. Do not change
GCCFLAGS += -g -Wall -fno-exceptions -fno-rtti
ICCFLAGS += -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503
@echo "Makefile options:"
@echo ""
@echo "make > Default: Compiler = g++"
+ @echo "make gcc-profile > Compiler = g++ + automatic pgo-build"
+ @echo "make gcc-popcnt > Compiler = g++ + popcnt-support"
@echo "make icc > Compiler = icpc"
@echo "make icc-profile > Compiler = icpc + automatic pgo-build"
@echo "make icc-profile-popcnt > Compiler = icpc + automatic pgo-build + popcnt-support"
@echo "make osx-icc64 > x86-Mac OS X 64 bit. Compiler = icpc"
@echo "make osx-icc32-profile > OSX 32 bit. Compiler = icpc + automatic pgo-build"
@echo "make osx-icc64-profile > OSX 64 bit. Compiler = icpc + automatic pgo-build"
+ @echo "make hpux > HP-UX. Compiler = aCC"
@echo "make strip > Strip executable"
@echo "make clean > Clean up"
@echo ""
all: $(EXE) .depend
+test check: default
+ @$(PGOBENCH)
+
clean:
- $(RM) *.o .depend *~ $(EXE)
+ $(RM) *.o .depend *~ $(EXE) core bench.txt
### Possible targets. You may add your own ones here
CXXFLAGS="$(GCCFLAGS)" \
all
+gcc-profile-make:
+ $(MAKE) \
+ CXX='g++' \
+ CXXFLAGS="$(GCCFLAGS)" \
+ CXXFLAGS+='-fprofile-generate' \
+ LDFLAGS="$(LDFLAGS)" \
+ LDFLAGS+=" -lgcov" \
+ all
+
+gcc-profile-use:
+ $(MAKE) \
+ CXX='g++' \
+ CXXFLAGS="$(GCCFLAGS)" \
+ CXXFLAGS+='-fprofile-use' \
+ all
+
+gcc-profile:
+ @touch *.cpp *.h
+ $(MAKE) gcc-profile-make
+ @echo ""
+ @echo "Running benchmark for pgo-build ..."
+ @$(PGOBENCH) > /dev/null
+ @echo "Benchmark finished. Build final executable now ..."
+ @echo ""
+ @touch *.cpp *.h
+ $(MAKE) gcc-profile-use
+ @rm -rf *.gcda bench.txt
+
+gcc-popcnt:
+ $(MAKE) \
+ CXX='g++' \
+ CXXFLAGS="$(GCCFLAGS) -DUSE_POPCNT" \
+ all
+
icc:
$(MAKE) \
CXX='icpc' \
CXX='g++' \
CXXFLAGS="$(GCCFLAGS)" \
CXXFLAGS+='-arch ppc' \
+ CXXFLAGS+='-DBIGENDIAN' \
LDFLAGS+='-arch ppc' \
all
CXX='g++' \
CXXFLAGS="$(GCCFLAGS)" \
CXXFLAGS+='-arch ppc64' \
+ CXXFLAGS+='-DBIGENDIAN' \
LDFLAGS+='-arch ppc64' \
all
$(MAKE) \
CXX='g++' \
CXXFLAGS="$(GCCFLAGS)" \
- CXXFLAGS+='-arch i386' \
- LDFLAGS+='-arch i386' \
+ CXXFLAGS+='-arch i386 -mdynamic-no-pic' \
+ LDFLAGS+='-arch i386 -mdynamic-no-pic' \
all
osx-x86_64:
$(MAKE) \
CXX='g++' \
CXXFLAGS="$(GCCFLAGS)" \
- CXXFLAGS+='-arch x86_64' \
- LDFLAGS+='-arch x86_64' \
+ CXXFLAGS+='-arch x86_64 -mdynamic-no-pic' \
+ LDFLAGS+='-arch x86_64 -mdynamic-no-pic' \
all
-
+
osx-icc32:
$(MAKE) \
CXX='icpc' \
$(MAKE) osx-icc64-profile-use
@rm -rf profdir bench.txt
+hpux:
+ $(MAKE) \
+ CXX='/opt/aCC/bin/aCC -AA +hpxstd98 -DBIGENDIAN -mt +O3 -DNDEBUG' \
+ CXXFLAGS="" \
+ LDFLAGS="" \
+ all
strip:
### Compilation. Do not change
$(EXE): $(OBJS)
- $(CXX) $(LDFLAGS) -o $@ $(OBJS)
+ $(CXX) -o $@ $(OBJS) $(LDFLAGS)
+### Installation
+install: default
+ -mkdir -p -m 755 $(BINDIR)
+ -cp $(EXE) $(BINDIR)
+ -strip $(BINDIR)/$(EXE)
### Dependencies. Do not change
.depend:
- $(CXX) -msse -MM $(OBJS:.o=.cpp) > $@
+ -@$(CXX) -msse -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null
-include .depend
+-include .depend