#!/bin/bash

INSTALL=`which install`
STRIP=`which strip`

BINDIR=/usr/bin
FONTSDIR=/usr/share/fonts/ekd500control
PIXMAPSDIR=/usr/share/pixmaps
MANDIREN=/usr/share/man/man1
MANDIRIT=/usr/share/man/it/man1
DOCDIR=/usr/share/doc/ekd500control
GPLV3DIR=/usr/share/doc/ekd500control/GPLv3
LOCALEDIR=/usr/share/locale

if ! test "$UID" = "0" ; then
    echo "'Install' must be run as root"
    exit
fi

if test -z $INSTALL ; then
	echo "'install' program not found"
	exit
fi

if ! test -d "$FONTSDIR" ; then
	mkdir -p "$FONTSDIR"
fi

if ! test -d $DOCDIR ; then
	mkdir -p $DOCDIR
fi

if ! test -d $GPLV3DIR ; then
	mkdir -p $GPLV3DIR
fi

echo "Installing..."

$INSTALL -m 755 ../EKD500Control $BINDIR
if test -n $STRIP ; then
	$STRIP $BINDIR/EKD500Control
fi

$INSTALL -m 644 ../man/en/EKD500Control.1 $MANDIREN
$INSTALL -m 644 ../man/it/EKD500Control.1 $MANDIRIT
$INSTALL -m 644 ../../EKD500Control.png $PIXMAPSDIR
$INSTALL -m 644 ../fonts/digital-dream-fat.ttf $FONTSDIR
$INSTALL -m 644 ../fonts/Arial.ttf $FONTSDIR
$INSTALL -m 644 ../fonts/Arial_Bold.ttf $FONTSDIR
$INSTALL -m 644 ../fonts/DejaVuSansMono.ttf $FONTSDIR
$INSTALL -m 644 ../locale/it/EKD500Control.mo $LOCALEDIR/it/LC_MESSAGES/EKD500Control.mo
$INSTALL -m 644 ../GPLv3/gpl-3.0.txt $GPLV3DIR
$INSTALL -m 644 ../GPLv3/gplv3-it-final.pdf $GPLV3DIR
$INSTALL -m 644 ../doc/Manual-en.txt $DOCDIR
$INSTALL -m 644 ../doc/Manual-it.txt $DOCDIR

echo "Done!"
