#!/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="slbCryptoflex.bundle"
libname="libcryptoflex"
targetname="slbCryptoflex"
dso_suffix="so"

hostType=`uname`
# some systems need a special case
case "$hostType" in
	SunOS)
		hostType="Solaris";;
	Darwin)
		dso_suffix="dylib"
		hostType="MacOS";;
	*BSD*)
		hostType="BSD";;
	HPUX)
		dso_suffix="sl"
esac

echo "Configuring for system: $hostType"
echo "Writing service bundle for $targetname in $DESTDIR"
if [ ! -d $DESTDIR ]
then
	install -d -m 755 $DESTDIR
fi
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"
