PROJECT=$(basename $(wildcard *.gnuplot))

PDFS=$(addsuffix .pdf, $(PROJECT))

all: $(PDFS)

define gnuplot2pdf
        gnuplot $(1).gnuplot > $(1).tikz.tex
        pdflatex -jobname $(1) -file-line-error $(1).tikz.tex
endef

$(PDFS): box.dat
	$(call gnuplot2pdf,$(basename $@))

box.dat:
	julia box.jl > $@

clean-aux:
	rm -f $(addsuffix .tikz.tex, $(PROJECT))
	rm -f $(addsuffix .log, $(PROJECT))
	rm -f $(addsuffix .aux, $(PROJECT))

clean-pdf:
	rm -f $(PDFS)

clean-dat:
	rm -f box.dat

clean: clean-aux clean-pdf
