#!/bin/sh

# this script finishes the mono installation

#
# See setup for user tweakables.
#
. ./setup

# check if install path redefined
test -n "$1" && OOINSTDIR="$1"

# continue only when mono has been built
test -f $OOINSTDIR/program/cli_basetypes.dll || exit 0;


echo "Finishing the mono installation..."

if ! test -w "$OODESTDIR/" ; then
    echo "Warning: You do not have rights to finish the mono installation"
    echo "         => skipping it"
    exit 0;	   
fi

# install the pkgconfig file
# GAC is in /usr/lib even on 64-bit architectures, so the .pc file points to
# the /usr/lib paths; the .pc file itself must be in the arch dependant path
# to be found in PKG_CONFIG_PATH, though
mkdir -p $OODESTDIR${LIBDIRBASE}/pkgconfig/
cp $SRCDIR/mono-ooo.pc ${OODESTDIR}${LIBDIRBASE}/pkgconfig/mono-ooo$BINSUFFIX-$VERSION.pc

# install versioned assemblies into the system Global Assembly Cache  (GAC)
# to  become  part  of  the assemblies that are available for all applications
# at runtime.
# Note: It should be done in postinstall script
#       It cannot be done with DESTDIR defined, definitely
if test "$RUN_POST_INSTALL_SCRIPTS" = "yes" -a -z "$OODESTDIR" ; then
    for dll in cli_basetypes.dll \
               cli_cppuhelper.dll \
	       cli_types.dll \
	       cli_uno_bridge.dll \
	       cli_ure.dll ; do
	gacutil -i $OOINSTDIR/program/$dll -package $OOOINSTALLDIRNAME
    done
fi
