#!/bin/sh
# Copyright (C) 1999-2001 INRIA/INSA de Rennes/IFSIC.
# This file may only be copied under the terms of the GNU Library General
# Public License - see the file License in the Morphine distribution.
#
# Author : Erwan Jahier <jahier@irisa.fr>
#
# This script creates the Morphine script.



MERCURY_MORPHINE_DIR=`pwd`
export MERCURY_MORPHINE_DIR 
cd scripts
rm -f morphine

# Get the Mercury library path (needed in source scenario)
MmcDefault=../../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 >> morphine
#!/bin/sh
# Copyright (C) 1999 INRIA/INSA de Rennes. 
# This file may only be copied under the terms of the GNU Library General
# Public License - see the file License in the Morphine distribution.
#  
# Author : Erwan Jahier <jahier@irisa.fr> 
# 
# Script generated by INSTALL-MORPHINE. 

Help=" 
Name:  morphine 
Usage: morphine [--no-banner]
Description: 
       Runs morphine, the Mercury trace analysis system. 
"

#This variable should contain the path where Morphine has been installed 
MERCURY_MORPHINE_DIR=$MERCURY_MORPHINE_DIR
export MERCURY_MORPHINE_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_MORPHINE_DIR}/source/load_morphine_without_banner.pl " ;;

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

exec \$COMMAND 
echo \$COMMAND

EOF
cd ..

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

mmake generate_pred_cov.depend
mmake generate_pred_cov
mv ${MERCURY_MORPHINE_DIR}/source/generate_pred_cov ${MERCURY_MORPHINE_DIR}/bin/
chmod a+x ${MERCURY_MORPHINE_DIR}/bin/generate_pred_cov

mmake generate_call_site_cov.depend
mmake generate_call_site_cov
mv ${MERCURY_MORPHINE_DIR}/source/generate_call_site_cov ${MERCURY_MORPHINE_DIR}/bin/
chmod a+x ${MERCURY_MORPHINE_DIR}/bin/generate_call_site_cov

mmake generate_pred_cov.realclean
mmake generate_call_site_cov.realclean

chmod a+x ${MERCURY_MORPHINE_DIR}/scripts/morphine

echo "Compiling Morphine files..."
eclipse -b ${MERCURY_MORPHINE_DIR}/source/make_scenario.pl







