Files
chess/makefile
Josh d462f82c8e
All checks were successful
Python tests (make) / test (push) Successful in 10s
Fix makefile
2025-08-15 12:59:00 -04:00

38 lines
852 B
Makefile

CC := gcc
CFLAGS := -O3 -fPIC -Wall -Wextra
LDFLAGS := -shared
SRCDIR := engine/src
INCDIR := engine/include
BUILDDIR := build
LIBNAME := libchess
SRC := $(wildcard $(SRCDIR)/*.c)
OBJ := $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC))
LIB := $(BUILDDIR)/$(LIBNAME).so
.PHONY: all clean clean-pycache test
all: $(LIB)
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
# compile each .c into build/*.o
$(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
$(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
# link shared library
$(LIB): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^
clean:
@echo "Cleaning Python caches..."
@find . -type d -name "__pycache__" -exec rm -rf {} +
@find . -type d -name ".pytest_cache" -exec rm -rf {} +
@find . -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete
# run Python unit tests
test: all
python3 -m unittest -v && $(MAKE) clean