CFLAGS += -Wall -O1 -std=gnu11
CFLAGS += $(shell gsl-config --cflags)
LDLIBS += $(shell gsl-config --libs)

all:Out.sin.png Out.H.png

Out.sin.png:out.sin.data Makefile
	echo '\
set term png ;\
set title "u´´=-u, u(0)=0, u´(0)=1" ;\
set out "$@" ;\
set key out ;\
set grid ;\
set xlabel "x/π" ;\
set ylabel "y" ;\
plot [][] \
 "$<" u ($$1/pi):2 w lp pt 4 ps 0.5 title "u"\
,"$<" u ($$1/pi):3 w lp pt 5 ps 0.5 title "u´"\
	'| gnuplot

out.sin.data:main
	./main 1 2>$@

Out.H.png:out.H.data Makefile
	echo '\
set term png ;\
set title "-(1/2)u´´-(1/r)u=-(1/2)u" ;\
set out "$@" ;\
set key out ;\
set grid ;\
set xlabel "r" ;\
set ylabel "u(r)" ;\
plot [][] \
 "$<" u 1:2 w lp pt 4 ps 0.5 title "u"\
	'| gnuplot

out.H.data:main
	./main 2 2>$@

main:main.o ode.o
main.o ode.o:ode.h

clean:
	$(RM) *.o main [Oo]ut*
