#!/bin/sh 

if [ -z $BIP2_HOME ]; then  
  echo "BIP2_HOME environment variable is not set" 
  exit 255
fi

#provide reasonable default values. 
BIP_COMPILER_BACKENDS=""
if [ -f $BIP2_HOME/backend.conf ]; then
    . $BIP2_HOME/backend.conf
else
    BIP_COMPILER_BACKENDS="ujf.verimag.bip.graphviz.GraphvizAutomaton;ujf.verimag.bip.cxxcodegen.CxxModuleGenerator"
fi

BIP_COMPILER_FILTERING_BACKENDS=""
if [ -f $BIP2_HOME/filteringbackend.conf ]; then
    . $BIP2_HOME/filteringbackend.conf
fi

if [ -d $BIP2_HOME/bip-parts ]; then  

    unset LOCAL_CP

    BIP_PLUGINS=$BIP2_HOME/bip-parts
    EXTERNAL_PLUGINS=$BIP2_HOME/externals
    
    for plugin in $BIP_PLUGINS/*.jar $EXTERNAL_PLUGINS/*.jar; do
	LOCAL_CP="$LOCAL_CP:$plugin"
    done

    java -D"bip.compiler.backends=$BIP_COMPILER_BACKENDS" -D"bip.compiler.filteringbackends=$BIP_COMPILER_FILTERING_BACKENDS" -cp $CLASSPATH:$LOCAL_CP  ujf.verimag.bip.cmdline.CmdLine  $BIP_CMDLINE_JAR $* 
else
    echo "BIP2_HOME environment variable does not point to the bip distribution" 
    exit 255
fi
