# -*- sh -*-
#
# bob script for spigot.

module spigot

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

# Make up a version number and substitute it in to the configure
# script and version.h.
in spigot do sed -i '/AC_INIT/s/NOVERSION/$(Version)/' configure.ac
in spigot do echo '/* Generated by automated build script */' > version.h
in spigot do echo '$#define VER "version $(Version)"' >> version.h

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

# Build the configure script.
in spigot do ./autogen.sh

# Run 'make test' with both bigint implementations. A side effect of
# this is that Makefile gets produced, so that the following 'make
# dist' will work.
in spigot do ./configure --without-gmp && make test
in spigot do ./configure --with-gmp && make test

# Build the tarball and HTML docs.
in spigot do make dist
in spigot do make spigot.html

# Build on Windows.
delegate windows
    in spigot with visualstudio do/win cl /O2 /DNDEBUG /EHsc /Fespigot.exe *.cpp
    # Code-sign this Windows binary, if the local bob config provides
    # a script to do so. We assume here that the script accepts an -i
    # option to provide a 'more info' URL, and that it signs the file
    # in place.
    ifneq "$(winsigncode)" "" in spigot do $(winsigncode) -i http://www.chiark.greenend.org.uk/~sgtatham/winurl/ spigot.exe
    return spigot/spigot.exe
enddelegate

# Deliver output.
deliver spigot/spigot-*.tar.gz $@
deliver spigot/spigot.html $@
deliver spigot/spigot.exe $@
