#!/bin/sh -e

## build an sbcl manual.

## call with: sbcl-build-manual DIR UPLOADER_NAME SBCL_BINARY SBCL_CORE
# expects SSH_SSH_AUTH_SOCK and SSH_AGENT_PID to be set to reasonable
# values, so auto-uploading works.

DIR=$1; shift
UPLOADER_NAME=$1; shift
SBCL_BINARY=$1; shift
SBCL_CORE=$1;

# ssh agent hack

[ -f ~/.ssh-agent ] && . ~/.ssh-agent


# first, find a usable GNU make. fortunately, sbcl provides a function
# for that.
. "$DIR"/find-gnumake.sh
find_gnumake

SBCL_HOME="$DIR"/contrib; export SBCL_HOME

cd "$DIR"/doc/manual
"$GNUMAKE" clean || exit 1
"$GNUMAKE" SBCL_SYSTEM="$SBCL_BINARY --core $SBCL_CORE" || exit 1
rm -rf manual || true
cp -Rp sbcl manual

# make a tarball and unpack it in SBCL's web space

tar zcf sbcl-manual.tgz manual
sleep 200
cat sbcl-manual.tgz | ssh $UPLOADER_NAME@shell.sf.net cd /home/groups/s/sb/sbcl/htdocs ";" tar zxf -

# arch-tag: "100855f9-ff31-11d8-8b1b-000c76244c24"
