#!/bin/sh
# @(#)$Date 2005/07/17 15:36:31 $
#
# Install-JML-Scripts -- script to install JML scripts in ${INSTALLDIR}
#
# SYNOPSIS: remove old JML scripts and install new ones
#
# Thanks to Joe Kiniry, K. Proch, Steve Shaner, and Michael Ernst
# for fixes and suggestions to this.

# If needed, change the following configuration parameters for your system
# by changing what is to the right of the equals sign (=) on the lines below
: ${INSTALLTYPE="unix"}                     # change to cygwin for cygwin
: ${INSTALLDIR="/usr/local"}                # installation target directory
: ${JMLDIR="$INSTALLDIR/JML"}               # where JML is unpacked and lives
: ${JUNITDIR="$INSTALLDIR/junit"}           # installation home of JUnit

: ${TOINSTALL="jml jmlc jmldoc jmlrac jmlspec jmlunit jtest jml-junit jml-launcher"}

if test ! -d ${INSTALLDIR} 
then
    echo "$0 : creating ${INSTALLDIR}..." >&2
    mkdir "${INSTALLDIR}"
fi 

if test ! -d ${JMLDIR} 
then
    echo "$0 : cannot find ${JMLDIR}!  Aborting install" >&2
    exit 1
fi

# The following is needed because (currently) jmldoc only works with
# the J2SDK 1.4 tools.jar (not 1.5 or 1.3, ...); 
# edit the path so that it points to tools.jar in your J2SDK 1.4 install.
: ${JDKTOOLS="/usr/local/jdk1.4/lib/tools.jar"}

case "`uname`" in
  Darwin*) # MAC OS X
	;;
  *) # everything else
	if test ! -f ${JDKTOOLS} 
	then
	    echo "$0 : ${JDKTOOLS} file not found" >&2
	    echo 'You need J2SDK 1.4 to be installed for jmldoc to work' >&2
	    exit 1
	fi
	;;
esac

test -d ${INSTALLDIR}/bin || mkdir ${INSTALLDIR}/bin
test -d ${INSTALLDIR}/man || mkdir ${INSTALLDIR}/man
test -d ${INSTALLDIR}/man/man1 || mkdir ${INSTALLDIR}/man/man1

: ${SEDEDITS='s@JMLDIR="/usr/local/JML"@JMLDIR="'${JMLDIR}'"@;s@JUNITDIR="/usr/local/junit"@JUNITDIR="'${JUNITDIR}'"@;s@JMLDIR=`cygpath -wa "/usr/local/JML"`@JMLDIR=`cygpath -wa "'${JMLDIR}'"`@;s@JUNITDIR=`cygpath -wa "/usr/local/junit"`@JUNITDIR=`cygpath -wa "'${JUNITDIR}'"`@;s@JDKTOOLS="/usr/local/jdk1.4/lib/tools.jar"@JDKTOOLS="'${JDKTOOLS}'"@;s@JDKTOOLS=`cygpath -wa "/usr/local/jdk1.4/lib/tools.jar"`@JDKTOOLS=`cygpath -wa "'${JDKTOOLS}'"`@'}

for f in ${TOINSTALL}
do
  rm -f ${INSTALLDIR}/bin/$f ${INSTALLDIR}/man/man1/${f}.1
  if test -f ${JMLDIR}/bin/${f}-${INSTALLTYPE}
  then
      sed -e "${SEDEDITS}" ${JMLDIR}/bin/${f}-${INSTALLTYPE} > ${INSTALLDIR}/bin/$f
  else 
      sed -e "${SEDEDITS}" ${JMLDIR}/bin/${f} > ${INSTALLDIR}/bin/$f
  fi
  chmod 755 ${INSTALLDIR}/bin/$f
  cp ${JMLDIR}/docs/man/${f}.1 ${INSTALLDIR}/man/man1/
  chmod 644 ${INSTALLDIR}/man/man1/${f}.1

  if test -f ${JMLDIR}/bin/${f}-gui-${INSTALLTYPE}
  then
      rm -f ${INSTALLDIR}/bin/${f}-gui
      sed -e "${SEDEDITS}" ${JMLDIR}/bin/${f}-gui-${INSTALLTYPE} > ${INSTALLDIR}/bin/${f}-gui
      chmod 755 ${INSTALLDIR}/bin/${f}-gui
  fi
done 

# Copyright (C) 2002-2005 Iowa State University
#
# This file is part of JML
#
# JML is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# JML is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with JML; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
