plot.png : points.dat sin.dat plot.gnu makefile
	gnuplot plot.gnu

points.dat : makefile
	echo '1 1 0.3' >  points.dat
	echo '2 2 0.2' >> points.dat
	echo '3 2 0.5' >> points.dat
	echo '4 3 0.1' >> points.dat

sin.dat : makefile
	echo 'for(i=0;i<63;i++)print i/10," ",s(i/10),"\n"' | bc -l > sin.dat

plot.gnu : makefile
	echo 'set term png' >  plot.gnu
	echo 'set out "plot.png"' >>  plot.gnu
	echo 'set xlabel "x"' >>  plot.gnu
	echo 'set ylabel "y"' >>  plot.gnu
	echo 'plot [0:6][-2:4] \' >> plot.gnu
	echo '"points.dat" title "some random points" with errorbars \' >> plot.gnu
	echo ',"sin.dat" title "some random sine" with lines' >> plot.gnu

clean:
	rm -f points.dat sin.dat plot.gnu
