-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (43 loc) · 1.22 KB
/
Makefile
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
# Compiler and Flags
CC := gcc
CFLAGS := -Ofast -flto -g -Wall -Wextra -pedantic -std=c11
# Source and Object Files
LIB := lib/spark.a
SRCS := src/main.c src/uci/uci.c src/eval/eval.c src/search/search.c src/zobr/zobr.c
OBJS := $(SRCS:.c=.o)
TEST_SRC := src/test/test.c src/uci/uci.c src/eval/eval.c src/search/search.c src/zobr/zobr.c
TEST_OBJ := $(TEST_SRC:.c=.o)
SPARK_REPO := https://github.com/stefanoskapa/spark.git
SPARK_DIR := external/spark
SPARK_LIB := $(SPARK_DIR)/bin/spark.a
SPARK_INCLUDE_DIR := lib
# Output Executable
TARGET := build/amadeus
TEST_TARGET := build/test
# Build Rule
all: spark $(TARGET) $(TEST_TARGET)
$(TARGET): $(OBJS)
mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIB)
$(TEST_TARGET): $(TEST_OBJ)
mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ $(TEST_OBJ) $(LIB)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
spark:
if [ ! -d "$(SPARK_DIR)" ]; then \
mkdir -p $(SPARK_INCLUDE_DIR); \
git clone $(SPARK_REPO) $(SPARK_DIR); \
else \
cd $(SPARK_DIR) && git pull; \
fi
$(MAKE) -C $(SPARK_DIR)
cp $(SPARK_LIB) lib/
cp $(SPARK_DIR)/inc/spark.h $(SPARK_INCLUDE_DIR)/
# Clean Rule
clean:
rm -f $(OBJS) $(TARGET) lib/spark.a lib/spark.h
run:
@build/amadeus
test: $(TEST_TARGET)
@./$(TEST_TARGET)