#!/bin/sh
rm -rf gc
gunzip -c gc5.0alpha4.tar.gz | tar xf -
rm -f gc/Makefile.new
sed -f gc-Makefile.sed gc/Makefile >gc/Makefile.new
mv -f gc/Makefile.new gc/Makefile
rm -f gc/os_dep.new
sed -f gc-os_dep.sed gc/os_dep.c >gc/os_dep.new
mv -f gc/os_dep.new gc/os_dep.c
case `uname -s`/`uname -r` in
  IRIX*/*)   RANLIB=touch;;
  SunOS/5.*) RANLIB=touch;;
  *)         RANLIB=ranlib;;
  esac
cd gc
make test
cd ..
cp -f gc/gc.h include/gc.h
cp -f gc/gc.a include/libgc.a
$RANLIB include/libgc.a
rm -rf gc
cd include
rm -f libstalin.a
# egcs can be used when it is available
#egcs -c -O2 -fomit-frame-pointer -freg-struct-return xlib-c.c
gcc -c -O2 -fomit-frame-pointer -freg-struct-return xlib-c.c
ar rc libstalin.a xlib-c.o
$RANLIB libstalin.a
rm xlib-c.o
cd ..
case `uname -m`/`uname -s` in
  i[3456]86/*)
    cp -f stalin-ia32.c stalin.c;;
  sun4*/*)
    cp -f stalin-sparc.c stalin.c;;
  IP*/IRIX*)
    cp -f stalin-mips.c stalin.c;;
  alpha/*)
    cp -f stalin-alpha.c stalin.c;;
  *)
    echo "Cannot (yet) run Stalin on this architecture"
    exit 1;;
  esac
exec make
