#!/usr/bin/make -f
# debian/rules for the VLC media player - uses debhelper.
# based on Joey Hess's one.
# Kludged for ipkg

VERSION=0.7.2-test1

export VIDDIR="usr/share/vlc"
export PIXDIR="usr/share/pixmaps"
export DESTDIR=${HOME}/arm-linux
export PKGDIR=${HOME}/packages/zaurus-vlc-$(VERSION)
export QTDIR=${HOME}/arm-linux/opt/QtPalmtop

# Compilation options
export CONFIG_FLAGS="--enable-release --prefix=/usr \
	--disable-plugins \
	--disable-gtk \
	--disable-gtk2 \
	--disable-gnome \
	--disable-gnome2 \
	--disable-qt \
	--disable-kde \
	--disable-xosd \
	--disable-ogg \
	--disable-tarkin \
	--disable-tremor \
	--disable-theorea \
	--enable-qte \
	--disable-x11 \
	--disable-xvideo \
	--enable-dummy \
	--enable-v4l \
	--enable-sout \
	--enable-fb \
	--disable-sdl \
	--enable-oss \
	--disable-alsa \
	--disable-dvd \
	--disable-dvdread \
	--disable-vcd \
	--disable-maxosx \
	--disable-freetype \
	--enable-a52 \
	--enable-faad2 \
	--enable-flac \
	--enable-libmpeg2 \
	--enable-libdvbpsi \
	--disable-mkv \
	--enable-mad \
	--enable-ffmpeg \
	--disable-pda \
	--with-tuning=strongarm1100 \
	--with-libiconv-prefix=${HOME}/arm-linux/usr \
	--with-mad-tree=${HOME}/arm-linux/vlc-${VERSION}/libmad-0.15.0b \
	--with-a52-tree=${HOME}/arm-linux/vlc-${VERSION}/a52dec-0.7.4 \
	--with-faad2-tree=${HOME}/arm-linux/vlc-${VERSION}/faad2-20030612 \
	--with-flac-tree=${HOME}/arm-linux/vlc-${VERSION}/flac-1.1.0 \
	--with-libmpeg2-tree=${HOME}/arm-linux/vlc-${VERSION}/mpeg2dec-20030612 \
	--with-libdvbpsi-tree=${HOME}/arm-linux/vlc-${VERSION}/libdvbpsi-0.1.2 \
	--with-qte=${QTDIR} \
	--with-ffmpeg-tree=${HOME}/arm-linux/vlc-${VERSION}/ffmpeg-20030622"

build: build-stamp
config:
	./configure --mandir=$${prefix}/share/man \
		--infodir=$${prefix}/share/info \
		--host=arm-linux \
		--target=arm-linux \
		$(shell echo $(CONFIG_FLAGS)) \
	LDFLAGS="-L${HOME}/arm-linux/lib \
		 -L${HOME}/arm-linux/opt/QtPalmtop/lib \
		 -L${HOME}/arm-linux/vlc-${VERSION}/libid3tag-0.15.0b" \
	CPPFLAGS="-I${HOME}/arm-linux/opt/QtPalmtop/include \
		  -I${HOME}/arm-linux/vlc-${VERSION}/libid3tag-0.15.0b"

build-stamp:
# This is ugly -- I know
#	patch -p0 < ipkg/patch

	$(MAKE)

clean:
	-$(MAKE) distclean

install: build
	rm -fr ${PKGDIR}/
	mkdir -p ${PKGDIR}/CONTROL
	mkdir -p $(PKGDIR)/usr/bin
	mkdir -p ${PKGDIR}/usr/share/vlc
	mkdir -p ${PKGDIR}/usr/lib/menu
	mkdir -p ${PKGDIR}/usr/lib/vlc
	mkdir -p ${PKGDIR}/opt/QtPalmtop/sharp/bin
	mkdir -p ${PKGDIR}/opt/QtPalmtop/apps/Applications
	$(STRIP) vlc
	cp ipkg/control.zaurus $(PKGDIR)/CONTROL/control
	cp ipkg/postinst.zaurus ${PKGDIR}/CONTROL/postinst
	cp ipkg/postrm.zaurus ${PKGDIR}/CONTROL/postrm
	cp share/vlc48x48.png  ${PKGDIR}/usr/share/vlc
	cp vlc $(PKGDIR)/usr/bin
	cp ipkg/vlc.zaurus ${PKGDIR}/opt/QtPalmtop/sharp/bin/zaurus-vlc
	cp ipkg/vlc.zaurus ${PKGDIR}/opt/QtPalmtop/sharp/bin/opie-vlc
	cp ipkg/vlc.desktop ${PKGDIR}/opt/QtPalmtop/sharp/apps/Applications

install-plugins: install
	find ./modules/ -name *.so -print -depth | xargs cp $1 ${PKGDIR}/usr/lib/vlc
	$(STRIP) ${PKGDIR}/usr/lib/vlc

.PHONY: build clean install install-plugins

