1- # :( openbench and fishtest require make
21EXE = engine
3- CXX ?= g++
4- CXXFLAGS ?= -std=c++17 -Wall -Wextra
5- OPTFLAGS ?= -O3
6- ifeq ($(LTO ) , yes)
7- OPTFLAGS += -flto
8- ifeq ($(findstring clang++,$(CXX)),clang++)
9- LDFLAGS += -fuse-ld=lld
10- endif
11- endif
12- ifeq ($(debug ) ,no)
13- CXXFLAGS += -DNDEBUG
14- endif
15- ARCH ?= native
162
17- ifeq ($(ARCH ) , native)
18- CXXFLAGS += -march=native -mtune=native
19- endif
20- ifeq ($(ARCH ) , avx2)
21- CXXFLAGS += -march=haswell -mavx2 -mbmi -mbmi2 -msse4.1
22- endif
23- ifeq ($(ARCH ) , bmi2)
24- CXXFLAGS += -mbmi2
25- endif
26- ifeq ($(ARCH ) , sse41)
27- CXXFLAGS += -msse4.1
28- endif
29- ifeq ($(ARCH ) , x86-64)
30- CXXFLAGS += -march=x86-64
31- endif
32- deps :
33- test -d deps/chesslib || git clone https://github.com/winapiadmin/chesslib deps/chesslib
34- test -d deps/tbprobe || git clone https://github.com/winapiadmin/tb_probing_tool deps/tbprobe
35- all : deps
36- @$(MAKE ) --no-print-directory $(EXE )
37- # Tuning is not required on Makefile, use CMake.
38- SRCS := \
39- $(filter-out tune_cmd.cpp,$(wildcard * .cpp) ) \
40- $(filter-out % tests.cpp,$(wildcard deps/chesslib/* .cpp) ) \
41- deps/tbprobe/syzygy/tbprobe.cpp
42- OBJS = $(SRCS:.cpp=.o )
43- SHA := $(shell git rev-parse --short HEAD 2>/dev/null)
44- TAG := $(shell git describe --tags --exact-match 2>/dev/null)
45- ifeq ($(debug ) ,yes)
46- BUILD_VERSION := debug-$(SHA )
47- else ifneq ($(TAG),)
48- BUILD_VERSION := $(TAG )
49- else
50- BUILD_VERSION := release-$(SHA )
51- endif
52-
53- CXXFLAGS += -DBUILD_VERSION=\"$(BUILD_VERSION ) \"
54- .PHONY : all clean deps
55-
56- $(EXE ) : $(OBJS )
57- $(CXX ) $(CXXFLAGS ) $(OPTFLAGS ) -o $(EXE ) $(OBJS )
58-
59- % .o : % .cpp
60- $(CXX ) $(CXXFLAGS ) $(OPTFLAGS ) -Ideps/chesslib -Ideps/tbprobe/syzygy -c $< -o $@
61-
62- clean :
63- rm -f $(OBJS ) $(EXE )
3+ all :
4+ cmake -B build -DCMAKE_BUILD_TYPE=Release
5+ cmake --build build
6+ cp build/engine $(EXE )
0 commit comments