SDKDIR=$(HOME)/.dotnet/sdk/6.0.102# or whatever your sdk is
CSCPATH=$(SDKDIR)/Roslyn/bincore/csc.dll
NETSTANDARD=$(SDKDIR)/ref/netstandard.dll
CONFIG=$(SDKDIR)/vstest.console.runtimeconfig.json
DOTNET=DOTNET_CLI_TELEMETRY_OPTOUT=1; dotnet
CSC=$(DOTNET) $(CSCPATH) -reference:$(NETSTANDARD)
RUN=$(DOTNET) exec --runtimeconfig $(CONFIG)
# export DOTNET_CLI_TELEMETRY_OPTOUT=1
CSC = mcs
RUN = mono

Out.png: oscillator.data.txt Makefile
	echo '\
set term png ;\
set out "$@" ;\
set tics out ;\
set xlabel "{/:Italic t}" ;\
set key bottom ;\
set grid ;\
set ytics 2 ;\
set title "oscillator example from scipy.integrate.odeint" ;\
plot \
 "oscillator.data.txt" using 1:2 with lines title "{/:Italic θ(t)}"\
,"oscillator.data.txt" using 1:3 with lines title "{/:Italic ω(t)}"\
	'| tee log.gpi |gnuplot

oscillator.data.txt: main.exe
	$(RUN) $< 1> $@ 2>log

main.exe: main.cs matlib.dll
	$(CSC) -t:exe $(addprefix -r:,$(filter %.dll,$^)) $(filter %.cs,$^)

matlib.dll: genlist.cs ode.cs ../../matlib/matrix/vector.cs
	$(CSC) -target:library -out:./$@ $^
	
clean:
	$(RM) *.dll *.exe *.png *.txt log*
