CFLAGS = -Wall -Werror -O1
CFLAGS += $(shell gsl-config --cflags)
LDLIBS += $(shell gsl-config --libs)
CC = gcc

.PHONEY:default
default:Out.bessel.png

Out.bessel.png: Out.bessel.txt Makefile
	echo ' \
set terminal png ;\
set output "$@" ;\
set xlabel "$$x$$" ;\
set ylabel "$$y$$" ;\
set title "Bessel functions via integral representation" ;\
plot [][:1.5]\
 "$<" using 1:2 with lines title "$$J_0$$" \
,"$<" using 1:3 with lines title "$$J_1$$" \
,"$<" using 1:4 with lines title "$$J_2$$" \
,"$<" using 1:5 with lines title "$$J_3$$" \
,"$<" using 1:(besselJ(0,$$1)) every 3 with points pointtype 3 title "Pyxplot`s besselJ(0,x)" \
'|pyxplot

Out.bessel.txt:main
	LD_LIBRARY_PATH=/usr/local/lib ./$< > $@

main:main.o bessel.o

.PHONEY:clean
clean:
	$(RM) Out* *.o
	find . -type f -executable -delete


.PHONEY:test
test:
	echo CFLAGS
	echo $(CFLAGS)
	echo $(LDLIBS)
