# Runs every .py in this folder. The C++ examples' Makefile compiles them;
# these need no build, so this just runs them and cleans up what they wrote.
#
# Usage:
#   make            # run all examples
#   make example1   # run a single example
#   make figures    # run all, then refresh the README gallery's images
#   make clean      # remove the generated svg/pdf/ipe files (not figures/)

PYTHON ?= python3

SOURCES := $(wildcard example*.py)
TARGETS := $(SOURCES:.py=)

.PHONY: all figures clean $(TARGETS)

all: $(TARGETS)

$(TARGETS): %: %.py
	$(PYTHON) $<

# The gallery in README.md shows these outputs, so they are kept (and tracked)
# under figures/ rather than regenerated by whoever reads the page.
figures: all
	cp *.svg *.pdf *.ipe figures/

clean:
	$(RM) *.svg *.pdf *.ipe
