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

pkgname=aMule
pkgver=2.3.1
pkgrel=2dj
source=("http://downloads.sourceforge.net/amule/$pkgname-$pkgver.tar.bz2" "gcc4.7.patch")
sourcetemplate=http://people.salixos.org/djemos/salix/$pkgname
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "about-nls")
url=http://www.amule.org


slackdesc=\
(
 #|-----handy-ruler------------------------------------------------------|
 "aMule (multiplatform ed2k client)"
 "aMule is a multiplatform ed2k client, fork of the eMule client,"
 "using the wxWidgets class library, supporting Linux, *BSD platforms,"
 "Solaris, *MacOSX and *Win32 (*soon). It was originally forked from"
 "the xMule project, which in turn was forked from the lMule project."
)

build() {
        
        cd $startdir/src/$pkgname-$pkgver || return 1

	patch -p1 < $startdir/src/gcc4.7.patch || return 1
       ./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc \
        --disable-debug \
		--enable-optimize \
		--enable-amule-daemon \
		--enable-amulecmd \
		--enable-webserver \
		--enable-amule-gui \
		--enable-cas \
		--enable-geoip \
		--enable-wxcas \
		--enable-alc \
		--enable-alcc \
		--program-prefix= \
		--program-suffix= \
		--build=$arch-slackware-linux
                
        make || return 1
        make install DESTDIR=$startdir/pkg || return 1
         # create icons
         if [ -e "$startdir/pkg/usr/share/icons/hicolor/48x48/apps" ]; then
	     echo "perhaps icons already exists?"
		 return 1
	   fi

       mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver || return 1
       cp $startdir/pkg/usr/share/doc/amule/* $startdir/pkg/usr/doc/$pkgname-$pkgver || return 1
       rm -rf $startdir/pkg/usr/share/doc || return 1

        mkdir -p $startdir/pkg/usr/share/icons/hicolor/48x48/apps || return 1
	    cp $startdir/src/$pkgname-$pkgver/amule.png $startdir/pkg/usr/share/icons/hicolor/48x48/apps || return 1
      
   	    cp $startdir/src/$pkgname-$pkgver/amule.desktop $startdir/pkg/usr/share/applications/ || return 1
	    sed -i "s/Categories=.*/Categories=Network;P2P;/" $startdir/pkg/usr/share/applications/amule.desktop || return 1
	    sed -i "s/.png//" $startdir/pkg/usr/share/applications/amule.desktop || return 1  
	             
}



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

}