############
# Makefile #
############
PLOTTERART=plotterart
PLOTTERARTINS=$(PLOTTERART).ins
PLOTTERARTDTX=$(PLOTTERART).dtx
TEST=test

BPDIR=bp


############
# ALL      #
############
all: install doc test allbp

allbp: install
	cd $(BPDIR) \
	&& make

############
# INSTALL  #
############
install:
	latex $(PLOTTERARTINS)

############
# DOC      #
############
doc: docps docpdf

docpdf:
	pdfcslatex $(PLOTTERARTDTX)

docps: docdvi
	dvips $(PLOTTERART).dvi -o $(PLOTTERART).ps

docdvi:
	cslatex $(PLOTTERARTDTX)

############
# TEST     #
############
test: testps testpdf

testpdf:
	pdfcslatex $(TEST).ltx && \
	mpost $(TEST).mp && \
	pdfcslatex $(TEST).ltx

testps: testdvi
	dvips $(TEST).dvi -o $(TEST).ps

testdvi:
	cslatex $(TEST).ltx && \
	mpost $(TEST).mp && \
	cslatex $(TEST).ltx
############
# BP       #
############
bp:
	cd $(BPDIR) \
	&& make

############
# DEVEL    #
############
devel: install testps

############
# CLEAN    #
############
clean: deldoc delmakro deltest delother delbp

deldoc:
	rm -f \
	plotterart.pdf plotterart.dvi plotterart.ps

deltest:
	rm -f \
	test.pdf test.dvi test.ps

delmakro:
	rm -f \
	plotterart.tex plotterart.sty

delother:
	rm -f \
	*.aux \
	*.log \
	*.out \
	*.mp \
	*.[0-9] \
	*.ps \
	*.pdf \
	*.dvi

delbp:
	cd $(BPDIR) && \
	rm -f $(PLOTTERARTBP).dvi \
	$(PLOTTERARTBP).ps \
	$(PLOTTERARTBP).pdf \
	$(PLOTTERARTBP).toc \
	*.mp \
	*.log \
	*.aux \
	*.out
