a2p=jcabc2ps
RM=/bin/rm

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

neat:
	$(RM) -f *- *.old
clean: neat
	$(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) img/* src/*
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

# Slow Scottish Jam local medley creation:

# 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

# Page info
Page: Page-info
Page-info= hdr/Page-info.hdr \
	Page/Page-info.abc \
	ftr/Page-info.ftr
Page-info: Page-info.abc Page.pdf
Page-info.abc: $(Page-info)
	abcjoin +NR $(Page-info) >Page-info.abc
	ln -f Page-info.abc __/Page-info.abc
Page.ps: Page-info.abc fmt/_70.fmt
	$(a2p) Page-info.abc +Ffmt/_70.fmt \
	|PSftr %D $U/ %D >Page.ps
Page.pdf: Page.ps
	ps2pdf Page.ps Page.pdf
	ln -f Page.pdf img/Page.pdf
hdr/Page-info.hdr: ; touch hdr/Page-info.hdr
ftr/Page-info.ftr: ; touch ftr/Page-info.ftr

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Some medleys that we make locally:

# JigSet_1
JigSet_1= hdr/JigSet_1.hdr \
	jig/Baddeck_Gathering-D-32-4.abc \
	jig/Soup_Dragon_1-Bm-32-3.abc \
	jig/Andy_de_Jarlis_Jig-E-32-2.abc \
	jig/Mist_Covered_Mountain-Am-32-3.abc
JigSet_1: jig/JigSet_1.abc jig/JigSet_1.pdf
jig/JigSet_1.abc: $(JigSet_1) # hdr/JigSet_1.hdr
	abcjoin $(JigSet_1) >jig/JigSet_1.abc
jig/JigSet_1.ps: jig/JigSet_1.abc fmt/_70.fmt
	$(a2p) jig/JigSet_1.abc +Ffmt/_70 \
	|PShdr 'Jig Set 1' '' 'Jig Set 1' \
	|PSftr %D $U/ %D >jig/JigSet_1.ps
jig/JigSet_1.pdf: jig/JigSet_1.ps
	ps2pdf jig/JigSet_1.ps jig/JigSet_1.pdf
hdr/JigSet_1.hdr: ; touch hdr/JigSet_1.hdr

# All_the_Rage
All_the_Rage= \
	All_the_Rage/All_the_Rage-E-32-2.abc \
	All_the_Rage/All_the_Rage-D-32-2.abc
All_the_Rage: jig/All_the_Rage-E,D-32-2.abc jig/All_the_Rage-E,D-32-2.pdf
jig/All_the_Rage-E,D-32-2.abc: $(All_the_Rage) # hdr/All_the_Rage-E,D-32-2.hdr
	abcjoin $(All_the_Rage) >jig/All_the_Rage-E,D-32-2.abc
jig/All_the_Rage-E,D-32-2.ps: jig/All_the_Rage-E,D-32-2.abc fmt/_70.fmt
	$(a2p) jig/All_the_Rage-E,D-32-2.abc +Ffmt/_70 \
	|PShdr jig/All_the_Rage '' jig/All_the_Rage \
	|PSftr %D $U/ %D >jig/All_the_Rage-E,D-32-2.ps
jig/All_the_Rage-E,D-32-2.pdf: jig/All_the_Rage-E,D-32-2.ps
	ps2pdf jig/All_the_Rage-E,D-32-2.ps jig/All_the_Rage-E,D-32-2.pdf

# Andy_de_Jarlis
Andy_de_Jarlis= \
	Andy_de_Jarlis/Andy_de_Jarlis_jig_SS-E-32-2.abc \
	Andy_de_Jarlis/Andy_de_Jarlis_Jig_1-E-32-2.abc \
	Andy_de_Jarlis/Andy_de_Jarlis_Jig_1-D-32-2.abc \
	Andy_de_Jarlis/Andy_de_Jarlis_Jig_2-E-32-2.abc
Andy_de_Jarlis: jig/Andy_de_Jarlis-E,D-32-2.abc jig/Andy_de_Jarlis-E,D-32-2.pdf
jig/Andy_de_Jarlis-E,D-32-2.abc: $(Andy_de_Jarlis) # hdr/Andy_de_Jarlis-E,D-32-2.hdr
	abcjoin $(Andy_de_Jarlis) >jig/Andy_de_Jarlis-E,D-32-2.abc
jig/Andy_de_Jarlis-E,D-32-2.ps: jig/Andy_de_Jarlis-E,D-32-2.abc fmt/_70.fmt
	$(a2p) jig/Andy_de_Jarlis-E,D-32-2.abc +Ffmt/_70 \
	|PShdr jig/Andy_de_Jarlis '' jig/Andy_de_Jarlis \
	|PSftr %D $U/ %D >jig/Andy_de_Jarlis-E,D-32-2.ps
jig/Andy_de_Jarlis-E,D-32-2.pdf: jig/Andy_de_Jarlis-E,D-32-2.ps
	ps2pdf jig/Andy_de_Jarlis-E,D-32-2.ps jig/Andy_de_Jarlis-E,D-32-2.pdf

# Banshee
Banshee= \
	Banshee/Banshee3_SS-G-32-4.abc \
	Banshee/Banshee3_SS-G-32-2.abc
Banshee: Banshee/ march/Banshee-G-32-4,2.abc march/Banshee-G-32-4,2.pdf
march/Banshee-G-32-4,2.abc: $(Banshee)
	abcjoin $(Banshee) >march/Banshee-G-32-4,2.abc
march/Banshee-G-32-4,2.ps: march/Banshee-G-32-4,2.abc fmt/_70.fmt
	$(a2p) march/Banshee-G-32-4,2.abc +Ffmt/_70 \
	|PShdr march/Banshee '' march/Banshee \
	|PSftr %D $U/ %D >march/Banshee-G-32-4,2.ps
march/Banshee-G-32-4,2.pdf: march/Banshee-G-32-4,2.ps
	ps2pdf march/Banshee-G-32-4,2.ps march/Banshee-G-32-4,2.pdf

# Battle of the Braes
Battle_of_the_Braes= \
	Battle_of_the_Braes/Battle_of_the_Braes_2-A-32-4.abc \
	Battle_of_the_Braes/Battle_of_the_Braes_2-D-32-6.abc \
	Battle_of_the_Braes/Battle_of_the_Braes_1-A-32-4.abc
Battle_of_the_Braes: march/Battle_of_the_Braes-A,D-32-4,6.abc march/Battle_of_the_Braes-A,D-32-4,6.pdf
march/Battle_of_the_Braes-A,D-32-4,6.abc: $(Battle_of_the_Braes)
	abcjoin $(Battle_of_the_Braes) >march/Battle_of_the_Braes-A,D-32-4,6.abc
march/Battle_of_the_Braes-A,D-32-4,6.ps: march/Battle_of_the_Braes-A,D-32-4,6.abc fmt/_70.fmt
	$(a2p) march/Battle_of_the_Braes-A,D-32-4,6.abc +Ffmt/_70 \
	|PShdr march/Battle_of_the_Braes '' march/Battle_of_the_Braes \
	|PSftr %D $U/ %D >march/Battle_of_the_Braes-A,D-32-4,6.ps
march/Battle_of_the_Braes-A,D-32-4,6.pdf: march/Battle_of_the_Braes-A,D-32-4,6.ps
	ps2pdf march/Battle_of_the_Braes-A,D-32-4,6.ps march/Battle_of_the_Braes-A,D-32-4,6.pdf

# Farewells to Nigg Bm-64-16 (march + 4V versions)
Farewells_to_Nigg: Farewells_to_Nigg-Bm-64-16
Farewells_to_Nigg-Bm-64-16= hdr/Farewells_to_Nigg-Bm-64-16.hdr \
	Farewell_to_Nigg/Farewell_to_Nigg-Bm-64-4.abc \
	Farewell_to_Nigg/Farewell_to_Nigg_4V-Bm-64-4.abc \
	ftr/Farewells_to_Nigg-Bm-64-16.ftr
Farewells_to_Nigg-Bm-64-16: Farewells_to_Nigg-Bm-64-16.abc Farewells_to_Nigg.pdf
Farewells_to_Nigg-Bm-64-16.abc: $(Farewells_to_Nigg-Bm-64-16)
	abcjoin +NR $(Farewells_to_Nigg-Bm-64-16) >Farewells_to_Nigg-Bm-64-16.abc
	ln -f Farewells_to_Nigg-Bm-64-16.abc march/Farewells_to_Nigg-Bm-64-16.abc
Farewells_to_Nigg.ps: Farewells_to_Nigg-Bm-64-16.abc fmt/_70.fmt
	$(a2p) Farewells_to_Nigg-Bm-64-16.abc +Ffmt/_70.fmt \
	|PSftr %D $U/ %D >Farewells_to_Nigg.ps
Farewells_to_Nigg.pdf: Farewells_to_Nigg.ps
	ps2pdf Farewells_to_Nigg.ps Farewells_to_Nigg.pdf
	ln -f Farewells_to_Nigg.pdf img/Farewells_to_Nigg.pdf
hdr/Farewells_to_Nigg-Bm-64-16.hdr: ; touch hdr/Farewells_to_Nigg-Bm-64-16.hdr
ftr/Farewells_to_Nigg-Bm-64-16.ftr: ; touch ftr/Farewells_to_Nigg-Bm-64-16.ftr

# First Pints
First_Pints= First_Pint/First_Pint-D-32-2.abc First_Pint/First_Pint_2-D-32-2.abc First_Pint/First_Pint_TT-D-32-2.abc
First_Pints: First_Pints.abc First_Pints.ps First_Pints.pdf
First_Pints.abc: $(First_Pints) # hdr/First_Pints.hdr
	abcjoin +s $(First_Pints) >First_Pints.abc
First_Pints.ps: First_Pints.abc fmt/_70.fmt
	$(a2p) First_Pints.abc +Ffmt/_70.fmt \
	|PShdr First_Pints '' First_Pints \
	|PSftr %D $U/ %D >First_Pints.ps
First_Pints.pdf: First_Pints.ps
	ps2pdf First_Pints.ps First_Pints.pdf
