#!/bin/sh

# bundleTool
# David Corcoran <corcoran@linuxnet.com>
# MUSCLE <http://www.musclecard.com>
#

if [ x$DESTDIR = "x" ]
then
	DESTDIR=`pkg-config libmusclecard --variable=muscledropdir`
	DESTDIR=${DESTDIR:-/usr/local/pcsc/services}
fi

bundlename="mscMuscleCard.bundle"
libname="libmusclecardApplet"
dso_suffix="so"
targetname="mscMuscleCard"

hostType=`uname`

case "$hostType" in
	SunOS)
		hostType="Solaris";;
	Linux)
		hostType="Linux";;
	Darwin)
		dso_suffix="dylib"
		hostType="MacOS";;
	BSD)
		hostType="BSD";;
	HPUX)
		dso_suffix="sl"
		hostType="HPUX";;
	Tru64)
		hostType="Tru64";;
	*)
		echo "Couldn't determine system type: $hostType"
		exit;;
esac
echo "Configuring for system: $hostType"

echo "Writing service bundle for $targetname in $DESTDIR"
if [ ! -d $DESTDIR ]
then
	install -d -m 755 $DESTDIR
fi

set -x
cp -r src/$bundlename $DESTDIR
install -d -m 755 $DESTDIR/$bundlename/Contents/$hostType
install -m 644 src/.libs/$libname.$dso_suffix $DESTDIR/$bundlename/Contents/$hostType/$targetname
echo "Installation Successful"

