#!/bin/sh
# Copyright (C) 1999 INRIA/INSA.
#
# Author : Erwan Jahier <jahier@irisa.fr>
#
# This script creates the Opium-M script.



MERCURY_OPIUM_DIR=`pwd`
export MERCURY_OPIUM_DIR 
cd scripts
rm -f Opium-M

# Get the Mercury library path (needed in source scenario)
MmcDefault=/soft/mercury/library

echo "What is the complete path of the Mercury library source files? [default=$MmcDefault]"
read RESPONSE

case $RESPONSE in
        '')   LIB_MERCURY=$MmcDefault;;
        *)    LIB_MERCURY=$RESPONSE;;
esac

cat << EOF >> Opium-M
#!/bin/sh
# Copyright (C) 1999 INRIA/INSA. 
#  
# Author : Erwan Jahier <jahier@irisa.fr> 
# 
# Script generated by INSTALL-OPIUM-M. 

Help=" 
Name:  Opium-M 
Usage: Opium-M [--no-banner]
Description: 
       Runs Opium-M, the Mercury trace analyser. 
"

#This variable should contain the path where Opium-M has been installed 
MERCURY_OPIUM_DIR=$MERCURY_OPIUM_DIR
export MERCURY_OPIUM_DIR 

#This variable should contain the path of the mercury library source files  
#(which is needed in the source scenario)  
LIB_MERCURY=$LIB_MERCURY 
export LIB_MERCURY 
 
case \$1 in
    --no-banner) COMMAND="eclipse -b ${MERCURY_OPIUM_DIR}/source/load_opium_without_banner.pl " ;;

     *) COMMAND="eclipse -b ${MERCURY_OPIUM_DIR}/source/load_opium.pl " ;;
esac

exec \$COMMAND 
echo \$COMMAND

EOF
cd ..

echo "Compiling the Mercury program listing.m..."
[ -d bin ] || mkdir bin
cd ${MERCURY_OPIUM_DIR}/source
mmake listing.depend
mmake listing
mv ${MERCURY_OPIUM_DIR}/source/listing ${MERCURY_OPIUM_DIR}/bin/
chmod a+x ${MERCURY_OPIUM_DIR}/bin/listing
mmake listing.realclean

chmod a+x ${MERCURY_OPIUM_DIR}/scripts/Opium-M

echo "Compiling Opium-M files..."
eclipse -b ${MERCURY_OPIUM_DIR}/source/make_scenario.pl

echo ""
echo "  Don't forget to add ${MERCURY_OPIUM_DIR}/scripts and"
echo "  ${MERCURY_OPIUM_DIR}/bin to your PATH."
echo "  Make sure that the executables mmc and eclipse are accessible "
echo "  from your PATH too."







