# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# into various directories, and then combine them into a single file.  We  also #
# have some entries to combine all the files in a single subdirectory, but this #
# is mostly for debugging purpose, and may disappear eventually.                #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
a2p=jcabc2ps
RM=/bin/rm
U=http://trillian.mit.edu/~jc/music/abc/session/BSFC

all: Sets
#airs hornpipes slipjigs jigs mixed marches polkas songs reels shottishes waltzes

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
neat:
	$(RM) -f *- *.old
clean: neat
	$(RM) -f *.out *.log *.ps *.pdf *-
	$(RM) -f airs.p* hornpipes.p* slipjigs.p* jigs.p* mixed.p* marches.p* \
		polkas.p* songs.p* reels.p* shottishes.p* waltzes.p*
	$(RM) *.abc	# ABC files in this directory are only temporary.
clobber: clean
	$(RM) -f *.abc

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
airs: airs.abc airs.ps airs.pdf
airs.abc: air/*.abc
	abcjoin +R +S air/*.abc >airs.abc
airs.ps: airs.abc
	$(a2p) airs.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >airs.ps
airs.pdf: airs.ps
	ps2pdf airs.ps airs.pdf

hornpipes: hornpipes.abc hornpipes.ps hornpipes.pdf
hornpipes.abc: hornpipe/*.abc
	abcjoin +R +S hornpipe/*.abc >hornpipes.abc
hornpipes.ps: hornpipes.abc
	$(a2p) hornpipes.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >hornpipes.ps
hornpipes.pdf: hornpipes.ps
	ps2pdf hornpipes.ps hornpipes.pdf

jigs: jigs.abc jigs.ps jigs.pdf
jigs.abc: jig/*.abc
	abcjoin +R +S jig/*.abc >jigs.abc
jigs.ps: jigs.abc
	$(a2p) jigs.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >jigs.ps
jigs.pdf: jigs.ps
	ps2pdf jigs.ps jigs.pdf

marches: marches.abc marches.ps marches.pdf
marches.abc: march/*.abc
	abcjoin +R +S march/*.abc >marches.abc
marches.ps: marches.abc
	$(a2p) marches.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >marches.ps
marches.pdf: marches.ps
	ps2pdf marches.ps marches.pdf

mixed: mixed.abc mixed.ps mixed.pdf
mixed.abc: march/*.abc
	abcjoin +R +S mixed/*.abc >mixed.abc
mixed.ps: mixed.abc
	$(a2p) mixed.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >mixed.ps
mixed.pdf: mixed.ps
	ps2pdf mixed.ps mixed.pdf

polkas: polkas.abc polkas.ps polkas.pdf
polkas.abc: polka/*.abc
	abcjoin +R +S polka/*.abc >polkas.abc
polkas.ps: polkas.abc
	$(a2p) polkas.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >polkas.ps
polkas.pdf: polkas.ps
	ps2pdf polkas.ps polkas.pdf

reels: reels.abc reels.ps reels.pdf
reels.abc: reel/*.abc
	abcjoin +R +S reel/*.abc >reels.abc
reels.ps: reels.abc
	$(a2p) reels.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >reels.ps
reels.pdf: reels.ps
	ps2pdf reels.ps reels.pdf

shottishes: shottishes.abc shottishes.ps shottishes.pdf
shottishes.abc: shottish/*.abc
	abcjoin +R +S shottish/*.abc >shottishes.abc
shottishes.ps: shottishes.abc
	$(a2p) shottishes.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >shottishes.ps
shottishes.pdf: shottishes.ps
	ps2pdf shottishes.ps shottishes.pdf

slipjigs: slipjigs.abc slipjigs.ps slipjigs.pdf
slipjigs.abc: slipjig/*.abc
	abcjoin +R +S slipjig/*.abc >slipjigs.abc
slipjigs.ps: slipjigs.abc
	$(a2p) slipjigs.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >slipjigs.ps
slipjigs.pdf: slipjigs.ps
	ps2pdf slipjigs.ps slipjigs.pdf

songs: songs.abc songs.ps songs.pdf
songs.abc: song/*.abc
	abcjoin +R +S song/*.abc >songs.abc
songs.ps: songs.abc
	$(a2p) songs.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >songs.ps
songs.pdf: songs.ps
	ps2pdf songs.ps songs.pdf

waltzes: waltzes.abc waltzes.ps waltzes.pdf
waltzes.abc: waltz/*.abc
	abcjoin +R +S waltz/*.abc >waltzes.abc
waltzes.ps: waltzes.abc
	$(a2p) waltzes.abc +x +Ffmt/_65 \
	|PSftr "Page %P" $U/ %D >waltzes.ps
waltzes.pdf: waltzes.ps
	ps2pdf waltzes.ps waltzes.pdf

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Here is a prototype for making medley pages:

# jj
jj= _.abc
jj: jj.abc jj.ps jj.pdf
jj.abc: $(jj) # hdr/jj.hdr
	abcjoin +s $(jj) >jj.abc
jj.ps: jj.abc fmt/_70.fmt
	$(a2p) jj.abc +Ffmt/_70 \
	|PShdr jj '' jj \
	|PSftr %D $U/ %D >jj.ps
jj.pdf: jj.ps
	ps2pdf jj.ps jj.pdf

# mm
mm=
mm: mm.abc mm.ps mm.pdf
mm.abc: $(mm) # hdr/mm.hdr
	abcmedley "mm" $(mm) >mm.abc
mm.ps: mm.abc fmt/_75.fmt
	$(a2p) mm.abc +Ffmt/_75 \
	|PShdr mm '' mm \
	|PSftr %D $U/ %D >mm.ps
mm.pdf: mm.ps
	ps2pdf mm.ps mm.pdf

# TT
TT= TT/TT_K-B-S.abc	# Single-tune files
TT: RR/TT-KK-BC-SC.abc RR/TT-KK-BC-SC.pdf
RR/TT-KK-BC-SC.abc: $(TT) # hdr/TT-KK-BC-SC.hdr
	abcjoin $(TT) >RR/TT-KK-BC-SC.abc
RR/TT-KK-BC-SC.ps: RR/TT-KK-BC-SC.abc fmt/_70.fmt
	$(a2p) RR/TT-KK-BC-SC.abc +Ffmt/_70 \
	|PShdr RR/TT '' RR/TT \
	|PSftr %D $U/ %D >RR/TT-KK-BC-SC.ps
RR/TT-KK-BC-SC.pdf: RR/TT-KK-BC-SC.ps
	ps2pdf RR/TT-KK-BC-SC.ps RR/TT-KK-BC-SC.pdf

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Medleys that we make locally:

# _name set
_name_Set= \
	__
_name_Set: _name_Set.abc _name_Set.ps _name_Set.pdf
_name_Set.abc: hdr/_name_Set.hdr $(_name_Set)
	abcjoin $(_name_Set) >_name_Set.abc
_name_Set.ps: _name_Set.abc fmt/Set.fmt
	$(a2p) _name_Set.abc +Ffmt/Set.fmt \
	|PShdr '_name_Set' '' '_name_Set' \
	|PSftr %D $U/ %D >_name_Set.ps
_name_Set.pdf: _name_Set.ps
	ps2pdf _name_Set.ps _name_Set.pdf

Sets: Jamie_Scotland_Set Skye_Boat_Song

# Jamie_Scotland set
Jamie_Scotland_Set= hdr/Jamie_Scotland_Set.hdr \
	march/Jamie_Allen-G-32-2.abc \
	march/Scotland_the_Brave_Song-G-32-4w8.abc \
	ftr/Jamie_Scotland_Set.ftr
Jamie_Scotland_Set: Jamie_Scotland_Set.abc Jamie_Scotland_Set.ps Jamie_Scotland_Set.pdf
Jamie_Scotland_Set.abc: hdr/Jamie_Scotland_Set.hdr $(Jamie_Scotland_Set)
	abcjoin $(Jamie_Scotland_Set) >Jamie_Scotland_Set.abc
	ln -f Jamie_Scotland_Set.abc img/Jamie_Scotland_Set.pdf
Jamie_Scotland_Set.ps: Jamie_Scotland_Set.abc fmt/_75.fmt
	$(a2p) Jamie_Scotland_Set.abc +Ffmt/_75.fmt \
	|PShdr 'Jamie_Scotland_Set' '' 'Jamie_Scotland_Set' \
	|PSftr %D $U/ %D >Jamie_Scotland_Set.ps
Jamie_Scotland_Set.pdf: Jamie_Scotland_Set.ps
	ps2pdf Jamie_Scotland_Set.ps Jamie_Scotland_Set.pdf
	ln -f Jamie_Scotland_Set.pdf strathspey/Jamie_Scotland_Set.pdf
hdr/Jamie_Scotland_Set.hdr: ; touch hdr/Jamie_Scotland_Set.hdr 
ftr/Jamie_Scotland_Set.ftr: ; touch ftr/Jamie_Scotland_Set.ftr

# Skye Boat Song set
Skye_Boat_Song_Set= \
	Skye_Boat_Song/Skye_Boat_Song-A-32-2w10.abc \
	Skye_Boat_Song/Skye_Boat_Song-G-16-2.abc \
	Skye_Boat_Song/Skye_Boat_Song-C-16-2.abc \
	Skye_Boat_Song/Skye_Boat_Song-D-16-2.abc
Skye_Boat_Song_Set: Skye_Boat_Song_Set.abc Skye_Boat_Song_Set.ps Skye_Boat_Song_Set.pdf
Skye_Boat_Song_Set.abc: hdr/Skye_Boat_Song_Set.hdr $(Skye_Boat_Song_Set)
	abcjoin $(Skye_Boat_Song_Set) >Skye_Boat_Song_Set.abc
Skye_Boat_Song_Set.ps: Skye_Boat_Song_Set.abc fmt/Set.fmt
	$(a2p) Skye_Boat_Song_Set.abc +Ffmt/Set.fmt \
	|PShdr 'Skye_Boat_Song_Set' '' 'Skye_Boat_Song_Set' \
	|PSftr %D $U/ %D >Skye_Boat_Song_Set.ps
Skye_Boat_Song_Set.pdf: Skye_Boat_Song_Set.ps
	ps2pdf Skye_Boat_Song_Set.ps Skye_Boat_Song_Set.pdf
