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

module ipbt

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

in ipbt do sed '/AC_INIT/s/6.66/$(Version)/' configure.ac > tmp.ac
in ipbt do mv tmp.ac configure.ac
in ipbt do ./mkauto.sh
in ipbt do rm -rf autom4te.cache

# use perl to avoid inconsistent behaviour of echo '\v'
in ipbt do perl -e 'print "\n\\versionid ipbt version $$ARGV[0]\n"' $(Version) >> ipbt.but

# Build the documentation. This also tests the automake setup to
# ensure configure actually works; but we use a self-delegation (i.e.
# do all of this in a throwaway copy of the build directory) to avoid
# accidentally shipping any outputs of configure. Instead we return
# only the actual man page from the delegation environment.
delegate -
  in ipbt do ./configure
  in ipbt do make doc
  return ipbt/*.1
  return ipbt/*.html
enddelegate

# Build a source archive with the right name.
in . do ln -s ipbt ipbt-$(Version)
in . do tar chzvf ipbt-$(Version).tar.gz ipbt-$(Version)

# Deliver the source archive.
deliver ipbt-$(Version).tar.gz $@

# And deliver the HTML man page.
deliver ipbt/ipbt.html $@
