]> git.sesse.net Git - stockfish/blobdiff - src/Makefile
Add signature-profile-build make target
[stockfish] / src / Makefile
index b23d671f07600388a87a3956fc211980f1659352..397c55b98fc01558b9517bf0b9ca8f4cf375393f 100644 (file)
@@ -34,8 +34,9 @@ ifeq ($(UNAME),Haiku)
 endif
 BINDIR = $(PREFIX)/bin
 
-### Built-in benchmark for pgo-builds
+### Built-in benchmark for pgo-builds and signature
 PGOBENCH = ./$(EXE) bench 32 1 10 default depth
+SIGNBENCH = ./$(EXE) bench
 
 ### Object files
 OBJS = benchmark.o bitbase.o bitboard.o book.o endgame.o evaluate.o main.o \
@@ -231,7 +232,7 @@ ifeq ($(COMP),clang)
 endif
 
 ### 3.2 General compiler settings
-CXXFLAGS = -g -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS)
+CXXFLAGS = -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS)
 
 ifeq ($(comp),gcc)
        CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra -Wshadow
@@ -275,6 +276,8 @@ endif
 ### 3.4 Debugging
 ifeq ($(debug),no)
        CXXFLAGS += -DNDEBUG
+else
+       CXXFLAGS += -g 
 endif
 
 ### 3.5 Optimization
@@ -354,6 +357,7 @@ endif
 ### needs access to the optimization flags.
 ifeq ($(comp),gcc)
        ifeq ($(optimize),yes)
+       ifeq ($(debug),no)
                GCC_MAJOR := `$(CXX) -dumpversion | cut -f1 -d.`
                GCC_MINOR := `$(CXX) -dumpversion | cut -f2 -d.`
                ifeq (1,$(shell expr \( $(GCC_MAJOR) \> 4 \) \| \( $(GCC_MAJOR) \= 4 \& $(GCC_MINOR) \>= 5 \)))
@@ -361,6 +365,7 @@ ifeq ($(comp),gcc)
                        LDFLAGS += $(CXXFLAGS)
                endif
        endif
+       endif
 endif
 
 ### ==========================================================================
@@ -413,6 +418,7 @@ help:
        @echo "make profile-build ARCH=x86-32    (This is for 32-bit systems)"
        @echo ""
 
+.PHONY: build profile-build embed-signature
 build:
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) config-sanity
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
@@ -437,6 +443,18 @@ profile-build:
        @echo "Step 4/4. Deleting profile data ..."
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_clean)
 
+embed-signature:
+       @echo "Running benchmark for getting the signature ..."
+       @$(SIGNBENCH) 2>&1 | grep 'Nodes searched' | grep -o ": .*" | tr -d ': ' > sign.txt
+       @sed -i -e 's,^,/static const string Version/s/"\\(.*\\)"/"sig-,1' -e 's,$$,"/1,1' sign.txt
+       @sed -i -f sign.txt misc.cpp
+       @rm sign.txt
+
+signature-build: build embed-signature       
+       $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
+
+signature-profile-build: build embed-signature profile-build
+
 strip:
        strip $(EXE)