Makefile: add 'build=' option
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ perf.data
|
|||||||
valgrind.out
|
valgrind.out
|
||||||
gmon.out
|
gmon.out
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
.lastbuild
|
66
Makefile
66
Makefile
@@ -12,16 +12,6 @@
|
|||||||
|
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
ifeq ($(CC),)
|
|
||||||
CC = gcc
|
|
||||||
endif
|
|
||||||
ifeq ($(CC),cc)
|
|
||||||
CC = gcc
|
|
||||||
endif
|
|
||||||
ifeq ($(BUILD),)
|
|
||||||
BUILD = dev
|
|
||||||
endif
|
|
||||||
|
|
||||||
BEAR := bear
|
BEAR := bear
|
||||||
TOUCH := touch
|
TOUCH := touch
|
||||||
RM := rm
|
RM := rm
|
||||||
@@ -60,6 +50,38 @@ TARGET := $(addprefix $(BINDIR)/,$(TARGET_FN))
|
|||||||
ASMFILES := $(SRC:.c=.s) $(TSTSRC:.c=.s)
|
ASMFILES := $(SRC:.c=.s) $(TSTSRC:.c=.s)
|
||||||
CPPFILES := $(SRC:.c=.i) $(TSTSRC:.c=.i)
|
CPPFILES := $(SRC:.c=.i) $(TSTSRC:.c=.i)
|
||||||
|
|
||||||
|
##################################### Check for compiler and requested build
|
||||||
|
BUILDS := release dev perf debug
|
||||||
|
# last compilation build
|
||||||
|
BUILDFILE := .lastbuild
|
||||||
|
lastbuild := $(file < $(BUILDFILE))
|
||||||
|
$(info last:$(lastbuild))
|
||||||
|
# default to gcc
|
||||||
|
CC ?= cc
|
||||||
|
ifeq ($(CC),cc)
|
||||||
|
CC = gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
# if no build specified, use last one
|
||||||
|
ifeq ($(build),)
|
||||||
|
build := $(lastbuild)
|
||||||
|
endif
|
||||||
|
# if build is still undefined, set a default
|
||||||
|
ifeq ($(build),)
|
||||||
|
build := release
|
||||||
|
endif
|
||||||
|
|
||||||
|
# check for valid build
|
||||||
|
ifeq ($(filter $(build),$(BUILDS)),)
|
||||||
|
$(error Error: Unknown build=`$(build)`. Possible builds are: $(BUILDS))
|
||||||
|
endif
|
||||||
|
|
||||||
|
# if new build, rewrite BUILDFILE
|
||||||
|
ifneq ($(build),$(lastbuild))
|
||||||
|
$(info New build:`$(build)` (was:$(lastbuild)))
|
||||||
|
$(file >$(BUILDFILE),$(build))
|
||||||
|
endif
|
||||||
|
|
||||||
##################################### set a version string
|
##################################### set a version string
|
||||||
# inspired from:
|
# inspired from:
|
||||||
# https://eugene-babichenko.github.io/blog/2019/09/28/nightly-versions-makefiles/
|
# https://eugene-babichenko.github.io/blog/2019/09/28/nightly-versions-makefiles/
|
||||||
@@ -90,11 +112,13 @@ endif
|
|||||||
##################################### pre-processor flags
|
##################################### pre-processor flags
|
||||||
CPPFLAGS := -I$(BRINCDIR) -I$(INCDIR) -DVERSION=\"$(VERSION)\"
|
CPPFLAGS := -I$(BRINCDIR) -I$(INCDIR) -DVERSION=\"$(VERSION)\"
|
||||||
|
|
||||||
|
CPPFLAGS += -DDIAGRAM_SYM # UTF8 symbols in diagrams
|
||||||
|
|
||||||
ifeq ($(BUILD),release)
|
ifeq ($(BUILD),release)
|
||||||
CPPFLAGS += -DNDEBUG # assert (unused)
|
CPPFLAGS += -DNDEBUG # assert (unused)
|
||||||
else # ifeq ($(BUILD),dev)
|
else # ifeq ($(BUILD),dev)
|
||||||
CPPFLAGS += -DWARN_ON # brlib bug.h
|
CPPFLAGS += -DWARN_ON=1 # brlib bug.h
|
||||||
CPPFLAGS += -DBUG_ON # brlib bug.h
|
CPPFLAGS += -DBUG_ON=1 # brlib bug.h
|
||||||
|
|
||||||
#CPPFLAGS += -DDEBUG # global - unused
|
#CPPFLAGS += -DDEBUG # global - unused
|
||||||
#CPPFLAGS += -DDEBUG_DEBUG # enable log() functions
|
#CPPFLAGS += -DDEBUG_DEBUG # enable log() functions
|
||||||
@@ -115,8 +139,6 @@ else # ifeq ($(BUILD),dev)
|
|||||||
#CPPFLAGS += -DDEBUG_SEARCH # move search
|
#CPPFLAGS += -DDEBUG_SEARCH # move search
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPFLAGS += -DDIAGRAM_SYM # UTF8 symbols in diagrams
|
|
||||||
|
|
||||||
# remove extraneous spaces (due to spaces before comments)
|
# remove extraneous spaces (due to spaces before comments)
|
||||||
CPPFLAGS := $(strip $(CPPFLAGS))
|
CPPFLAGS := $(strip $(CPPFLAGS))
|
||||||
|
|
||||||
@@ -132,8 +154,8 @@ CFLAGS += -march=native
|
|||||||
### dev OR release
|
### dev OR release
|
||||||
ifeq ($(BUILD),release)
|
ifeq ($(BUILD),release)
|
||||||
CFLAGS += -O3
|
CFLAGS += -O3
|
||||||
CFLAGS += -g
|
#CFLAGS += -g
|
||||||
CFLAGS += -ginline-points # inlined funcs debug info
|
#CFLAGS += -ginline-points # inlined funcs debug info
|
||||||
CFLAGS += -funroll-loops
|
CFLAGS += -funroll-loops
|
||||||
CFLAGS += -flto
|
CFLAGS += -flto
|
||||||
else ifeq ($(BUILD),dev)
|
else ifeq ($(BUILD),dev)
|
||||||
@@ -210,9 +232,9 @@ $(sort all $(MAKECMDGOALS)):
|
|||||||
else
|
else
|
||||||
|
|
||||||
##################################### General targets
|
##################################### General targets
|
||||||
.PHONY: all release dev perf debug compile clean cleanall
|
.PHONY: all release dev perf debug compile libs clean cleanall
|
||||||
|
|
||||||
all: testing $(TARGET)
|
all: libs testing $(TARGET)
|
||||||
|
|
||||||
release:
|
release:
|
||||||
$(MAKE) BUILD=release clean all
|
$(MAKE) BUILD=release clean all
|
||||||
@@ -314,7 +336,7 @@ cleanobjdir: cleanobj
|
|||||||
# "normal" ones, but do not imply to rebuild target.
|
# "normal" ones, but do not imply to rebuild target.
|
||||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) $(DEPDIR)
|
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) $(DEPDIR)
|
||||||
@echo compiling brchess module: $< "->" $@.
|
@echo compiling brchess module: $< "->" $@.
|
||||||
@$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
##################################### brlib libraries
|
##################################### brlib libraries
|
||||||
.PHONY: cleanbrlib cleanallbrlib brlib
|
.PHONY: cleanbrlib cleanallbrlib brlib
|
||||||
@@ -325,8 +347,10 @@ cleanbrlib:
|
|||||||
cleanallbrlib:
|
cleanallbrlib:
|
||||||
$(MAKE) -C $(BRLIB) cleanall
|
$(MAKE) -C $(BRLIB) cleanall
|
||||||
|
|
||||||
|
export build
|
||||||
brlib:
|
brlib:
|
||||||
$(MAKE) -C $(BRLIB) libs
|
$(info calling with build=$(build))
|
||||||
|
$(MAKE) -e -C $(BRLIB) lib-static
|
||||||
|
|
||||||
##################################### brchess binaries
|
##################################### brchess binaries
|
||||||
.PHONY: targets cleanbin cleanbindir
|
.PHONY: targets cleanbin cleanbindir
|
||||||
@@ -398,7 +422,7 @@ TEST += movedo-test perft-test tt-test
|
|||||||
|
|
||||||
PIECE_OBJS := piece.o
|
PIECE_OBJS := piece.o
|
||||||
FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \
|
FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \
|
||||||
hq.o attack.o hash.o init.o misc.o move.o
|
hq.o attack.o hash.o init.o misc.o alloc.o move.o
|
||||||
BB_OBJS := $(FEN_OBJS)
|
BB_OBJS := $(FEN_OBJS)
|
||||||
MOVEGEN_OBJS := $(BB_OBJS) move-gen.o
|
MOVEGEN_OBJS := $(BB_OBJS) move-gen.o
|
||||||
ATTACK_OBJS := $(MOVEGEN_OBJS)
|
ATTACK_OBJS := $(MOVEGEN_OBJS)
|
||||||
|
2
brlib
2
brlib
Submodule brlib updated: 553dc6bd07...a48ebf9099
Reference in New Issue
Block a user