#!/bin/bash
# Abstract remove libraries and install new

cd $(dirname $0)

LIBS=$(ls -d 10_*)

PS3="Which library to be installed? "
printf "\nInstallation of libraries:\n\n"
select s in $LIBS cancel
do
   case $s in
   cancel )
           echo "cancelled ..."
           exit 1
           ;;
   * )
           echo "going to install $s"
           break
           ;;
   esac
done

#
# Remove old libraries first
#
sudo rm -f /usr/lib/libmxmac260.a
sudo rm -f /usr/lib/libmxmac260.dylib
sudo rm -f /usr/lib/libmxmac2260.a
sudo rm -f /usr/lib/libmxmac2260.dylib
sudo rm -f /usr/lib/libmxmac.dylib
sudo rm -f /usr/lib/libmxmac2.dylib

#
# Copy libraries and make links
#
sudo cp $s/libmxmac260.a      /usr/lib
sudo cp $s/libmxmac260.dylib  /usr/lib
sudo ln -s /usr/lib/libmxmac260.dylib /usr/lib/libmxmac.dylib

echo "Following libraries installed:"
ls -l /usr/lib/libmxmac*

