Compare commits
3 Commits
242b501404
...
0c15be28b1
Author | SHA1 | Date | |
---|---|---|---|
0c15be28b1 | |||
879bda850c | |||
0a0c3227b8 |
138
Makefile
138
Makefile
@@ -11,9 +11,17 @@
|
||||
#
|
||||
|
||||
SHELL := /bin/bash
|
||||
CC := gcc
|
||||
#CC := gcc-13
|
||||
#CC := clang
|
||||
|
||||
ifeq ($(CC),)
|
||||
CC = gcc
|
||||
endif
|
||||
ifeq ($(CC),cc)
|
||||
CC = gcc
|
||||
endif
|
||||
ifeq ($(BUILD),)
|
||||
BUILD = release
|
||||
endif
|
||||
|
||||
BEAR := bear
|
||||
TOUCH := touch
|
||||
RM := rm
|
||||
@@ -56,9 +64,6 @@ CPPFILES := $(SRC:.c=.i) $(TSTSRC:.c=.i)
|
||||
# inspired from:
|
||||
# https://eugene-babichenko.github.io/blog/2019/09/28/nightly-versions-makefiles/
|
||||
|
||||
# default empty version
|
||||
#VERSION :=
|
||||
|
||||
# last commit and date
|
||||
COMMIT := $(shell git rev-parse --short HEAD)
|
||||
DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
|
||||
@@ -85,31 +90,30 @@ endif
|
||||
##################################### pre-processor flags
|
||||
CPPFLAGS := -I$(BRINCDIR) -I$(INCDIR) -DVERSION=\"$(VERSION)\"
|
||||
|
||||
CPPFLAGS += -DNDEBUG # assert (unused)
|
||||
CPPFLAGS += -DWARN_ON # brlib bug.h
|
||||
CPPFLAGS += -DBUG_ON # brlib bug.h
|
||||
ifeq ($(BUILD),release)
|
||||
CPPFLAGS += -DNDEBUG # assert (unused)
|
||||
else ifeq ($(BUILD),dev)
|
||||
CPPFLAGS += -DWARN_ON # brlib bug.h
|
||||
CPPFLAGS += -DBUG_ON # brlib bug.h
|
||||
|
||||
#CPPFLAGS += -DDEBUG # global - unused
|
||||
#CPPFLAGS += -DDEBUG_DEBUG # enable log() functions
|
||||
#CPPFLAGS += -DDEBUG_DEBUG_C # enable log() settings
|
||||
#CPPFLAGS += -DDEBUG_POOL # memory pools management
|
||||
#CPPFLAGS += -DDEBUG_POS # position.c
|
||||
#CPPFLAGS += -DDEBUG_MOVE # move generation
|
||||
|
||||
# fen.c
|
||||
#CPPFLAGS += -DDEBUG_FEN # FEN decoding
|
||||
|
||||
# hash / TT
|
||||
#CPPFLAGS += -DZOBRIST_VERIFY # double chk zobrist
|
||||
#CPPFLAGS += -DPERFT_MOVE_HISTORY # perft, keep prev moves
|
||||
|
||||
# attack.c
|
||||
#CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS # sq_attackers
|
||||
#CPPFLAGS += -DDEBUG_ATTACK_PINNERS # sq_pinners details
|
||||
|
||||
#CPPFLAGS += -DDEBUG_EVAL # eval functions
|
||||
#CPPFLAGS += -DDEBUG_PIECE # piece list management
|
||||
#CPPFLAGS += -DDEBUG_SEARCH # move search
|
||||
#CPPFLAGS += -DDEBUG # global - unused
|
||||
#CPPFLAGS += -DDEBUG_DEBUG # enable log() functions
|
||||
#CPPFLAGS += -DDEBUG_DEBUG_C # enable log() settings
|
||||
#CPPFLAGS += -DDEBUG_POOL # memory pools management
|
||||
#CPPFLAGS += -DDEBUG_POS # position.c
|
||||
#CPPFLAGS += -DDEBUG_MOVE # move generation
|
||||
# fen.c
|
||||
#CPPFLAGS += -DDEBUG_FEN # FEN decoding
|
||||
# hash / TT
|
||||
#CPPFLAGS += -DZOBRIST_VERIFY # double chk zobrist
|
||||
#CPPFLAGS += -DPERFT_MOVE_HISTORY # perft, keep prev moves
|
||||
# attack.c
|
||||
#CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS # sq_attackers
|
||||
#CPPFLAGS += -DDEBUG_ATTACK_PINNERS # sq_pinners details
|
||||
# CPPFLAGS += -DDEBUG_EVAL # eval functions
|
||||
#CPPFLAGS += -DDEBUG_PIECE # piece list management
|
||||
#CPPFLAGS += -DDEBUG_SEARCH # move search
|
||||
endif
|
||||
|
||||
CPPFLAGS += -DDIAGRAM_SYM # UTF8 symbols in diagrams
|
||||
|
||||
@@ -119,41 +123,37 @@ CPPFLAGS := $(strip $(CPPFLAGS))
|
||||
##################################### compiler flags
|
||||
CFLAGS := -std=gnu11
|
||||
|
||||
### dev OR release
|
||||
|
||||
# dev
|
||||
CFLAGS += -g # symbols (gdb, perf, etc.)
|
||||
CFLAGS += -ginline-points # inlined funcs debug info
|
||||
#CFLAGS += -Og
|
||||
# for gprof
|
||||
#CFLAGS += -pg
|
||||
# Next one may be useful for valgrind (when invalid instructions)
|
||||
#CFLAGS += -mno-tbm
|
||||
|
||||
# release
|
||||
CFLAGS += -O3
|
||||
|
||||
CFLAGS += -march=native
|
||||
CFLAGS += -flto
|
||||
CFLAGS += -funroll-loops
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Wextra
|
||||
CFLAGS += -Wshadow
|
||||
CFLAGS += -Wmissing-declarations
|
||||
|
||||
### dev OR release
|
||||
ifeq ($(BUILD),release)
|
||||
CFLAGS += -O3
|
||||
|
||||
CFLAGS += -march=native
|
||||
CFLAGS += -flto
|
||||
CFLAGS += -funroll-loops
|
||||
else ifeq ($(BUILD),dev)
|
||||
CFLAGS += -Og
|
||||
CFLAGS += -g # symbols (gdb, perf, etc.)
|
||||
CFLAGS += -ginline-points # inlined funcs debug info
|
||||
# for gprof
|
||||
#CFLAGS += -pg
|
||||
# Next one may be useful for valgrind (when invalid instructions)
|
||||
#CFLAGS += -mno-tbm
|
||||
endif
|
||||
|
||||
CFLAGS := $(strip $(CFLAGS))
|
||||
|
||||
# development CFLAGS - unused - TODO
|
||||
#DEV_CFLAGS := -Og
|
||||
#DEV_CFLAGS += -g
|
||||
|
||||
# release CFLAGS - unused - TODO
|
||||
#REL_CFLAGS := -Ofast
|
||||
|
||||
##################################### linker flags
|
||||
LDFLAGS := --static
|
||||
LDFLAGS += -L$(BRLIBDIR)
|
||||
LDFLAGS += -flto
|
||||
|
||||
ifeq ($(BUILD),release)
|
||||
LDFLAGS += -flto
|
||||
endif
|
||||
|
||||
LDFLAGS := $(strip $(LDFLAGS))
|
||||
|
||||
@@ -198,9 +198,15 @@ $(sort all $(MAKECMDGOALS)):
|
||||
else
|
||||
|
||||
##################################### General targets
|
||||
.PHONY: all compile clean cleanall
|
||||
.PHONY: all release dev compile clean cleanall
|
||||
|
||||
all: $(TARGET)
|
||||
all: testing $(TARGET)
|
||||
|
||||
release:
|
||||
$(MAKE) BUILD=release clean all
|
||||
|
||||
dev:
|
||||
$(MAKE) BUILD=dev clean all
|
||||
|
||||
compile: brlib objs
|
||||
|
||||
@@ -316,7 +322,7 @@ cleanbindir:
|
||||
$(call rmdir,$(BINDIR),binaries)
|
||||
|
||||
$(TARGET): libs $(OBJ) | $(BINDIR)
|
||||
@echo generating $@.
|
||||
@echo linking $@.
|
||||
$(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o $@
|
||||
|
||||
##################################### pre-processed (.i) and assembler (.s) output
|
||||
@@ -400,35 +406,35 @@ test:
|
||||
testing: $(TEST)
|
||||
|
||||
bin/piece-test: test/piece-test.c $(FEN_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(FEN_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/fen-test: test/fen-test.c test/common-test.h $(FEN_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(FEN_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/bitboard-test: test/bitboard-test.c test/common-test.h $(BB_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(BB_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/movegen-test: test/movegen-test.c test/common-test.h $(MOVEGEN_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(MOVEGEN_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/attack-test: test/attack-test.c test/common-test.h $(ATTACK_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(ATTACK_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/movedo-test: test/movedo-test.c test/common-test.h $(MOVEDO_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(MOVEDO_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/perft-test: test/perft-test.c test/common-test.h $(PERFT_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(PERFT_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
bin/tt-test: test/tt-test.c test/common-test.h $(TT_OBJS)
|
||||
@echo compiling $@ test executable.
|
||||
@echo linking $@ test executable.
|
||||
@$(CC) $(ALL_CFLAGS) $< $(TT_OBJS) $(ALL_LDFLAGS) -o $@
|
||||
|
||||
##################################### Makefile debug
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#ifndef HASH_H
|
||||
#define HASH_H
|
||||
|
||||
#include <bug.h>
|
||||
//#include <bug.h>
|
||||
|
||||
#include "chessdefs.h"
|
||||
|
||||
@@ -121,7 +121,7 @@ bool zobrist_verify(pos_t *pos);
|
||||
*/
|
||||
static inline void tt_prefetch(hkey_t key)
|
||||
{
|
||||
bug_on(!hash_tt.keys);
|
||||
// bug_on(!hash_tt.keys);
|
||||
__builtin_prefetch(hash_tt.keys + (key & hash_tt.mask));
|
||||
}
|
||||
|
||||
|
@@ -360,7 +360,7 @@ bitboard_t pos_king_blockers(const pos_t *pos, const color_t color, const bitboa
|
||||
bool pos_ok(pos_t *pos, const bool strict)
|
||||
{
|
||||
int n, count = 0, bbcount = 0, error = 0;
|
||||
color_t us = pos->turn, them = OPPONENT(us);
|
||||
color_t __unused us = pos->turn, __unused them = OPPONENT(us);
|
||||
|
||||
/* force BUG_ON and WARN_ON */
|
||||
# pragma push_macro("BUG_ON")
|
||||
@@ -391,7 +391,7 @@ bool pos_ok(pos_t *pos, const bool strict)
|
||||
}
|
||||
for (square_t sq = 0; sq < 64; ++sq) {
|
||||
piece_t piece = pos->board[sq];
|
||||
bitboard_t match;
|
||||
__unused bitboard_t match;
|
||||
if (piece == EMPTY)
|
||||
continue;
|
||||
color_t c = COLOR(piece);
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <brlib.h>
|
||||
#include <bitops.h>
|
||||
#include <struct-group.h>
|
||||
#include <bug.h>
|
||||
// #include <bug.h>
|
||||
|
||||
#include "chessdefs.h"
|
||||
#include "hash.h"
|
||||
|
@@ -17,8 +17,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <bug.h>
|
||||
|
||||
#include "chessdefs.h"
|
||||
|
||||
#undef safe_malloc
|
||||
@@ -29,6 +27,7 @@
|
||||
#pragma push_macro("BUG_ON")
|
||||
#undef BUG_ON
|
||||
#define BUG_ON
|
||||
#include <bug.h>
|
||||
|
||||
#define safe_malloc(size) ({ \
|
||||
void *_ret = malloc(size); \
|
||||
|
@@ -61,10 +61,12 @@ struct fentest {
|
||||
* "r3k2r/p6p/8/B7/1pp1p3/3b4/P6P/R3K2R w KQkq - 0 1" // Perft(6) == 77,054,993
|
||||
* },
|
||||
*/
|
||||
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
||||
"from https://www.talkchess.com/forum/viewtopic.php?t=42463",
|
||||
"rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6"
|
||||
},
|
||||
/*
|
||||
* { __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
||||
* "from https://www.talkchess.com/forum/viewtopic.php?t=42463",
|
||||
* "rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6"
|
||||
* },
|
||||
*/
|
||||
/*
|
||||
r3k2r/pb3p2/5npp/n2p4/1p1PPB2/6P1/P2N1PBP/R3K2R w KQkq - // Perft(5) == 29,179,893
|
||||
*/
|
||||
|
Reference in New Issue
Block a user