# Makefile for repsim (pybind11 + scikit-build-core)
# Usage:
#   make develop   # editable install
#   make install   # regular install
#   make uninstall # uninstall package
#   make build     # wheel+sdist to dist/
#   make clean     # remove build artifacts
#   make rebuild   # clean + develop
#   make help      # show this help

# --- Config ---
PYTHON ?= python
PIP    ?= $(PYTHON) -m pip
PKG    ?= repsim

# --- Helpers ---
define PRINT_HELP
@echo "Targets:"
@echo "  develop     Editable install (pip install -e .)"
@echo "  install     Regular install (pip install .)"
@echo "  uninstall   Uninstall package ($(PKG))"
@echo "  build       Build wheel and sdist into dist/"
@echo "  clean       Remove build artifacts and caches"
@echo "  rebuild     clean + develop"
@echo "  help        Show this help"
endef

.PHONY: develop install uninstall build clean rebuild test help

help:
	$(PRINT_HELP)

develop:
	$(PIP) install -e .

install:
	$(PIP) install .

uninstall:
	-$(PIP) uninstall -y $(PKG)

build:
	$(PYTHON) -m build --wheel --outdir dist
	$(PYTHON) -m build --sdist --outdir dist

clean:
	@echo "Cleaning build artifacts..."
	@rm -rf \
	  build/ \
	  _skbuild/ \
	  dist/ \
	  *.egg-info \
	  .eggs \
	  .pytest_cache \
	  .mypy_cache \
	  .ruff_cache \
	  .nox \
	  .tox \
	  **/__pycache__
	@# Remove compiled extensions if present
	@find python/$(PKG) -maxdepth 1 -name "_$(PKG).*so" -delete 2>/dev/null || true
	@find python/$(PKG) -maxdepth 1 -name "_$(PKG).*pyd" -delete 2>/dev/null || true

rebuild: clean develop
