#Maintainer: Thorsten Muehlfelder <thenktor@gmx.de>

pkgname=vbrfix
pkgver=r131
pkgrel=1tm
arch=i486
source=("get-new-src.sh" "vbrfix.png" "vbrfix.svg" "http://thenktor.dyndns.org/packages/$pkgname/$pkgname-$pkgver.src.tar.gz")
sourcetemplate=http://thenktor.dyndns.org/packages/$pkgname/
url="http://www.willwap.co.uk/Programs/vbrfix.php"
docs=('AUTHORS' 'README' 'COPYING')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (fixes vbr mp3 files)"
"Vbrfix reads the mp3 structure and rebuilds the file including a new"
"Xing VBR header."
"What is VBRFix for?"
"VBR MP3s often have a special tag at the beginning to inform the"
"player about how to treat the VBR file. VBRFix can create/replace"
"this special tag. It can also be used to remove unrecognised data"
"from the mp3 and spot other problems."
)

build() {
	cd $startdir/src/vbrfix/vbrfix
	qmake -config release
	# change flags in makefiles
	make clean
	sed -i 's#^CFLAGS *= -pipe -O2#CFLAGS        = -pipe -O2 -march=i486 -mtune=i686#' ConsoleFixer/Makefile || return 1
	sed -i 's#^CXXFLAGS *= -pipe -O2#CFLAGS        = -pipe -O2 -march=i486 -mtune=i686#' ConsoleFixer/Makefile || return 1
	sed -i 's#^CFLAGS *= -pipe -O2#CFLAGS        = -pipe -O2 -march=i486 -mtune=i686#' QtFixer/Makefile || return 1
	sed -i 's#^CXXFLAGS *= -pipe -O2#CFLAGS        = -pipe -O2 -march=i486 -mtune=i686#' QtFixer/Makefile || return 1
	sed -i 's#^CFLAGS *= -pipe -O2#CFLAGS        = -pipe -O2 -march=i486 -mtune=i686#' Fixer/Makefile || return 1
	sed -i 's#^CXXFLAGS *= -pipe -O2#CFLAGS        = -pipe -O2 -march=i486 -mtune=i686#' Fixer/Makefile || return 1
	# compile
	make -j3
	# install files
	mkdir -p $startdir/pkg/usr/bin/
	#install -m 755 ConsoleFixer/VbrfixConsole $startdir/pkg/usr/bin/vbrfix
	install -m 755 QtFixer/VbrfixGui $startdir/pkg/usr/bin/vbrfix-gui

	# icons
	cd $startdir/src
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/48x48/apps
	cp vbrfix.png $startdir/pkg/usr/share/icons/hicolor/48x48/apps || return 1
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/scalable/apps
	cp vbrfix.svg $startdir/pkg/usr/share/icons/hicolor/scalable/apps || return 1

	# desktop file
	mkdir -p $startdir/pkg/usr/share/applications/
	cat << "EOF" > $startdir/pkg/usr/share/applications/vbrfix.desktop
[Desktop Entry]
Categories=AudioVideo;AudioVideoEditing
Comment=A MP3 fixing tool
Comment[de]=Repariert MP3 Dateien
Encoding=UTF-8
Exec=vbrfix-gui
GenericName=Vbrfix
Icon=vbrfix
Name=Vbrfix
Name[de]=Vbrfix
Terminal=false
Type=Application
EOF
}