# Project:           Scheme-PG
# Author:            David J. Neu, djneu@acm.org
# Maintainer:        David J. Neu, djneu@acm.org
# Project Home Page: http://scheme-pg.sourceforge.net
# Copyright:         Copyright (c) 2004 Universal Technical Resource Services, Inc.
# License:           MIT License, see license.txt
# CVS Id:            $Id: install.sh,v 1.6 2005/03/21 20:24:18 djneu Exp $

# NOTE: Adjust, in vars.sh:
#   MACHINE_OS PGINCDIR PGLIBDIR PLTCOLLECTS SHLIB
# reflect your system.

if . vars.sh; then true; else
    echo "Please create vars.sh from the provided templates"
    exit 1
fi

rm -rf "$PLTCOLLECTS"/scheme-pg

mkdir "$PLTCOLLECTS"/scheme-pg
mkdir "$PLTCOLLECTS"/scheme-pg/compiled
mkdir "$PLTCOLLECTS"/scheme-pg/compiled/native
mkdir "$PLTCOLLECTS"/scheme-pg/compiled/native/$MACHINE_OS

sh ./compile.sh
sh ./link.sh
mv s-pg.o "$PLTCOLLECTS"/scheme-pg/compiled/native/$MACHINE_OS
mv s-pg.$SHLIB "$PLTCOLLECTS"/scheme-pg/compiled/native/$MACHINE_OS

cp -r * "$PLTCOLLECTS"/scheme-pg

# NOTE: The timesatamp of s-pg.$SHLIB must be later than the timestamp of
# s-pg.ss.  Quoting from Section 3.3 of the mzc: MzScheme Compiler
# Manual, "A byte-code or native-code file is used in place of the
# requested file only if its modification date is later than the
# requested file, or if the requested file does not exist. If both
# byte-code and native-code files can be loaded, the native-code file
# is loaded."
touch "$PLTCOLLECTS"/scheme-pg/s-pg.ss
touch "$PLTCOLLECTS"/scheme-pg/compiled/native/$MACHINE_OS/s-pg.$SHLIB

mzc --collection-zos scheme-pg
#setup-plt --mode errortrace -l scheme-pg
