# /usr/share/doc/sagetex/examples/Makefile
#
# Ad hoc Makefile for building and playing with the sample sources
# distributed within the debian package sagetex-doc.
#
# Recommended usage:
#  create a dedicated folder somewhere in your HOME directory;
#  link all the files in /usr/share/doc/sagetex/examples in the dedicated folder;
#  launch this Makefile in the dedicated folder:
#  $ make ;
#  for a basic cleanup, consider the clean target:
#  $ make clean ;
#  for an entire cleanup, the maintainer-clean target:
#  $ make maintainer-clean ;
#  for other targets, just read the Makefile.
#
# written for Debian by Jerome Benoit <calculus@rezozer.net>
# on behalf of the Debian Science Team
# copyright: 2016-2019 Jerome Benoit <calculus@rezozer.net>
# distributed under the terms and conditions of GPL version 3 or later
#

DOCUMENTS = $(patsubst %.tex,%.pdf,$(filter-out sage-plots-for-%.tex,$(wildcard *.tex)))
DOCTESTS = $(patsubst %.pdf,%_doctest.sage,$(DOCUMENTS))

TEXOPTS = -interaction batchmode

default: all

all: compose

compose: $(DOCUMENTS)

check: compose
	$(foreach dctst,$(DOCTESTS), $(SAGE) -t $(dctst) ;)

auxclean:
	$(RM) *.aux *.out *.log

sauxclean:
	$(RM) *.sagetex.s* *.sobj *-tikz*.table
	$(RM) -r sage-plots-for-*.tex

clean: auxclean sauxclean
	$(RM) $(DOCTESTS)
	$(RM) $(DOCUMENTS)

maintainer-clean: clean

%.pdf : %.tex
	$(PDFLATEX) $(TEXOPTS) $<
	$(SAGE) $*.sagetex.sage
	$(PDFLATEX) $(TEXOPTS) $<
	$(PDFLATEX) $(TEXOPTS) $<

PDFLATEX ?= pdflatex
SAGE ?= sage
