# 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

N=400

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

all: out.txt speed.txt

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

speed.txt: speed.cs $(dlls) makefile
	$(compiler) speed.cs /reference:$(refs) /out:speed.exe
	\time -p --append --output=speed.txt $(runtime) \
		 speed.exe $(N) > speed.txt
	cat speed.txt

qr.dll: qr.cs vmatrix.dll
	$(compiler) qr.cs /target:library \
	/reference:vector.dll,vmatrix.dll \
	/out:qr.dll

vmatrix.dll: vmatrix.cs vector.dll
	$(compiler) vmatrix.cs \
	/target:library \
	/reference:vector.dll \
	/out:vmatrix.dll

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