#!/bin/sh
# configure script for Gauss package,
# usage: ./configure gappath
# this script creates a `Makefile' from `Makefile.in'
if [ x"$1" = "x" ]; then
    GAPPATH=../..; echo "Using ../.. as default GAP path"
else
    GAPPATH="$1"
fi
rm -f makefile Makefile
. "$GAPPATH"/sysinfo.gap
case "$GAParch" in
  i?86*)
    EXTRA_COPTS=-m32
    ;;
  x86_64*)
    EXTRA_COPTS=-m64
    ;;
esac
echo "GAPPATH=$GAPPATH" > Makefile
sed "s/@GAPARCH@/$GAParch/g;s/@EXTRACOPTS@/$EXTRA_COPTS/g;" Makefile.in >> Makefile
case "$GAParch" in
  *linux*)
    sed "s/@GAPARCH@/$GAParch/g;s/@EXTRACOPTS@/$EXTRA_COPTS/g;" Makefile.linux.in >> Makefile
    ;;
  *apple-darwin*)
    sed "s/@GAPARCH@/$GAParch/g;s/@EXTRACOPTS@/$EXTRA_COPTS/g;" Makefile.darwin.in >> Makefile
    ;;
  *)
    echo "Unsupported architecture. If you manage to compile Gauss on this"
    echo "architecture, please send a patch to Gauss@momo.math.rwth-aachen.de."
    rm -f Makefile
    exit 1
esac
