rename to brchess

This commit is contained in:
2023-06-22 16:07:16 +02:00
parent 6f3570ef40
commit cb94ca52b9
5 changed files with 102 additions and 47 deletions

2
.gitignore vendored
View File

@@ -13,6 +13,8 @@ debug
brchess
*.o
*.s
*.old
*.save
/test/
/obj/
/lib/

111
Makefile
View File

@@ -1,44 +1,56 @@
# 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.
# 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>
#
SHELL := /bin/bash
CC := gcc
BEAR := bear
CCLSFILE := compile_commands.json
DEPFILE := make.deps
BINDIR := ./bin
SRCDIR := ./src
OBJDIR := ./obj
DEPS := make.deps
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))
SRC=$(wildcard $(SRCDIR)/*.c)
INC=$(wildcard $(SRCDIR)/*.h)
SRC_S=$(notdir $(SRC))
CC=gcc
SRC := $(wildcard $(SRCDIR)/*.c)
INC := $(wildcard $(SRCDIR)/*.h)
SRC_S := $(notdir $(SRC))
.SECONDEXPANSION:
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
CFLAGS += -std=gnu99
LIBS = -l$(LIB) -lreadline -lncurses
CFLAGS += -std=gnu11
#CFLAGS += -O2
CFLAGS += -g
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -march=native
#CFLAGS += -pedantic
#CFLAGS += -Wno-pointer-arith
#CFLAGS += -Werror
CFLAGS += -Wmissing-declarations
##################################### DEBUG flags
CFLAGS += -DDEBUG # global
CFLAGS += -DDEBUG_DEBUG # enable log() functions
CFLAGS += -DDEBUG_POOL # memory pools management
CFLAGS += -DDEBUG_FEN # FEN decoding
CFLAGS += -DDEBUG_MOVE # move generation
@@ -51,33 +63,50 @@ CFLAGS += -DDEBUG_PIECE # piece list management
#CFLAGS += -DDEBUG_EVAL3 # eval 3
#CFLAGS += -DDEBUG_MEM # malloc
.PHONY: all cflags clean
##################################### General targets
.PHONY: compile cflags all clean
compile: cflags $(OBJ) $(BIN)
compile: lib $(OBJ) $(BIN)
cflags:
@echo CFLAGS used: $(CFLAGS)
all: clean compile
$(DEPS): $(SRC) $(INC)
@echo generating dependancies.
@$(CC) -MM $(SRC) > $@
@sed -i "s|\(.*\.o\):|${OBJDIR}/\0:|" $@
include $(DEPS)
clean:
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
# @mkdir -p $(@D)
# $(CC) -c $(CFLAGS) -o $@ $<
$(OBJDIR)/%.o:
@mkdir -p $(@D)
@echo compiling $@.
@$(CC) -c $(CFLAGS) -o $@ $<
$(OBJDIR)/%.o: $(SRCDIR)/%.c
echo SRC_S=$(SRC_S)
echo O=$(OBJ)
mkdir -p $(@D)
@echo compiling A=$@ I=$<
$(CC) -c $(CFLAGS) -I $(INCDIR) -o $@ $<
##################################### binaries
#fen: CFLAGS+=-DBIN_$$@
#$(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
# @echo compiling $@.
@@ -87,7 +116,7 @@ $(OBJDIR)/%.o:
$(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
@echo compiling $@.
@echo NEED_TO_CHANGE_THIS=$^
@$(CC) -DBIN_$@ $(CFLAGS) $^ $(LIBS) -o $@
$(CC) -DBIN_$@ $(CFLAGS) -I $(INCDIR) $^ $(LDFLAGS) $(LIBS) -o $@
#pool: CFLAGS+=-DPOOLBIN
#pool: $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
@@ -109,3 +138,27 @@ $(BIN): $$(subst $(OBJDIR)/$$@.o,,$(OBJ)) $(SRCDIR)/$$@.c
#bits2: src/bits.c
# $(CC) $(CFLAGS) -S $^ -o $@.s
# $(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 $@ $<

View File

@@ -5,7 +5,7 @@
* 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>.
* 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>
*

View File

@@ -1,11 +1,11 @@
/* bodichess.c - main loop.
/* brchess.c - main loop.
*
* Copyright (C) 2021 Bruno Raoult ("br")
* Licensed under the GNU General Public License v3.0 or later.
* 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>.
* 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>
*
@@ -27,7 +27,7 @@
#include "debug.h"
#include "fen.h"
#include "eval.h"
#include "bodichess.h"
#include "brchess.h"
typedef struct {
char *name; /* User printable name */
@@ -78,7 +78,7 @@ COMMAND commands[] = {
static int done=0;
int bodichess(pos_t *pos)
int brchess(pos_t *pos)
{
char *buffer, *s;
@@ -372,10 +372,10 @@ int do_help(__attribute__((unused)) pos_t *pos,
return 0;
}
#ifdef BIN_bodichess
#ifdef BIN_brchess
/** main()
* options:
int bodichess(pos_t *pos)
int brchess(pos_t *pos)
*
*/
static int usage(char *prg)
@@ -413,6 +413,6 @@ int main(int ac, char **av)
if (optind < ac)
return usage(*av);
return bodichess(pos);
return brchess(pos);
}
#endif /* BIN_bodichess */
#endif /* BIN_brchess */

View File

@@ -5,17 +5,17 @@
* 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>.
* 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>
*
*/
#ifndef BODICHESS_H
#define BODICHESS_H
#ifndef BRCHESS_H
#define BRCHESS_H
#include "position.h"
int bodichess(pos_t *pos);
int brchess(pos_t *pos);
#endif /* BODICHESS_H */
#endif /* BRCHESS_H */