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

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

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

all: out.txt

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

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

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
