#Maintainer: Chris Farrell <chris~at~opensuse~dot~us>
#Former Maintainer(s): George Vlahavas (vlahavas~at~gmail~dot~com)

#Mandatory
pkgname=vice
pkgver=2.4
pkgrel=1cf
source=("http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/vice-$pkgver.tar.gz"
"icons.tar.gz" 
"vice.desktop" 
"vice"
"vice-2.4-no-fc-cache.patch"
"vice-2.4-64bit.patch")
sourcetemplate=http://people.salixos.org/timcowchip/$pkgname/$pkgver/
docs=("AUTHORS" "COPYING" "ChangeLog" "FEEDBACK" "INSTALL" "NEWS" "README")
url=http://www.viceteam.org/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"vice (an emulator for Commodore's 8-bit computers)"
"VICE is a program that runs on a Unix, MS-DOS, Win32, OS/2, Acorn"
"RISC OS, BeOS, QNX 6.x, Amiga, GP2X or Mac OS X machine and executes"
"programs intended for the old 8-bit computers. The current version"
"emulates the C64, the C128, the VIC20, almost all PET models, the"
"PLUS4 and the CBM-II (aka C610)."
)
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

build() {
	cd $startdir/src/$pkgname-$pkgver
        [ "$ARCH" == "x86_64" ] && patch -p1 < $startdir/src/vice-2.4-64bit.patch || return 1
        patch -p1 < $startdir/src/vice-2.4-no-fc-cache.patch || exit 1
        CFLAGS="$SLKCFLAGS" \
        CXXFLAGS="$SLKCFLAGS" \
        
	./configure --prefix=/usr \
	--libdir=/usr/lib${LIBDIRSUFFIX} \
	--sysconfdir=/etc \
	--enable-gnomeui \
	--enable-ethernet \
	--enable-fullscreen \
	--disable-ffmpeg \
	--without-oss
	make || return 1
	make install DESTDIR=$startdir/pkg

	mkdir -p $startdir/pkg/usr/bin
	cp $startdir/src/vice $startdir/pkg/usr/bin
	chmod a+x $startdir/pkg/usr/bin/vice

	mkdir -p $startdir/pkg/usr/share/applications
	cp $startdir/src/vice.desktop $startdir/pkg/usr/share/applications/

    # Copy icons to the right place
	ICONSIZES="48 32 24 22 16"
	for i in $ICONSIZES; do
		mkdir -p $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps;
		mv $startdir/src/$pkgname-$i.png $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps/$pkgname.png;
	done;

	# Remove unwanted files
	rm -rf $startdir/pkg/usr/share/info/dir
}
