# -*- sh -*-
# Build script for Gonville.

module gonville

set Version $(!builddate).$(vcsid)

# Construct the source archive, before we create any new files.
in . do mkdir gonville-$(Version)
in gonville-$(Version) do cp -r ../gonville/* .
in . do tar czvf gonville-$(Version)-src.tar.gz gonville-$(Version)

# For a faster development cycle, an option to omit building the large
# and slow brace subfont.
set Lilybuildopt --lily
ifeq "$(FASTBRACE)" "yes" set Lilybuildopt --lily --fastbrace

# Build the font.
in gonville/svgfilter do make
in gonville do ./glyphs.py --ver=$(Version) --svgfilter=./svgfilter/svgfilter $(Lilybuildopt) -j$(nproc)

# Make the 'new' distribution archives, for Lilypond >= 2.20
in . do rm -rf gonville-$(Version)
in . do mkdir gonville-$(Version)
in gonville do cp LICENCE lilyfonts/* ../gonville-$(Version)
in gonville do cp README.post-2.20 ../gonville-$(Version)/README
in . do tar czvf gonville-$(Version).tar.gz gonville-$(Version)
in . do zip -r gonville-$(Version).zip gonville-$(Version)

# Make the 'old' distribution archive, for Lilypond < 2.20.
in . do rm -rf gonville-$(Version)-old
in . do mkdir gonville-$(Version)-old
in gonville do cp LICENCE ../gonville-$(Version)-old
in gonville do cp README.pre-2.20 ../gonville-$(Version)-old/README
in gonville do cp -rT lilyfonts-old ../gonville-$(Version)-old/fontdir
in . do tar czvf gonville-$(Version)-old.tar.gz gonville-$(Version)-old
in . do zip -r gonville-$(Version)-old.zip gonville-$(Version)-old

# Make the SMuFL-compliant font files, and zip them together into a
# single download.
in gonville do ./glyphs.py --smufl
in gonville do zip gonville-smufl.zip gonville-smufl.otf gonville-smufl.woff

# Build the demo images.
in gonville do ./demo.sh before
in gonville do ./demo.sh after -I lilyfonts -d include-settings=gonville.ily

deliver gonville-$(Version)-src.tar.gz $@
deliver gonville-$(Version).tar.gz $@
deliver gonville-$(Version).zip $@
deliver gonville-$(Version)-old.tar.gz $@
deliver gonville-$(Version)-old.zip $@
deliver gonville/before.png $@
deliver gonville/after.png $@
deliver gonville/before.svg $@
deliver gonville/after.svg $@
deliver gonville/gonville-smufl.otf $@
deliver gonville/gonville-smufl.woff $@
deliver gonville/gonville-smufl.zip $@
