#!/bin/sh

# Change this to fit your spice3 binary absolute path:
SPICE3PATH="/usr/bin/spice3"

# Change this to fit your spice3 model absolute path:
SPICE3LIBPATH="/home/yourname/eaglesp3/spice3lib"

# Change this to fit your eagle distribution absolute path:
EAGLEPATH="/opt/eagle-3.55r3e"

#---------------------- DO NOT EDIT ANYTHING BELOW THIS LINE! ----------------------

THISPATH=`pwd`

echo "Installing eaglesp3 analog library."
cp $THISPATH/install/spice3.lbr $EAGLEPATH/lbr

echo "Installing eaglesp3 digital library."
cp $THISPATH/install/digital.lbr $EAGLEPATH/lbr

echo "Installing eaglesp3 help files."
cp -r $THISPATH/install/help/eaglesp3 $EAGLEPATH/help
cd $EAGLEPATH/help

echo "Patching original eagle help index file to include"
echo "a link to the eaglesp3 help files..."
patch < $THISPATH/install/help/eagleindex.dif

echo "Installing eaglesp3 spice3 models."
mkdir $SPICE3LIBPATH
cp $THISPATH/install/spice3lib/* $SPICE3LIBPATH  

echo "Installing customized eagle netlister program." 
sed "s#yourspice3path#$SPICE3PATH#;s#yourspice3libpath#$SPICE3LIBPATH#" $THISPATH/install/spice3.ulp > $EAGLEPATH/ulp/spice3.ulp

echo "Installing customized eagle startup configuration file." 
sed "s#youreaglepath#$EAGLEPATH#" $THISPATH/install/spice3.scr > $EAGLEPATH/scr/spice3.scr

echo "Installing customized eagle start and simulation handler shell script." 
sed "s#youreaglepath#$EAGLEPATH#" $THISPATH/install/starteagle > $THISPATH/starteagle
chmod 755 $THISPATH/starteagle

echo ""
echo "Installation finished."
echo ""
echo "Execute ./starteagle and choose Help/Contents from the upcoming EAGLE Control Panel."
echo "A Browser window should rise. Click on the Eaglesp3 Spice3 Simulation Interface"
echo "link (at the bottom) and proceed with the tutorial."
