#!/bin/sh
# install script for the binary distribution of LabPlot

# check KDEDIR
if [ "$KDEDIR" ];then
	if [ -f "$KDEDIR"/bin/startkde ]; then
	    	echo "checking KDE : OK"
	else
		found_kde=0
	fi
else
	found_kde=0
fi

if [ "$found_kde" = "0" ];then
	echo "Please set KDEDIR correct"
	echo "  bash : export KDEDIR=/path/to/kde"
	echo "(t)csh : setenv KDEDIR /path/to/kde"
	exit 1
fi

# check argument
# TODO : linux_alpha, freebsd_x86, freebsd_alpha, linux_sparc, linux_ppc, openbsd_x86, openbsd_sparc, ...
if [ "$1" = "linux_x86" ] || [ "$1" = "linux_suse8.2_x86" ] || [ "$1" = "linux_x86_64" ] || [ "$1" = "solaris_sparc" ]; then
	platform="$1"
else
	echo "Please select one the following platforms:"
	echo "./install linux_x86"
	echo "./install linux_suse8.2_x86"
	echo "./install linux_x86_64"
	echo "./install solaris_sparc"
	exit 2
fi

echo "Installing LabPlot on $platform under $KDEDIR ..."

cp -f src/LabPlot.$platform $KDEDIR/bin/LabPlot
cp -f src/LabPlot.desktop $KDEDIR/share/applnk/Applications
cp -f src/x-lpl.desktop $KDEDIR/share/mimelnk/application
mkdir -p $KDEDIR/share/apps/LabPlot
cp -f examples/*.lpl src/LabPlotui.rc $KDEDIR/share/apps/LabPlot

mkdir -p $KDEDIR/share/apps/LabPlot/icons/locolor/16x16/apps/
cp -f src/lo16-app-LabPlot.png $KDEDIR/share/apps/LabPlot/icons/locolor/16x16/apps/
mkdir -p $KDEDIR/share/apps/LabPlot/icons/locolor/32x32/apps/
cp -f src/lo32-app-LabPlot.png $KDEDIR/share/apps/LabPlot/icons/locolor/32x32/apps/
mkdir -p $KDEDIR/share/apps/LabPlot/icons/hicolor/48x48/apps/
cp -f src/hi48-app-LabPlot.png $KDEDIR/share/apps/LabPlot/icons/hicolor/48x48/apps/
mkdir -p $KDEDIR/share/apps/LabPlot/icons/hicolor/48x48/mimetypes/
cp -f src/hi48-mime-lpl.png $KDEDIR/share/apps/LabPlot/icons/hicolor/48x48/mimetypes/
mkdir -p $KDEDIR/share/apps/LabPlot/icons/hicolor/64x64/mimetypes/
cp -f src/hi64-mime-lpl.png $KDEDIR/share/apps/LabPlot/icons/hicolor/64x64/mimetypes/
mkdir -p $KDEDIR/share/apps/LabPlot/icons/locolor/16x16/mimetypes/
cp -f src/lo16-mime-lpl.png $KDEDIR/share/apps/LabPlot/icons/locolor/16x16/mimetypes/
mkdir -p $KDEDIR/share/apps/LabPlot/icons/locolor/32x32/mimetypes/
cp -f src/lo32-mime-lpl.png $KDEDIR/share/apps/LabPlot/icons/locolor/32x32/mimetypes/

echo " OK"
