]> git.sesse.net Git - stockfish/blobdiff - src/Makefile
Merge remote-tracking branch 'upstream/master' into HEAD
[stockfish] / src / Makefile
index 340b3008381be752d1d9edf1cd3020bffd323961..d7e09c8c682b510872f613c10118b12118b2cea9 100644 (file)
@@ -1,7 +1,5 @@
 # Stockfish, a UCI chess playing engine derived from Glaurung 2.1
-# Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-# Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
-# Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
+# Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
 #
 # Stockfish is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -39,9 +37,12 @@ PGOBENCH = ./$(EXE) bench
 SRCS = benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp \
        material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp \
        search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp \
-       nnue/evaluate_nnue.cpp nnue/features/half_kp.cpp
+       nnue/evaluate_nnue.cpp nnue/features/half_kp.cpp \
+       hashprobe.grpc.pb.cc hashprobe.pb.cc
+CLISRCS = client.cpp hashprobe.grpc.pb.cc hashprobe.pb.cc uci.cpp
 
 OBJS = $(notdir $(SRCS:.cpp=.o))
+CLIOBJS = $(notdir $(CLISRCS:.cpp=.o))
 
 VPATH = syzygy:nnue:nnue/features
 
@@ -307,7 +308,7 @@ endif
 ifeq ($(COMP),gcc)
        comp=gcc
        CXX=g++
-       CXXFLAGS += -pedantic -Wextra -Wshadow
+       CXXFLAGS += -pedantic -Wextra
 
        ifeq ($(arch),$(filter $(arch),armv7 armv8))
                ifeq ($(OS),Android)
@@ -366,9 +367,11 @@ ifeq ($(COMP),clang)
 
        ifneq ($(KERNEL),Darwin)
        ifneq ($(KERNEL),OpenBSD)
+       ifneq ($(KERNEL),FreeBSD)
                LDFLAGS += -latomic
        endif
        endif
+       endif
 
        ifeq ($(arch),$(filter $(arch),armv7 armv8))
                ifeq ($(OS),Android)
@@ -381,19 +384,6 @@ ifeq ($(COMP),clang)
        endif
 endif
 
-ifeq ($(comp),icc)
-       profile_make = icc-profile-make
-       profile_use = icc-profile-use
-else
-ifeq ($(comp),clang)
-       profile_make = clang-profile-make
-       profile_use = clang-profile-use
-else
-       profile_make = gcc-profile-make
-       profile_use = gcc-profile-use
-endif
-endif
-
 ifeq ($(KERNEL),Darwin)
        CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.14
        LDFLAGS += -arch $(arch) -mmacosx-version-min=10.14
@@ -405,20 +395,30 @@ endif
 # Currently we don't know how to make PGO builds with the NDK yet.
 ifeq ($(COMP),ndk)
        CXXFLAGS += -stdlib=libc++ -fPIE
+       comp=clang
        ifeq ($(arch),armv7)
-               comp=armv7a-linux-androideabi16-clang
                CXX=armv7a-linux-androideabi16-clang++
                CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
                STRIP=arm-linux-androideabi-strip
        endif
        ifeq ($(arch),armv8)
-               comp=aarch64-linux-android21-clang
                CXX=aarch64-linux-android21-clang++
                STRIP=aarch64-linux-android-strip
        endif
        LDFLAGS += -static-libstdc++ -pie -lm -latomic
 endif
 
+ifeq ($(comp),icc)
+       profile_make = icc-profile-make
+       profile_use = icc-profile-use
+else ifeq ($(comp),clang)
+       profile_make = clang-profile-make
+       profile_use = clang-profile-use
+else
+       profile_make = gcc-profile-make
+       profile_use = gcc-profile-use
+endif
+
 ### Travis CI script uses COMPILER to overwrite CXX
 ifdef COMPILER
        COMPCXX=$(COMPILER)
@@ -469,7 +469,7 @@ endif
 ### 3.3 Optimization
 ifeq ($(optimize),yes)
 
-       CXXFLAGS += -O3
+       CXXFLAGS += -O3 -g
 
        ifeq ($(comp),gcc)
                ifeq ($(OS), Android)
@@ -482,6 +482,10 @@ ifeq ($(optimize),yes)
                        CXXFLAGS += -mdynamic-no-pic
                endif
        endif
+
+       ifeq ($(comp),clang)
+               CXXFLAGS += -fexperimental-new-pass-manager
+       endif
 endif
 
 ### 3.4 Bits
@@ -590,11 +594,8 @@ endif
 ### needs access to the optimization flags.
 ifeq ($(optimize),yes)
 ifeq ($(debug), no)
-       ifeq ($(COMP),ndk)
-               CXXFLAGS += -flto=thin
-               LDFLAGS += $(CXXFLAGS)
-       else ifeq ($(comp),clang)
-               CXXFLAGS += -flto=thin
+       ifeq ($(comp),clang)
+               CXXFLAGS += -flto
                ifneq ($(findstring MINGW,$(KERNEL)),)
                        CXXFLAGS += -fuse-ld=lld
                else ifneq ($(findstring MSYS,$(KERNEL)),)
@@ -614,7 +615,7 @@ ifeq ($(debug), no)
                        LDFLAGS += -save-temps
                endif
        else
-               CXXFLAGS += -flto=thin
+               CXXFLAGS += -flto
                LDFLAGS += $(CXXFLAGS)
        endif
 
@@ -717,7 +718,7 @@ endif
         config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
         clang-profile-use clang-profile-make
 
-build: config-sanity net
+build: net config-sanity
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
 
 profile-build: net config-sanity objclean profileclean
@@ -788,9 +789,9 @@ default:
 ### Section 5. Private Targets
 ### ==========================================================================
 
-all: $(EXE) .depend
+all: $(EXE) client .depend
 
-config-sanity:
+config-sanity: net
        @echo ""
        @echo "Config:"
        @echo "debug: '$(debug)'"
@@ -884,6 +885,32 @@ icc-profile-use:
        EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \
        all
 
+### GRPC
+
+PROTOS_PATH = .
+PROTOC = protoc
+GRPC_CPP_PLUGIN = grpc_cpp_plugin
+GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
+
+%.grpc.pb.h %.grpc.pb.cc: %.proto
+       $(PROTOC) -I $(PROTOS_PATH) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
+
+# oh my
+%.cpp: %.cc
+       cp $< $@
+
+%.pb.h %.pb.cc: %.proto
+       $(PROTOC) -I $(PROTOS_PATH) --cpp_out=. $<
+
+#LDFLAGS += -Wl,-Bstatic -Wl,-\( -lprotobuf -lgrpc++_unsecure -lgrpc_unsecure -lgrpc -lz -Wl,-\) -Wl,-Bdynamic -ldl
+LDFLAGS += /usr/lib/x86_64-linux-gnu/libprotobuf.a /usr/lib/x86_64-linux-gnu/libgrpc++_unsecure.a /usr/lib/x86_64-linux-gnu/libgrpc_unsecure.a /usr/lib/x86_64-linux-gnu/libgrpc.a /usr/lib/x86_64-linux-gnu/libcares.a -ldl -lz
+#LDFLAGS += /usr/lib/x86_64-linux-gnu/libprotobuf.a /usr/lib/libgrpc++_unsecure.a /usr/lib/libgrpc_unsecure.a /usr/lib/libgrpc.a /usr/lib/x86_64-linux-gnu/libcares.a -ldl -lz
+
+client: $(CLIOBJS)
+       $(CXX) -o $@ $(CLIOBJS) $(LDFLAGS)
+
+# Other stuff
+
 .depend:
        -@$(CXX) $(DEPENDFLAGS) -MM $(SRCS) > $@ 2> /dev/null