# $Id: Portfile,v 1.18 2006/05/25 06:54:59 blb Exp $

PortSystem			1.0
name				MPlayer
version				cvs-20060408
epoch				20060408
categories			multimedia
maintainers			darwinports@opendarwin.org
description			The Unix movie player
long_description \
	MPlayer can play most standard video formats out of the box and almost \
	all others with the help of external codecs.  MPlayer currently works \
	best from the command line, but visual feedback for many functions is \
	available from its onscreen status display (OSD), which is also used for \
	displaying subtitles. MPlayer also has a GUI with skin support and \
	several unofficial alternative graphical frontends are available.

platforms			darwin

homepage			http://www.mplayerhq.hu/
master_sites		http://www.opendarwin.org/~blb/ \
					http://www1.mplayerhq.hu/MPlayer/releases/codecs/:codecs \
					http://www2.mplayerhq.hu/MPlayer/releases/codecs/:codecs
use_bzip2			yes

checksums			${distname}${extract.suffix} \
						md5 d79ce79b767ca858a3cb555c41daa255 \
						sha1 91ec82c5bbd0aed6e68256891bdf84af5d7d53da \
						rmd160 cd62009e46a7ed58074cac9af472e22270f5d0e7

depends_lib			port:libpng port:jpeg port:lzo port:libvorbis \
					port:libmad port:lame

configure.args		--with-extraincdir=${prefix}/include \
					--with-extralibdir=${prefix}/lib \
					--datadir=${prefix}/share/${name} \
					--confdir=${prefix}/etc/${name} \
					--mandir=${prefix}/share/man \
					--enable-inet6 --enable-png --enable-jpeg \
					--enable-liblzo --enable-vorbis --enable-mad \
					--enable-mencoder \
					--disable-sdl --disable-x11 --disable-freetype \
					--disable-fontconfig --disable-gif --disable-arts \
					--disable-esd --disable-fribidi --disable-theora \
					--disable-xvid --disable-x264 --disable-cdparanoia \
					--disable-libcdio

post-destroot {
	file mkdir ${destroot}${prefix}/share/doc/${name}
	eval file copy [glob ${worksrcpath}/DOCS/*] \
		${destroot}${prefix}/share/doc/${name}
}

variant real {
	global mplayerRP8 mplayerRP9 mplayerRP8file mplayerRP9file
	set mplayerRP8			rp8codecs-ppc-20050115
	set mplayerRP9			rp9codecs-macosx-20041107.pkg
	set mplayerRP8file		${mplayerRP8}.tar.bz2
	set mplayerRP9file		${mplayerRP9}.zip
	distfiles-append		${mplayerRP8file}:codecs ${mplayerRP9file}:codecs
	checksums-append		${mplayerRP8file} \
								md5 4cc9a6270f9aa834b4fef49d71b9faf9 \
								sha1 12ce04765bdf96e6ad386de1ef637b471d947796 \
								rmd160 8d3feedca9ef50a25c5b7560dd5bca9184c1dd01 \
							${mplayerRP9file} \
								md5 788cf4940280fd787c0a2141d88ce3c7 \
								sha1 18abd6d0424c4682815a13b34695d37d2fda2a73 \
								rmd160 c6f49012633bbb84ffa405b8881dc90605d26fc6

	extract.only			${distname}${extract.suffix}

	depends_lib-append		bin:unzip:unzip

	post-extract {
		cd ${worksrcpath}
		system "bunzip2 -c ${distpath}/${mplayerRP8file} | tar xf -"
		system "unzip -q ${distpath}/${mplayerRP9file}"
	}

	configure.args-append	--with-reallibdir=${prefix}/share/${name}/codecs

	post-destroot {
		xinstall -m 755 -d ${destroot}${prefix}/share/${name}/codecs
		eval file copy [glob ${worksrcpath}/${mplayerRP8}/*] \
			${destroot}${prefix}/share/${name}/codecs
		cd ${destroot}${prefix}/share/${name}/codecs
		system "gunzip -c \
			${worksrcpath}/${mplayerRP9}/Contents/Archive.pax.gz | pax -r"
	}
}

variant x11 requires freetype requires fontconfig {
	depends_lib-append		lib:libX11.6:XFree86
	configure.args-delete	--disable-x11
	configure.args-append	--enable-x11
	configure.env-append	PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:${x11prefix}/lib/pkgconfig
}

variant sdl {
	depends_lib-append		port:libsdl
	configure.args-delete	--disable-sdl
	configure.args-append	--enable-sdl
}

# configure doesn't fully build up necessary flags when --enable-fontconfig
# is used, so use autodetect instead
variant fontconfig {
	depends_lib-append		port:fontconfig
	configure.args-delete	--disable-fontconfig
}

variant freetype {
	depends_lib-append		port:freetype
	configure.args-delete	--disable-freetype
	configure.args-append	--enable-freetype
}

# configure doesn't pick up the right -l flag if we --enable-gif, so
# we let it autodetect this
variant gif {
	depends_lib-append		port:libungif
	configure.args-delete	--disable-gif
}

variant arts {
	depends_lib-append		port:arts
	configure.args-delete	--disable-arts
	configure.args-append	--enable-arts
}

variant esd {
	depends_lib-append		port:esound
	configure.args-delete	--disable-esd
	configure.args-append	--enable-esd
}

variant fribidi {
	depends_lib-append		port:fribidi
	configure.args-delete	--disable-fribidi
	configure.args-append	--enable-fribidi
}

variant theora {
	depends_lib-append		port:libtheora
	configure.args-delete	--disable-theora
	configure.args-append	--enable-theora
}

# Install all possible languages for man pages
variant man_all_lang {
	configure.args-append --language=all
}

# GUI variant needs additional download of a skin
#variant gui {
#	depends_lib-append		port:gtk1
#	configure.args-append	--enable-gui
#}

platform macosx {
	configure.args-append	--enable-macosx --enable-macosx-finder-support \
							--enable-macosx-bundle --enable-qtx
}

platform darwin {
	patchfiles-append	patch-Makefile
	build.env			LD=cc
}

platform darwin 8 {
	# Need to force use of c++ for linking when Xcode 2.2 is used since some
	# bits of libstdc++ are needed during linking
	build.env			LD=c++
}

