]> git.sesse.net Git - stockfish/blobdiff - src/Makefile
Use explicit logic for pruning
[stockfish] / src / Makefile
index 294634f69156656ddf617a0df157f0a550efc3f4..95e6ac981350f59d51f14b4350bc28025244414e 100644 (file)
 ### ==========================================================================
 
 ### Establish the operating system name
-UNAME = $(shell uname)
+KERNEL = $(shell uname -s)
+ifeq ($(KERNEL),Linux)
+       OS = $(shell uname -o)
+endif
 
 ### Executable name
 EXE = stockfish
@@ -32,7 +35,7 @@ PREFIX = /usr/local
 BINDIR = $(PREFIX)/bin
 
 ### Built-in benchmark for pgo-builds
-PGOBENCH = ./$(EXE) bench 16 1 1000 default time
+PGOBENCH = ./$(EXE) bench
 
 ### Object files
 OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \
@@ -145,8 +148,17 @@ endif
 ifeq ($(COMP),gcc)
        comp=gcc
        CXX=g++
-       CXXFLAGS += -pedantic -Wextra -Wshadow -m$(bits)
-       ifneq ($(UNAME),Darwin)
+       CXXFLAGS += -pedantic -Wextra -Wshadow
+
+       ifeq ($(ARCH),armv7)
+               ifeq ($(OS),Android)
+                       CXXFLAGS += -m$(bits)
+               endif
+       else
+               CXXFLAGS += -m$(bits)
+       endif
+
+       ifneq ($(KERNEL),Darwin)
           LDFLAGS += -Wl,--no-as-needed
        endif
 endif
@@ -154,7 +166,7 @@ endif
 ifeq ($(COMP),mingw)
        comp=mingw
 
-       ifeq ($(UNAME),Linux)
+       ifeq ($(KERNEL),Linux)
                ifeq ($(bits),64)
                        ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
                                CXX=x86_64-w64-mingw32-c++
@@ -185,9 +197,19 @@ endif
 ifeq ($(COMP),clang)
        comp=clang
        CXX=clang++
-       CXXFLAGS += -pedantic -Wextra -Wshadow -m$(bits)
-       LDFLAGS += -m$(bits)
-       ifeq ($(UNAME),Darwin)
+       CXXFLAGS += -pedantic -Wextra -Wshadow
+
+       ifeq ($(ARCH),armv7)
+               ifeq ($(OS),Android)
+                       CXXFLAGS += -m$(bits)
+                       LDFLAGS += -m$(bits)
+               endif
+       else
+               CXXFLAGS += -m$(bits)
+               LDFLAGS += -m$(bits)
+       endif
+
+       ifeq ($(KERNEL),Darwin)
                CXXFLAGS += -stdlib=libc++
                DEPENDFLAGS += -stdlib=libc++
        endif
@@ -205,7 +227,7 @@ else
        profile_clean = gcc-profile-clean
 endif
 
-ifeq ($(UNAME),Darwin)
+ifeq ($(KERNEL),Darwin)
        CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9
        LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9
 endif
@@ -223,28 +245,29 @@ endif
 ### On mingw use Windows threads, otherwise POSIX
 ifneq ($(comp),mingw)
        # On Android Bionic's C library comes with its own pthread implementation bundled in
-       ifneq ($(arch),armv7)
+       ifneq ($(OS),Android)
                # Haiku has pthreads in its libroot, so only link it in on other platforms
-               ifneq ($(UNAME),Haiku)
+               ifneq ($(KERNEL),Haiku)
                        LDFLAGS += -lpthread
                endif
        endif
 endif
 
-### 3.4 Debugging
+### 3.2 Debugging
 ifeq ($(debug),no)
        CXXFLAGS += -DNDEBUG
 else
        CXXFLAGS += -g
 endif
 
-### 3.5 Optimization
+### 3.3 Optimization
 ifeq ($(optimize),yes)
 
+       CXXFLAGS += -O3
+
        ifeq ($(comp),gcc)
-               CXXFLAGS += -O3
 
-               ifeq ($(UNAME),Darwin)
+               ifeq ($(KERNEL),Darwin)
                        ifeq ($(arch),i386)
                                CXXFLAGS += -mdynamic-no-pic
                        endif
@@ -253,27 +276,19 @@ ifeq ($(optimize),yes)
                        endif
                endif
 
-               ifeq ($(arch),armv7)
+               ifeq ($(OS), Android)
                        CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
                endif
        endif
 
-       ifeq ($(comp),mingw)
-               CXXFLAGS += -O3
-       endif
-
        ifeq ($(comp),icc)
-               ifeq ($(UNAME),Darwin)
-                       CXXFLAGS += -fast -mdynamic-no-pic
-               else
-                       CXXFLAGS += -fast
+               ifeq ($(KERNEL),Darwin)
+                       CXXFLAGS += -mdynamic-no-pic
                endif
        endif
 
        ifeq ($(comp),clang)
-               CXXFLAGS += -O3
-
-               ifeq ($(UNAME),Darwin)
+               ifeq ($(KERNEL),Darwin)
                        ifeq ($(pext),no)
                                CXXFLAGS += -flto
                                LDFLAGS += $(CXXFLAGS)
@@ -288,12 +303,12 @@ ifeq ($(optimize),yes)
        endif
 endif
 
-### 3.6. Bits
+### 3.4 Bits
 ifeq ($(bits),64)
        CXXFLAGS += -DIS_64BIT
 endif
 
-### 3.7 prefetch
+### 3.5 prefetch
 ifeq ($(prefetch),yes)
        ifeq ($(sse),yes)
                CXXFLAGS += -msse
@@ -303,7 +318,7 @@ else
        CXXFLAGS += -DNO_PREFETCH
 endif
 
-### 3.9 popcnt
+### 3.6 popcnt
 ifeq ($(popcnt),yes)
        ifeq ($(comp),icc)
                CXXFLAGS += -msse3 -DUSE_POPCNT
@@ -312,15 +327,15 @@ ifeq ($(popcnt),yes)
        endif
 endif
 
-### 3.10 pext
+### 3.7 pext
 ifeq ($(pext),yes)
        CXXFLAGS += -DUSE_PEXT
        ifeq ($(comp),$(filter $(comp),gcc clang mingw))
-               CXXFLAGS += -mbmi -mbmi2
+               CXXFLAGS += -mbmi2
        endif
 endif
 
-### 3.11 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
+### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
 ### This is a mix of compile and link time options because the lto link phase
 ### needs access to the optimization flags.
 ifeq ($(comp),gcc)
@@ -333,7 +348,7 @@ ifeq ($(comp),gcc)
 endif
 
 ifeq ($(comp),mingw)
-       ifeq ($(UNAME),Linux)
+       ifeq ($(KERNEL),Linux)
        ifeq ($(optimize),yes)
        ifeq ($(debug),no)
                CXXFLAGS += -flto
@@ -343,9 +358,9 @@ ifeq ($(comp),mingw)
        endif
 endif
 
-### 3.12 Android 5 can only run position independent executables. Note that this
+### 3.9 Android 5 can only run position independent executables. Note that this
 ### breaks Android 4.0 and earlier.
-ifeq ($(arch),armv7)
+ifeq ($(OS), Android)
        CXXFLAGS += -fPIE
        LDFLAGS += -fPIE -pie
 endif
@@ -453,6 +468,8 @@ config-sanity:
        @echo "optimize: '$(optimize)'"
        @echo "arch: '$(arch)'"
        @echo "bits: '$(bits)'"
+       @echo "kernel: '$(KERNEL)'"
+       @echo "os: '$(OS)'"
        @echo "prefetch: '$(prefetch)'"
        @echo "popcnt: '$(popcnt)'"
        @echo "sse: '$(sse)'"