SHELL = /bin/sh

RUBY = ruby
SMFLIB = ../lib

.SUFFIXES: .mml .mid .mld .stt .txt .wav .xml .spkr

.mml.mid:
	$(RUBY) -I $(SMFLIB) mml.rb $<
 
.mid.mld:
	$(RUBY) -I $(SMFLIB) smf2mld.rb $<

.stt.mid:
	$(RUBY) -I $(SMFLIB) stt.rb $<
 
.mid.txt:
	$(RUBY) -I $(SMFLIB) smf2text.rb $<
 
.mid.wav:
	$(RUBY) -I $(SMFLIB) smf2wav.rb $<

.mid.xml:
	$(RUBY) -I $(SMFLIB) smf2xml.rb $<

.mid.spkr:
	test x`uname` = xFreeBSD && $(RUBY) -I $(SMFLIB) play-spkr.rb $<
 
default:
	if $(RUBY) -r gsl -e exit; then \
	  $(MAKE) w_gsl; \
	else \
	  $(MAKE) wo_gsl; \
	fi

w_gsl: mml stt text xml groove shuffle mml-samp stt-samp morse-samp
wo_gsl: mml stt text xml mml-samp stt-samp morse-samp

mml: bwv772.mid bwv775.mid bwv787.mid
stt: ltvddpd2.mid
text: bwv772.txt
xml: bwv772.xml

groove: bwv772.mid
	$(RUBY) -I $(SMFLIB) groove.rb groove.grv bwv772.mid

shuffle: bwv772.mid
	$(RUBY) -I $(SMFLIB) shuffle.rb bwv772.mid

mml-samp:
	$(RUBY) -I $(SMFLIB) mml-samp.rb

stt-samp:
	$(RUBY) -I $(SMFLIB) stt-samp.rb

morse-samp:
	$(RUBY) -I $(SMFLIB) morse-samp.rb

