# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.

include ${TOPDIR}/rules.mk

PKG_NAME:=		mplayer
PKG_VERSION:=		1.0-32749
PKG_RELEASE:=		2
PKG_MD5SUM:=		aadc5d8cca503c8b18b3ed00b3a52cf5
PKG_DESCR:=		popular video player
PKG_SECTION:=		multimedia
PKG_DEPENDS:=		alsa-lib libjpeg libfaad2 libmad libncurses
PKG_DEPENDS+=		libogg libpng libpthread libvorbis
PKG_DEPENDS+=		libx11 libxau libxdmcp libxext libxv zlib
PKG_BUILDDEP:=		alsa-lib libmad libvorbis faad2 ncurses zlib
PKG_BUILDDEP+=		libX11 libXv libpng libXext
PKG_URL:=		http://www.mplayerhq.hu/
PKG_SITES:=		http://openadk.org/distfiles/

PKG_ARCH_DEPENDS:=	x86 x86_64 mips mipsel mips64 mips64el

PKG_FLAVOURS_MPLAYER:=	WITH_DIRECTFB
PKGFD_WITH_DIRECTFB:=	enable DirectFB video output support
PKGFS_WITH_DIRECTFB:=	directfb
PKGFB_WITH_DIRECTFB:=	DirectFB


include ${TOPDIR}/mk/package.mk

$(eval $(call PKG_template,MPLAYER,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))

CONFIG_STYLE:=		minimal
FAKE_FLAGS+=		INSTALLSTRIP=''

ifeq (${ADK_LINUX_MIPS64EL},y)
EXTRA_CFLAGS:=		-DARCH_MIPS64
endif
ifeq (${ADK_LINUX_MIPS64},y)
EXTRA_CFLAGS:=		-DARCH_MIPS64
endif

# Somehow this include path is missing here, although other
# applications build fine against DirectFB. There is also a
# related patch to allow configure to find out the DirectFB
# version number.
ifeq (${ADK_PACKAGE_MPLAYER_WITH_DIRECTFB},y)
TARGET_CPPFLAGS+=	-I${STAGING_TARGET_DIR}/usr/include/directfb
endif

ifeq (${ADK_TARGET_CPU_WITH_MMX},y)
CONFIGURE_CPU_OPTS:=	--enable-mmx
else
CONFIGURE_CPU_OPTS:=	--disable-mmx
endif
ifeq (${ADK_TARGET_CPU_WITH_MMXEXT},y)
CONFIGURE_CPU_OPTS+=	--enable-mmxext
else
CONFIGURE_CPU_OPTS+=	--disable-mmxext
endif
ifeq (${ADK_TARGET_CPU_WITH_SSE},y)
CONFIGURE_CPU_OPTS+=	--enable-sse
else
CONFIGURE_CPU_OPTS+=	--disable-sse
endif
ifeq (${ADK_TARGET_CPU_WITH_SSE2},y)
CONFIGURE_CPU_OPTS+=	--enable-sse2
else
CONFIGURE_CPU_OPTS+=	--disable-sse2
endif

ifeq ($(ADK_DEBUG),y)
CONFIGURE_DEBUG=	--enable-debug
endif

ifeq (${ADK_PACKAGE_MPLAYER_WITH_DIRECTFB},y)
CONFIGURE_DIRECTFB=	--enable-directfb
else
CONFIGURE_DIRECTFB=	--disable-directfb
endif

CONFIGURE_ARGS:=	--prefix=/usr \
			--enable-x11 \
			--confdir=/etc \
			--enable-cross-compile \
			--target=${ARCH}-linux \
			--cc='$(TARGET_CC)' \
			--host-cc=$(CC_FOR_BUILD) \
			--yasm='' \
			--disable-mencoder \
			--enable-fbdev \
			--enable-alsa \
			--enable-tv \
			--enable-v4l2 \
			--enable-png \
			--enable-jpeg \
			--enable-mad \
			--enable-libvorbis \
			--disable-ossaudio \
			--disable-vm \
			--disable-iconv \
			--disable-lirc \
			--disable-radio-v4l2 \
			--disable-faac \
			--disable-libdv \
			--disable-live \
			--disable-pvr \
			--disable-ftp \
			--disable-ivtv \
			--disable-dvdread-internal \
			--disable-libdvdcss-internal \
			--disable-freetype \
			--disable-mpg123 \
			--disable-tremor-internal \
			--disable-arts \
			--disable-esd \
			--disable-jack \
			--disable-openal \
			--disable-nas \
			--disable-sgiaudio \
			--disable-sunaudio \
			--disable-win32waveout \
			--disable-tga \
			--disable-pnm \
			--disable-md5sum \
			--disable-liblzo \
			--disable-sdl \
			--disable-xinerama \
			--disable-vidix \
			--disable-gl \
			--extra-cflags="${EXTRA_CFLAGS}" \
			${CONFIGURE_CPU_OPTS} \
			${CONFIGURE_DEBUG} \
			${CONFIGURE_DIRECTFB}

XAKE_FLAGS+=		AR="${TARGET_CROSS}ar" RANLIB="${TARGET_CROSS}ranlib"

post-install:
	${INSTALL_DIR} ${IDIR_MPLAYER}/usr/bin
	${CP} ${WRKINST}/usr/bin/mplayer ${IDIR_MPLAYER}/usr/bin

include ${TOPDIR}/mk/pkg-bottom.mk
