-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (53 loc) · 2.38 KB
/
Makefile
File metadata and controls
63 lines (53 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
CC = g++
UNAME_S := $(shell uname -s)
# Compiler flags common to all platforms and build types.
# Note: -lboost_program_options is a linker flag and belongs only in link steps;
# moved out of FLAGS so it isn't passed during compilation.
FLAGS = -march=native -pedantic -std=c++17 -Wall -Werror -Wextra -Wshadow
# -O3 instead of -Ofast: drops -ffast-math, which can silently break
# floating-point behavior. The remaining flags are safe on both platforms.
OPT_FLAGS = -O3 -fno-signed-zeros -fno-trapping-math -funroll-loops
DEBUG_FLAGS = -O0 -g
ifeq ($(UNAME_S), Darwin)
# Homebrew on Apple Silicon installs to /opt/homebrew.
BREW_PREFIX := $(shell brew --prefix 2>/dev/null || echo /opt/homebrew)
FLAGS += -I$(BREW_PREFIX)/include
LINK_FLAGS = -L$(BREW_PREFIX)/lib -lboost_program_options
else
# Linux/GCC: restore the parallel STL and OpenMP flags if ever wired up.
LINK_FLAGS = -lboost_program_options
endif
OBJECTS = build/board.o build/engine.o build/game.o build/magics.o \
build/main.o build/masks.o build/transposition_table.o \
build/piece_sq_tables.o
all : build $(OBJECTS)
$(CC) -o build/OmegaZero $(OBJECTS) $(FLAGS) $(OPT_FLAGS) $(LINK_FLAGS)
build/%.o: src/%.cc
$(CC) -c -o $@ $< $(FLAGS) $(OPT_FLAGS)
build :
mkdir $@
src/masks.cc :
python3 scripts/generate_masks.py
src/magics.cc :
python3 scripts/mine_magics.py
.PHONY: check-deps
check-deps:
@echo "Checking dependencies..."
@command -v $(CC) >/dev/null 2>&1 || \
{ echo "ERROR: $(CC) not found. Install it:"; \
if [ "$(UNAME_S)" = "Darwin" ]; then echo " xcode-select --install"; \
else echo " sudo apt-get install g++"; fi; exit 1; }
@command -v python3 >/dev/null 2>&1 || \
{ echo "ERROR: python3 not found (needed to generate masks/magics). Install it:"; \
if [ "$(UNAME_S)" = "Darwin" ]; then echo " brew install python3"; \
else echo " sudo apt-get install python3"; fi; exit 1; }
@$(CC) $(FLAGS) -x c++ /dev/null -c -o /dev/null >/dev/null 2>&1 \
&& echo '#include <boost/program_options.hpp>' | \
$(CC) $(FLAGS) -x c++ - -fsyntax-only >/dev/null 2>&1 \
|| { echo "ERROR: boost not found. Install it:"; \
if [ "$(UNAME_S)" = "Darwin" ]; then echo " brew install boost"; \
else echo " sudo apt-get install libboost-program-options-dev"; fi; exit 1; }
@echo "All dependencies satisfied. Run 'make' to build."
.PHONY: clean
clean:
rm -rf build build