rename to brchess
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,6 +13,8 @@ debug
|
|||||||
brchess
|
brchess
|
||||||
*.o
|
*.o
|
||||||
*.s
|
*.s
|
||||||
|
*.old
|
||||||
|
*.save
|
||||||
/test/
|
/test/
|
||||||
/obj/
|
/obj/
|
||||||
/lib/
|
/lib/
|
||||||
|
115
Makefile
115
Makefile
@@ -1,44 +1,56 @@
|
|||||||
# Makefile - GNU make only.
|
# Makefile - GNU make only.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2021 Bruno Raoult ("br")
|
# Copyright (C) 2021-2023 Bruno Raoult ("br")
|
||||||
# Licensed under the GNU General Public License v3.0 or later.
|
# Licensed under the GNU General Public License v3.0 or later.
|
||||||
# Some rights reserved. See COPYING.
|
# Some rights reserved. See COPYING.
|
||||||
# * You should have received a copy of the GNU General Public License along with this
|
#
|
||||||
# program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.htmlL>.
|
# You should have received a copy of the GNU General Public License along with this
|
||||||
|
# program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
# SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||||
#
|
#
|
||||||
|
|
||||||
BINDIR := ./bin
|
SHELL := /bin/bash
|
||||||
SRCDIR := ./src
|
CC := gcc
|
||||||
OBJDIR := ./obj
|
BEAR := bear
|
||||||
DEPS := make.deps
|
CCLSFILE := compile_commands.json
|
||||||
|
DEPFILE := make.deps
|
||||||
|
|
||||||
SRC=$(wildcard $(SRCDIR)/*.c)
|
BINDIR := ./bin
|
||||||
INC=$(wildcard $(SRCDIR)/*.h)
|
SRCDIR := ./src
|
||||||
SRC_S=$(notdir $(SRC))
|
OBJDIR := ./obj
|
||||||
|
INCDIR := ./include
|
||||||
|
LIBDIR := ./lib
|
||||||
|
LIBSRCDIR := ./libsrc
|
||||||
|
LDFLAGS := -L$(LIBDIR)
|
||||||
|
LIB := br_$(shell uname -m)
|
||||||
|
SLIB := $(LIBDIR)/lib$(LIB).a
|
||||||
|
DLIB := $(LIBDIR)/lib$(LIB).so
|
||||||
|
LIBSRC := $(wildcard $(LIBSRCDIR)/*.c)
|
||||||
|
LIBOBJ := $(patsubst %.c,%.o,$(LIBSRC))
|
||||||
|
|
||||||
CC=gcc
|
SRC := $(wildcard $(SRCDIR)/*.c)
|
||||||
|
INC := $(wildcard $(SRCDIR)/*.h)
|
||||||
|
SRC_S := $(notdir $(SRC))
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
OBJ=$(addprefix $(OBJDIR)/,$(SRC_S:.c=.o))
|
OBJ=$(addprefix $(OBJDIR)/,$(SRC_S:.c=.o))
|
||||||
BIN=fen pool piece move debug eval bits bodichess
|
BIN=fen piece move eval brchess
|
||||||
|
|
||||||
LIBS = -lreadline -lncurses
|
LIBS = -l$(LIB) -lreadline -lncurses
|
||||||
CFLAGS += -std=gnu99
|
|
||||||
|
CFLAGS += -std=gnu11
|
||||||
|
|
||||||
#CFLAGS += -O2
|
#CFLAGS += -O2
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
CFLAGS += -Wall
|
CFLAGS += -Wall
|
||||||
CFLAGS += -Wextra
|
CFLAGS += -Wextra
|
||||||
CFLAGS += -march=native
|
CFLAGS += -march=native
|
||||||
#CFLAGS += -pedantic
|
|
||||||
#CFLAGS += -Wno-pointer-arith
|
|
||||||
#CFLAGS += -Werror
|
|
||||||
CFLAGS += -Wmissing-declarations
|
CFLAGS += -Wmissing-declarations
|
||||||
|
|
||||||
##################################### DEBUG flags
|
##################################### DEBUG flags
|
||||||
CFLAGS += -DDEBUG # global
|
CFLAGS += -DDEBUG # global
|
||||||
|
CFLAGS += -DDEBUG_DEBUG # enable log() functions
|
||||||
CFLAGS += -DDEBUG_POOL # memory pools management
|
CFLAGS += -DDEBUG_POOL # memory pools management
|
||||||
CFLAGS += -DDEBUG_FEN # FEN decoding
|
CFLAGS += -DDEBUG_FEN # FEN decoding
|
||||||
CFLAGS += -DDEBUG_MOVE # move generation
|
CFLAGS += -DDEBUG_MOVE # move generation
|
||||||
@@ -51,33 +63,50 @@ CFLAGS += -DDEBUG_PIECE # piece list management
|
|||||||
#CFLAGS += -DDEBUG_EVAL3 # eval 3
|
#CFLAGS += -DDEBUG_EVAL3 # eval 3
|
||||||
#CFLAGS += -DDEBUG_MEM # malloc
|
#CFLAGS += -DDEBUG_MEM # malloc
|
||||||
|
|
||||||
.PHONY: all cflags clean
|
##################################### General targets
|
||||||
|
.PHONY: compile cflags all clean
|
||||||
|
|
||||||
compile: cflags $(OBJ) $(BIN)
|
compile: lib $(OBJ) $(BIN)
|
||||||
|
|
||||||
cflags:
|
cflags:
|
||||||
@echo CFLAGS used: $(CFLAGS)
|
@echo CFLAGS used: $(CFLAGS)
|
||||||
|
|
||||||
all: clean compile
|
all: clean compile
|
||||||
|
|
||||||
$(DEPS): $(SRC) $(INC)
|
|
||||||
@echo generating dependancies.
|
|
||||||
@$(CC) -MM $(SRC) > $@
|
|
||||||
@sed -i "s|\(.*\.o\):|${OBJDIR}/\0:|" $@
|
|
||||||
|
|
||||||
include $(DEPS)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJ) core $(BIN)
|
rm -rf $(OBJ) core $(BIN)
|
||||||
|
|
||||||
|
##################################### Generate and include dependencies
|
||||||
|
.PHONY: deps cleandeps $(DEPFILE)
|
||||||
|
|
||||||
|
cleandeps:
|
||||||
|
rm -f $(DEPFILE)
|
||||||
|
|
||||||
|
deps: $(DEPFILE)
|
||||||
|
|
||||||
|
$(DEPFILE): $(SRC) $(INC)
|
||||||
|
@echo generating dependancies.
|
||||||
|
$(CC) -MM -MF $(DEPFILE) -I $(INCDIR) $(SRC)
|
||||||
|
#cp $@ $@.sav
|
||||||
|
sed -i "s|\(.*\.o\):|${OBJDIR}/\0:|" $@
|
||||||
|
|
||||||
|
include $(DEPFILE)
|
||||||
|
|
||||||
|
##################################### objects
|
||||||
|
.PHONY: obj
|
||||||
|
|
||||||
|
obj: $(OBJ)
|
||||||
#$(OBJ): $(OBJDIR)/%.o: $(SRCDIR)/%.c
|
#$(OBJ): $(OBJDIR)/%.o: $(SRCDIR)/%.c
|
||||||
# @mkdir -p $(@D)
|
# @mkdir -p $(@D)
|
||||||
# $(CC) -c $(CFLAGS) -o $@ $<
|
# $(CC) -c $(CFLAGS) -o $@ $<
|
||||||
$(OBJDIR)/%.o:
|
$(OBJDIR)/%.o: $(SRCDIR)/%.c
|
||||||
@mkdir -p $(@D)
|
echo SRC_S=$(SRC_S)
|
||||||
@echo compiling $@.
|
echo O=$(OBJ)
|
||||||
@$(CC) -c $(CFLAGS) -o $@ $<
|
mkdir -p $(@D)
|
||||||
|
@echo compiling A=$@ I=$<
|
||||||
|
$(CC) -c $(CFLAGS) -I $(INCDIR) -o $@ $<
|
||||||
|
|
||||||
|
##################################### binaries
|
||||||
#fen: CFLAGS+=-DBIN_$$@
|
#fen: CFLAGS+=-DBIN_$$@
|
||||||
#$(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
#$(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
||||||
# @echo compiling $@.
|
# @echo compiling $@.
|
||||||
@@ -87,7 +116,7 @@ $(OBJDIR)/%.o:
|
|||||||
$(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
$(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
||||||
@echo compiling $@.
|
@echo compiling $@.
|
||||||
@echo NEED_TO_CHANGE_THIS=$^
|
@echo NEED_TO_CHANGE_THIS=$^
|
||||||
@$(CC) -DBIN_$@ $(CFLAGS) $^ $(LIBS) -o $@
|
$(CC) -DBIN_$@ $(CFLAGS) -I $(INCDIR) $^ $(LDFLAGS) $(LIBS) -o $@
|
||||||
|
|
||||||
#pool: CFLAGS+=-DPOOLBIN
|
#pool: CFLAGS+=-DPOOLBIN
|
||||||
#pool: $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
#pool: $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
||||||
@@ -109,3 +138,27 @@ $(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
|
|||||||
#bits2: src/bits.c
|
#bits2: src/bits.c
|
||||||
# $(CC) $(CFLAGS) -S $^ -o $@.s
|
# $(CC) $(CFLAGS) -S $^ -o $@.s
|
||||||
# $(CC) $(CFLAGS) $^ -o $@
|
# $(CC) $(CFLAGS) $^ -o $@
|
||||||
|
|
||||||
|
##################################### br library
|
||||||
|
.PHONY: cleanlib lib
|
||||||
|
|
||||||
|
cleanlib: clean
|
||||||
|
@$(RM) -f $(SLIB) $(DLIB) $(LIBOBJ)
|
||||||
|
|
||||||
|
lib: $(DLIB) $(SLIB)
|
||||||
|
|
||||||
|
$(SLIB): $(LIBOBJ)
|
||||||
|
@echo building $@ static library.
|
||||||
|
@mkdir -p $(LIBDIR)
|
||||||
|
@$(AR) $(ARFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
$(DLIB): CFLAGS += -fPIC
|
||||||
|
$(DLIB): LDFLAGS += -shared
|
||||||
|
$(DLIB): $(LIBOBJ)
|
||||||
|
@echo building $@ shared library.
|
||||||
|
@mkdir -p $(LIBDIR)
|
||||||
|
@$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
@echo compiling $<.
|
||||||
|
@$(CC) -c $(CFLAGS) $(LDFLAGS) -I $(INCDIR) -o $@ $<
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
* Some rights reserved. See COPYING.
|
* Some rights reserved. See COPYING.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with this
|
* You should have received a copy of the GNU General Public License along with this
|
||||||
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.htmlL>.
|
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||||
*
|
*
|
||||||
@@ -79,7 +79,7 @@ enum x88_square {
|
|||||||
|
|
||||||
/* necessary not to become mad to set bitboards
|
/* necessary not to become mad to set bitboards
|
||||||
*/
|
*/
|
||||||
enum bb_square{
|
enum bb_square {
|
||||||
A1=(u64)1, B1=(u64)A1<<1, C1=(u64)B1<<1, D1=(u64)C1<<1,
|
A1=(u64)1, B1=(u64)A1<<1, C1=(u64)B1<<1, D1=(u64)C1<<1,
|
||||||
E1=(u64)D1<<1, F1=(u64)E1<<1, G1=(u64)F1<<1, H1=(u64)G1<<1,
|
E1=(u64)D1<<1, F1=(u64)E1<<1, G1=(u64)F1<<1, H1=(u64)G1<<1,
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/* bodichess.c - main loop.
|
/* brchess.c - main loop.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2021 Bruno Raoult ("br")
|
* Copyright (C) 2021 Bruno Raoult ("br")
|
||||||
* Licensed under the GNU General Public License v3.0 or later.
|
* Licensed under the GNU General Public License v3.0 or later.
|
||||||
* Some rights reserved. See COPYING.
|
* Some rights reserved. See COPYING.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with this
|
* You should have received a copy of the GNU General Public License along with this
|
||||||
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.htmlL>.
|
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||||
*
|
*
|
||||||
@@ -27,11 +27,11 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "fen.h"
|
#include "fen.h"
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "bodichess.h"
|
#include "brchess.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name; /* User printable name */
|
char *name; /* User printable name */
|
||||||
int (*func)(pos_t *, char *); /* function doing the job */
|
int (*func)(pos_t *, char *); /* function doing the job */
|
||||||
char *doc; /* function doc */
|
char *doc; /* function doc */
|
||||||
} COMMAND;
|
} COMMAND;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ COMMAND commands[] = {
|
|||||||
|
|
||||||
static int done=0;
|
static int done=0;
|
||||||
|
|
||||||
int bodichess(pos_t *pos)
|
int brchess(pos_t *pos)
|
||||||
{
|
{
|
||||||
char *buffer, *s;
|
char *buffer, *s;
|
||||||
|
|
||||||
@@ -372,10 +372,10 @@ int do_help(__attribute__((unused)) pos_t *pos,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BIN_bodichess
|
#ifdef BIN_brchess
|
||||||
/** main()
|
/** main()
|
||||||
* options:
|
* options:
|
||||||
int bodichess(pos_t *pos)
|
int brchess(pos_t *pos)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int usage(char *prg)
|
static int usage(char *prg)
|
||||||
@@ -413,6 +413,6 @@ int main(int ac, char **av)
|
|||||||
if (optind < ac)
|
if (optind < ac)
|
||||||
return usage(*av);
|
return usage(*av);
|
||||||
|
|
||||||
return bodichess(pos);
|
return brchess(pos);
|
||||||
}
|
}
|
||||||
#endif /* BIN_bodichess */
|
#endif /* BIN_brchess */
|
||||||
|
@@ -5,17 +5,17 @@
|
|||||||
* Some rights reserved. See COPYING.
|
* Some rights reserved. See COPYING.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with this
|
* You should have received a copy of the GNU General Public License along with this
|
||||||
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.htmlL>.
|
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BODICHESS_H
|
#ifndef BRCHESS_H
|
||||||
#define BODICHESS_H
|
#define BRCHESS_H
|
||||||
|
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
|
|
||||||
int bodichess(pos_t *pos);
|
int brchess(pos_t *pos);
|
||||||
|
|
||||||
#endif /* BODICHESS_H */
|
#endif /* BRCHESS_H */
|
||||||
|
Reference in New Issue
Block a user