#! /bin/sh
# Utility script to generate the generated sid files.
# This is useful for verifying changes to the generated files.
#
# Run this script in the src/cgen directory.
#
# Usage: gen-all-sid /path/to/sid/src

# Exit on any error.
set -e

# For debugging.
set -x

if [ ! -f sim.scm ]
then
    echo "Not in the src/cgen directory." >& 2
    exit 1
fi

if [ $# != 1 ]
then
    echo "Usage: gen-all-sid /path/to/sid/src" >& 2
    exit 1
fi

siddir=$1
if [ ! -f $siddir/sid/COPYING.SID ]
then
    echo "unable to find sid sources in $siddir" >& 2
    exit 1
fi

builddir=tmp-sid

rm -rf $builddir
mkdir $builddir

cd $builddir
$siddir/configure --prefix /tmp/junk --enable-ltdl-install
make configure-sid
cd sid/component/cgen-cpu
make cgen-all
