#Maintainer: Dimitris Tzemos <djemos~at~slackel~dot~gr>

pkgname=icedtea-web
pkgver=1.4
pkgrel=2dj
source=("http://icedtea.wildebeest.org/download/source/$pkgname-$pkgver.tar.gz")
sourcetemplate=http://people.salixos.org/djemos/salix/$pkgname
docs=("AUTHORS" "COPYING" "ChangeLog" "NEWS" "README" "doc/OVERVIEW")
url=http://icedtea.classpath.org/wiki/IcedTea-Web

slackdesc=\
(
 #|-----handy-ruler------------------------------------------------------|
"icedtea-web (Java Web Start browser plugin)"
"The IcedTea-Web project provides a Free Software web browser plugin"
"running applets written in the Java programming language and"
"an implementation of Java Web Start, originally based on the"
"NetX project."
""
"HomePage: http://icedtea.classpath.org/wiki/IcedTea-Web"
)

build() {

case "ARCH" in
    arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
    *)    TARGET=$ARCH-slackware-linux ;;
esac   
 

cd $startdir/src/$pkgname-$pkgver
        
[ ! -x configure  ] && ./autogen.sh

# We use seamonkey, not xulrunner:
sed -i -e 's/mozilla-plugin/seamonkey-plugin/g' configure

# IcedTea Web 1.1 and later do not install into the JDK/JRE directory but
# straight into /usr/lib
CFLAGS="$SLKCFLAGS" \
LDFLAGS="$SLKLDFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --mandir=/usr/man \
  --infodir=/usr/info \
  --docdir=/usr/doc/$PKGNAM-$VERSION \
  --with-jdk-home=/usr/lib${LIBDIRSUFFIX}/java \
  --with-jre-home=/usr/lib${LIBDIRSUFFIX}/java/jre \
  --with-pkgversion=$(cat /etc/slackware-version |tr ' ' '-')-$ARCH \
  --disable-docs \
  --build=$TARGET

make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG || exit 1

# Make the tools work with only the openjre installed:
sed -i -e "s,java/jre/bin,java/bin,g" $PKG/usr/bin/javaws || return 1
sed -i -e "s,java/jre/bin,java/bin,g" $PKG/usr/bin/itweb-settings || return 1

# Provide a link to the plugin for browsers:
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins || return 1
( cd $PKG/usr/lib${LIBDIRSUFFIX}/mozilla/plugins || return 1
  ln -sf /usr/lib${LIBDIRSUFFIX}/IcedTeaPlugin.so || return 1
)

# Install desktop files:
mkdir -p $PKG/usr/share/icons/hicolor/48x48/apps || return 1
mkdir -p $PKG/usr/share/{applications,pixmaps} || return 1
cp javaws.png $PKG/usr/share/pixmaps || return 1
cp javaws.png $PKG/usr/share/icons/hicolor/48x48/apps || return 1

install -m 0644 javaws.desktop $PKG/usr/share/applications/ || return 1
install -m 0644 itweb-settings.desktop $PKG/usr/share/applications/ || return 1
sed -i "s/.png//" $PKG/usr/share/applications/javaws.desktop || return 1
sed -i "s/.png//" $PKG/usr/share/applications/itweb-settings.desktop || return 1
}

doinst() {
# Update the desktop database:
if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database usr/share/applications >/dev/null 2>&1
fi

# Update the mime database:
if [ -x /usr/bin/update-mime-database ]; then
  /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi
}