all: Out.txt
Out.txt:main.exe
	mono $< >$@ 2>log

main.exe:main.cs stochastic.dll matlib.dll
	mcs $< -r:$(call clist,$(filter %.dll,$^))

LIBDIR=..
LIBSRC=\
	$(LIBDIR)/matrix/vector.cs\
	$(LIBDIR)/matrix/matrix.cs\
	$(LIBDIR)/minim/qnewton.cs
matlib.dll:$(LIBSRC)
	mcs $^ -target:library -out:$@

stochastic.dll: swarm.cs prernd.cs halton.cs rndstart.cs bbpso.cs \
			apso.cs matlib.dll
	mcs -target:library -out:$@ \
	$(addprefix -r:,$(filter %.dll,$^)) $(filter %.cs,$^)

clean:
	$(RM) *.exe *.dll [Oo]ut* [Ll]og*

comma:=,
empty:=
space:=$(empty) $(empty)
clist = $(subst $(space),$(comma),$(1))
