# Mono compiler and runtime for C-sharp:
#compiler = /usr/users/wwwifa/docs/subatom/nucltheo/bin/mcs
#runtime = /usr/users/wwwifa/docs/subatom/nucltheo/bin/mono
# Pnet compiler and runtime for C-sharp:
#compiler = /usr/users/wwwifa/docs/subatom/nucltheo/bin/cscc
#runtime = /usr/users/wwwifa/docs/subatom/nucltheo/bin/ilrun
compiler = cscc
runtime = ilrun

# graph from plotutils package
GRAPH = /usr/users/wwwifa/docs/subatom/nucltheo/bin/graph

comma:=,
empty:=
space:=$(empty) $(empty)

# a default rule to compile .cs file into a .dll file:
%.dll: %.cs
	$(compiler) $*.cs /target:library /out:$*.dll

dlls = ode.dll
refs = $(subst $(space),$(comma),$(dlls))

GraphFlags = \
		--symbol 1 \
		--x-label "x" \
		--y-label "y" \
		--top-label "u'=v, v'=-u, u(0)=0, v(0)=1" \

all: graph.svg graph.png graph.gif

graph.svg: points.dat makefile
	$(GRAPH) $(GraphFlags)\
		--display-type svg \
		points.dat > graph.svg

graph.png: points.dat makefile
	$(GRAPH) $(GraphFlags)\
		--display-type png \
		points.dat > graph.png

graph.gif: points.dat makefile
	$(GRAPH) $(GraphFlags)\
		--display-type gif \
		points.dat > graph.gif

points.dat: main.exe
	$(runtime) main.exe > points.dat

main.exe: main.cs $(dlls)
	$(compiler) main.cs /reference:$(refs) /out:main.exe

clean:
	rm -f $(dlls) *.exe core* out
