all:	$(ABCPARTS) head.abc Makefile
	make score.abc
	make allparts.abc
	make allparts.ps
	make -i score.mid
	make allparts.pdf
	make allparts.zip

score.abc:	$(ABCPARTS) head.abc
	makescore >score.abc

#allparts.lytex: $(LILYPARTS) head.abc
#	writetex.sh >allparts.lytex

allparts.zip:	allparts.lytex 
	zip allparts.zip allparts.lytex $(LILYPARTS)

allparts.abc: $(ABCPARTS) head.abc
	make -f /home/lconrad/music/make.in allparts.abc

allparts.ps:	allparts.lytex *.ly
	lilypond-book --outdir=out allparts.lytex
	cd out;latex allparts.latex;dvips -o ../allparts.ps allparts.dvi

cantus.eps altus.eps tenor.eps bassus.eps:	$(ABCPARTS) /home/lconrad/music/morley/2v/can2v.fmt
	make
	makeallparts4tex.sh allparts.abc >allparts4tex.abc
#	abctab2ps allparts4tex.abc  -n -N -o  -E -F /home/lconrad/music/morley/2v/can2v.fmt
	abctab2ps allparts4tex.abc   -n -N -o  -E -F /home/lconrad/music/morley/2v/can2v.fmt $(TEXFLAGS)
	mvepsfiles.sh
	rm -f allparts.ps

cantus-lute.ps:	cantus-lute.abc
	abctab2ps -O =  cantus-lute.abc -c -a 1.0 -N

index: *.abc
	abc2mtex -i *.abc
	sort_in

ps: $(ABC:=.ps)

tidy:
	$(RM) -f *.o index abc2mtex.log music.tex userguide.toc transpose.abc
	$(RM) -f $(TEX:=.dvi) $(TEX:=.log) $(TEX:=.ps) $(TEX:=.aux)
	$(RM) -f $(ABC:=.tex) $(ABC:=.dvi) $(ABC:=.log) $(ABC:=.ps) $(ABC:=.aux)

clean: tidy
	$(RM) -f abc2mtex sort_in search

allparts.book.ps:	allparts.ps
	psnup -2 -l -w17in -h11in -Pletter -s1 allparts.ps  | addpsctrl  -c usledger -f - >allparts.book.ps

.SUFFIXES:  .ps .abc .mid .dvi .pdf .tex  .dvi .ps .htm .ly .latex .lytex

.abc.ps:	
	abctab2ps $*.abc -c -n -N -O = -o $(ABC2PSFLAGS)


.abc.mid:
	rm -f /tmp/no8va*.*
	cat $*.abc | sed 's;treble8;;' >/tmp/no8va.abc
	abc2midi /tmp/no8va.abc
	mv /tmp/no8va*.mid $*.mid

.ps.pdf:	
	ps2pdf $*.ps $*.pdf


.ly.mid:
	make $*.dvi
	cp $*.midi $*.mid

.ly.dvi:
	ly2dvi $*.ly

.lytex.latex:
	lilypond-book $*.tex

.latex.dvi:
	latex $*.latex

#.dvi.ps:
#	dvips -o $*.ps $*.dvi -D 600
	
.htm.tex:
	tth <$*.tex >$*.htm

%-book.ps:	%.ps
	psbook $*.ps >psbook.out
	cat psbook.out | psnup -2 -ptabloid -Pletter -l >$*-book.ps
