DLLS = $(addprefix -reference:,$(filter %.dll,$^))
CODE = $(filter %.cs,$^)
MKEXE = mcs -target:exe -out:$@ $(DLLS) $(CODE)
MKLIB = mcs -target:library -out:$@ $(DLLS) $(CODE)

Qspline.svg: out.data Makefile
	echo '\
	set term svg background "white"; \
	set out "$@" ;\
	set key out ;\
	set xlabel "x" ;\
	set ylabel "x" ;\
	set grid ;\
	set title "Quadratic spline example" ;\
	plot \
	 "$<" index 0 using 1:2 title "data" \
	,"$<" index 0 using 1:3 title "deriv" \
	,"$<" index 0 using 1:4 title "integ" \
	,"$<" index 1 using 1:2 with lines title "eval" \
	,"$<" index 1 using 1:3 with lines title "deriv" \
	,"$<" index 1 using 1:4 with lines title "integ" \
	'|tee log.gpi|gnuplot
out.data: main.exe ; mono $< > $@
main.exe: main.cs qspline.dll ; $(MKEXE)
qspline.dll: qspline.cs ; $(MKLIB)
