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

SIMPLESOLV=simplesolv

all: $(addsuffix .pdf, $(PROJECT))

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

define bigeq_run
	julia $(SIMPLESOLV)/main.jl -p "eq=bigeq;N=12;P=8;J=10;maxiter=100;v_a=16;minlrho_init=-6;nlrho_init=100;rho=2e-2;xmax=10" -M anyeq 2pt > 2pt.dat
endef

2pt.dat:
	$(call bigeq_run)

DATS=2pt.dat

2pt.pdf: 2pt.dat
	$(call gnuplot2pdf,$(basename $@))


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

clean-dat:
	rm -f $(DATS)

clean-pdf:
	rm -f $(addsuffix .pdf, $(PROJECT))

clean: clean-aux clean-pdf
