# Common Makefile variables and targets

PYTHON = python3
PIP = $(PYTHON) -m pip
TWINE = $(PYTHON) -m twine

SOURCE_DIR = src
PYNAUTY_VERSION = $(shell $(PYTHON) -m $(SOURCE_DIR).pynauty pynauty-version)
NAUTY_VERSION = $(shell $(PYTHON) -m $(SOURCE_DIR).pynauty nauty-version)
NAUTY_DIR = $(shell $(PYTHON) -m $(SOURCE_DIR).pynauty nauty-dir)

python_version_full := $(wordlist 2,4,$(subst ., ,$(shell $(PYTHON) --version 2>&1)))
platform := "$(shell uname -a)"
LIBPATH = $(shell echo build/lib.*)

MODULE_TEST = $(PWD)/src/module-test.py

VENV_DIR = .venv-pynauty

export

help:
	@echo
	@echo 'Available targets for building, testing and (un)installing pynauty:'
	@echo
	@echo '  pynauty        - build the pynauty extension module'
ifdef VIRTUAL_ENV
	@echo '  tests          - run all tests loading from virtaulenv' $(VIRTUAL_ENV)
else
	@echo '  tests          - run all tests loading either from build/ or from an active virtualenv'
endif
ifdef VIRTUAL_ENV
	@echo '  install        - install pynauty into virtualenv' $(VIRTUAL_ENV)
else
	@echo '  install        - install pynauty either into ~/.local or into an active virtualenv'
endif
ifdef VIRTUAL_ENV
	@echo '  uninstall      - uninstall pynauty from virtualenv' $(VIRTUAL_ENV)
else
	@echo '  uninstall      - uninstall pynauty either from ~/.local or from an active virtualenv'
endif
	@echo '  docs           - build pyanauty documentation'
	@echo '  clean          - remove all files created by build/packaging except' $(VENV_DIR)/
	@echo '  clean-docs     - remove pyanauty documentation'
	@echo '  virtenv-create - create virtualenv' $(VENV_DIR)/
	@echo '  virtenv-delete - delete virtualenv' $(VENV_DIR)/
	@echo '  nauty-objects  - compile only nauty.o nautil.o naugraph.o schreier.o naurng.o'
	@echo '  clean-nauty    - a "distclean" for nauty'
	@echo '  clobber        - clean + clean-nauty + clean-docs + virtenv-delete'
	@echo
	@echo 'Pynauty version:' ${PYNAUTY_VERSION}
	@echo 'Nauty version:  ' ${NAUTY_VERSION}
	@echo 'Python version: ' ${python_version_full}
	@echo 'Pip used:       ' ${PIP}
	@echo 'Platform:       ' ${platform}

# vim: filetype=make syntax=make
