#!/bin/sh

# This installs MSVC-built libraries of a module such as libsigc++, glibmm or
# gtkmm into the MSVC subdirectory

module=$1
toolset=$2

# Assume all the other libraries are at same point as gtkmm:
basepath=../..

# TODO: Automatically find latest version of package: First try SVN checkout, then look for latest installed tarball version.
if test $module = 'libsigc++'; then
	# Path to extracted tarball or SVN checkout
	sourcepath="${basepath}/libsigc++"
	# Basename of DLL
	basename='sigc'
	# Version tag of DLL name
	vername='2_0'
	# Abiname of package
	abiname='sigc++-2.0'
	# Subdirectory in MSVC_Net2005
	subdir='.'
elif test $module = 'glibmm'; then
	sourcepath="${basepath}/glibmm-2.18.0"
	basename='glibmm'
	vername='2_4'
	abiname='glibmm-2.4'
	subdir='glibmm'
elif test $module = 'giomm'; then
	sourcepath="${basepath}/glibmm-2.18.0"
	basename='giomm'
	vername='2_4'
	abiname='giomm-2.4'
	subdir='giomm'
elif test $module = 'cairomm'; then
	sourcepath="${basepath}/cairomm-1.6.4"
	basename='cairomm'
	vername='1_0'
	abiname='cairomm-1.0'
	subdir='cairomm'
elif test $module = 'pangomm'; then
	sourcepath="${basepath}/pangomm-2.14.0"
	basename='pangomm'
	vername='1_4'
	abiname='pangomm-1.4'
	subdir='pangomm'
elif test $module = 'atkmm'; then
	sourcepath="${basepath}/gtkmm-2.14.1"
	basename='atkmm'
	vername='1_6'
	abiname='atkmm-1.6'
	subdir='atkmm'
elif test $module = 'gdkmm'; then
	sourcepath="${basepath}/gtkmm-2.14.1"
	basename='gdkmm'
	vername='2_4'
	abiname='gdkmm-2.4'
	subdir='gdkmm'
elif test $module = 'gtkmm'; then
	sourcepath="${basepath}/gtkmm-2.14.1"
	basename='gtkmm'
	vername='2_4'
	abiname='gtkmm-2.4'
	subdir='gtkmm'
elif test $module = 'libglademm'; then
	sourcepath="${basepath}/libglademm-2.6.7"
	basename='glademm'
	vername='2_4'
	abiname='glademm-2.4'
	subdir='libglademm'
elif test $module = 'libxml++'; then
	sourcepath="${basepath}/libxml++-2.24.0"
	basename='xml++'
	vername='2_6'
	abiname='libxml++-2.6'
	subdir='libxml++'
else
	echo "Module $module not known"
	exit -1
fi

if test $toolset = 'vc80'; then
	vcdir='MSVC_Net2005'
elif test $toolset = 'vc90'; then
	vcdir='MSVC_Net2008'
else
	echo "Toolset $toolset not known"
	exit -1
fi

#echo "Source Path: $sourcepath"
#echo "Basename: $basename"
#echo "Abiname: $abiname"
#echo "Subdir: $subdir"

targetpath=MSVC

mkdir -p ${targetpath} || exit -1
cp $sourcepath/$vcdir/$subdir/Release/${basename}-${toolset}-${vername}.dll $targetpath || exit -1
cp $sourcepath/$vcdir/$subdir/Debug/${basename}-${toolset}-d-${vername}.dll $targetpath || exit -1
cp $sourcepath/$vcdir/$subdir/Debug/${basename}-${toolset}-d-${vername}.pdb $targetpath || exit -1

mkdir -p ${targetpath}/lib || exit -1
cp $sourcepath/$vcdir/$subdir/Release/${basename}-${toolset}-${vername}.lib $targetpath || exit -1
cp $sourcepath/$vcdir/$subdir/Debug/${basename}-${toolset}-d-${vername}.lib $targetpath || exit -1

# Configfile is used from mingw, thus commented out:
#configfile=$sourcepath/MSVC_Net2005/$subdir/*config.h
#if test -f configfile; then
#	mkdir -p $targetpath/lib/${abiname}/include/ || exit -1
#	cp $configfile $targetpath/lib/${abiname}/include/ || exit -1
#fi
