CODE = $(filter %.cs,$^)
LIBS = $(addprefix -reference:,$(filter %.dll,$^)) 
MKLIB = mcs -target:library -out:$@ $(LIBS) $(CODE)
MKEXE = mcs -target:exe -out:$@ $(LIBS) $(CODE)

Out.txt: main.exe
	mono $< > $@

sfuns.dll: sfuns.cs ; $(MKLIB)
main.exe: main.cs sfuns.dll ; $(MKEXE)
