w3bin = /usr/users/wwwifa/docs/subatom/nucltheo/bin/
# Mono compiler and runtime for C-sharp:
#compiler = $(w3bin)/mcs
#runtime = $(w3bin)/mono

# Pnet compiler and runtime for C-sharp:
compiler = $(w3bin)/cscc
runtime  = $(w3bin)/ilrun

GRAPH = /usr/users/wwwifa/docs/subatom/nucltheo/bin/graph
GRAPHFLAGS = \
		--width 0.7 --height 0.6 \
		--x-label "time" --y-label "signal" \
		--top-label "noise filtering" \
		--x-limits 0 6

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 = complex.dll fft.dll
refs = $(subst $(space),$(comma),$(dlls))

all: plot.png plot.svg

plot.png: out.txt makefile
	$(GRAPH) $(GRAPHFLAGS) --display-type png < out.txt > plot.png

plot.svg: out.txt makefile
	$(GRAPH) $(GRAPHFLAGS) --display-type svg < out.txt > plot.svg

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

fft.dll: complex.dll fft.cs
	$(compiler) fft.cs /target:library /reference:complex.dll /out:fft.dll

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