%global with_faac 1
%global with_vaapi 1
%global with_libvpx 1

# define with_ffmpeg 1
%global ffmpegver 2.8.5

%global pkgname mplayer
%global name	self-build-%{pkgname}
%global version 1.2
#% global svndate  20120525
%global release	3%{?svndate:.%svndate}%{?_dist_release}

%global source0path	MPlayer/releases/MPlayer-%{version}.tar.xz
%global source1url	http://ffmpeg.org/releases/ffmpeg-%{ffmpegver}.tar.bz2

Summary:	Package to automatically build %{pkgname} rpm package
Summary(ja): 	%{pkgname} の rpm パッケージを自動作成するパッケージ
Name:		%{name}
Version:	%{version}
Release: 	%{release}
Source0:	%{pkgname}-vl.spec
Source10:	mplayer-snapshot-vine.sh

Source11:	http://www.mplayerhq.hu/MPlayer/skins/Blue-1.11.tar.bz2
Source12:	http://www.mplayerhq.hu/MPlayer/skins/Blue-small-1.8.tar.bz2
Source13:	http://www.mplayerhq.hu/MPlayer/skins/standard-1.11.tar.bz2
Source14:	http://www.mplayerhq.hu/MPlayer/skins/OSX-Mod-1.1.tar.bz2

Source102:        %{pkgname}-1.1.1-config-vine.patch
Source108:        %{pkgname}-1.1.1-manlinks.patch
# Source114:        %{pkgname}-1.1.1-nodvdcss.patch
Source118:        %{pkgname}-1.1.1-ffmpeg.patch

License:	GPLv2+
Group:		Restricted Software

Obsoletes:      mplayer < %{version}-%{release}
Obsoletes:      self-build-mplayer < %{version}-%{release}

Requires(post):		self-build-setup >= 0.9.9
%{?svndate:Requires(post):		subversion}

# (build)requies of target package.
Requires(post):	SDL-devel
Requires(post):  aalib-devel
Requires(post):	alsa-lib-devel
Requires(post):	cdparanoia-devel
Requires(post):  desktop-file-utils
Requires(post): libdvdnav-devel
Requires(post):  enca-devel
Requires(post):	freetype2-devel >= 2.0.9
Requires(post):  fribidi-devel
Requires(post):  fontconfig-devel
Requires(post):	giflib-devel
Requires(post):	gtk2-devel
Requires(post):	mesa-libGL-devel
Requires(post):  libXinerama-devel
Requires(post):  libXScrnSaver-devel
Requires(post):  libXv-devel
Requires(post):  libXvMC-devel
Requires(post):  libXxf86dga-devel
Requires(post):  libXxf86vm-devel
Requires(post):  libass-devel
Requires(post):	libpng-devel
Requires(post):	libjpeg-devel
Requires(post):	libdvdread
Requires(post):  libmpcdec-devel >= 1.2.1
Requires(post):  librtmp-devel >= 2.3
Requires(post):  speex-devel >= 1.1
%{?with_vaapi:Requires(post):libva-devel}
Requires(post):  libvdpau-devel
Requires(post):	libvorbis-devel
%{?with_libvpx:Requires(post):  libvpx-devel >= 0.9.6}
Requires(post):  lzo-devel >= 2
Requires(post):  pulseaudio-lib-devel
Requires(post):  speex-devel >= 1.1
Requires(post):  twolame-devel
Requires(post):	xorg-x11-devel 
Requires(post):  yasm
Requires(post):	zlib-devel

Requires(post):		lame
Requires(post):   libmpeg2
Requires(post):		self-build-mplayer-codecs
##!!Requires(post):		self-build-libdvdcss
Requires(post):		self-build-faac
Requires(post):		self-build-faad2 >= 2.6.1
# Requires(post):		self-build-lame
Requires(post):		self-build-libdca
Requires(post):		self-build-libmad
Requires(post):	self-build-x264 >= 0.136
Requires(post):		self-build-xvidcore >= 0.9.2
# Requires(post):		self-build-libmpeg2
Requires:	TrueType-vlgothic
Requires:	mesa-libGL

BuildArch:	noarch
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

Packager:	munepi

%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.

MEncoder is a command line video encoder for advanced users that can
be built from the MPlayer source tree. Unofficial graphical frontends
exist but arenot included.

MPlayer supports most common formats, like DVDs, MPEG-1/2/4, etc, but
support for some newer codecs are not yet inpmlemented.
You should install mplayer-codecs package if you want to play videos
using those new codecs.


Additional function is automatically included if following 
packages are installed in advance.

samba-libsmbclient-devel: SMB file system support


[Note]
This package requires many other packages to compile
targetsoftware. So it consume more disk space than usual.
Also installation takes logner time because of compilation.
(This will take a few minutes to quarter or half of an hour,
depends on building environment)

[About self-build package]
For some kind of software, distributing of binary package
may viorate the patent or law. Therefore we chose self-build
packge, create binary package on your machine, for such kind
of softwares instead of distributing binary package.

Please obey the national law when you use the created binary
packages. And if you want to use the softwares using patented 
thechnology, it may be required to get a permission, make an 
agreement or purchas a license. Please consider it with your
purpose or way of use and take appropriate action.

%description -l ja
MPlayer は一般的なフォーマットの動画ならそのままですぐ再生できます。
またそれ以外のほとんど全てのフォーマットも外部 Codec を使用すること
で再生できます。
現在の MPlayer はコマンドラインから使うのが一番便利ですが、多くの操作
は字幕と同様に、オンスクリーン・ディスプレイ (OSD) によりその結果が画
面上で確認できます。
MPlayer には スキンを変更できる GUI も用意されていますし、また複数の
非公式なフロントエンドも利用できます。

MEncoder は上級者向けのコマンドラインの動画用エンコーダーです。
非公式な GUI フロントエンドもありますが、このパッケージには含まれて
いません。

MPlayer は何もしなくても DVD や MPEG-1/2/4 のように一般的なフォーマット
を再生できます。ただし一部の最新のフォーマットへの対応はまだ実装されて
いないので、そのような動画を再生したい場合は mplayer-codecs パッケージ
をインストールする必要があります。


このパッケージより前に以下の関連パッケージをインストールして
おくと、%{pkgname} が対応できる機能が自動的に追加されます。

samba-libsmbclient-devel: SMB ファイルシステムのサポート


[注意]
コンパイルに必要な多くの関連パッケージを要求するので通常より
ディスクの領域を多く消費します。
またインストール時にコンパイルを行うため、通常より時間がかか
る場合があります。(環境にもよりますが数分から数十分程度)

[self-build パッケージについて]
ソフトウェアによってはバイナリパッケージの配布が特許や法律に
違反する可能性があるものがあります。その為、このような問題が
懸念されるソフトウェアについてはバイナリパッケージを直接配布
せずに、ユーザの環境でバイナリを作成する self-build パッケー
ジという方法を採っています。

作成されたバイナリパッケージの利用にあたっては、各ソフトウェ
アのライセンス、および利用する国の各種法令に従ってください。
また特許に関連するソフトウェアの場合、利用許諾や契約、ライ
センスの購入などが必要となる場合がありますので、利用する目的
や形態に応じて各自で判断し適切な対応を取ってください。


%prep
[ "%{version}-%{release}" != $(rpm -q --queryformat "%%{version}-%%{release}\n" --specfile %{SOURCE0} | tail -1) ] && exit 1

%install
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__install} -d ${RPM_BUILD_ROOT}/%{_datadir}/%{name}
%{__install} -m 644 %{SOURCE0} ${RPM_BUILD_ROOT}/%{_datadir}/%{name}
%{__install} -m 644 %{SOURCE10} ${RPM_BUILD_ROOT}/%{_datadir}/%{name}
%{__install} -m 644 \
    %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} \
    ${RPM_BUILD_ROOT}/%{_datadir}/%{name}
%{__install} -m 644 \
    %{SOURCE102} %{SOURCE108} %{SOURCE118} \
    ${RPM_BUILD_ROOT}/%{_datadir}/%{name}


%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%posttrans
## official tarball
/usr/lib/rpm/self-build-rpm.sh %{name} %{pkgname}-vl.spec \
    http://www{,1,2,3,4,5,7,8,9}.mplayerhq.hu/%{source0path} \
    %{source1url} \
    1429000
exit 0

## svn checkout
# set locale
case ${LANG} in
    ja*)LOCALE=ja ;;
    *) LOCALE=C ;;
esac

GetSrc_C(){
    echo -n "     "
    echo "Download source file with Subversion..."
}

GetSrc_ja(){
    echo -n "     "
    echo "Subversion を用いてソースファイルをダウンロードしています..."
}

GetSrc_${LOCALE}

# svn checkout
. /etc/self-build.conf
(cd ${TEMP_DIR}
su ${BUILD_USER} -c "/bin/bash %{_datadir}/%{name}/%{pkgname}-snapshot-vine.sh >/dev/null 2>&1 || exit 1"
%__mv %{pkgname}-export-%{svndate}.tar.xz %{_datadir}/%{name}/ || exit 1
)

/usr/lib/rpm/self-build-rpm.sh %{name} %{pkgname}-vl.spec \
    http://www{,1,2,3,4,5,7,8,9}.mplayerhq.hu/%{source1path} 2261000
    

%files
%defattr(-,root,root)
%{_datadir}/%{name}

%changelog
* Wed Oct 09 2019 Toshiaki Ara <ara_t@384.jp> 1.2-3
- change BR: self-build-{lame,libmpeg2} to {lame,a52dec}-devel

* Sun Jul 03 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.2-2
- rebuild with libcdio-0.93

* Sat Jan 23 2016 Munehiro Yamamoto <munepi@vinelinux.org> 1.2-1
- new upstream release

* Sat Jul 11 2015 Munehiro Yamamoto <munepi@vinelinux.org> 1.1.1-4
- rebuilt

* Fri Jan  2 2015 Munehiro Yamamoto <munepi@vinelinux.org> 1.1.1-3
- rebuilt with ffmpeg-0.11.5

* Mon Oct  7 2013 Munehiro Yamamoto <munepi@vinelinux.org> 1.1.1-2
- remove some obsolete comments (mplayer-vl.spec)

* Sun Sep 29 2013 Munehiro Yamamoto <munepi@vinelinux.org> 1.1.1-1
- updated to 1.1.1
- build with new x264 (ABI 0.136) and ffmpeg 0.11.4 (libav 0.8.2 as of 2012-09-19)

* Sun Jan 20 2013 Munehiro Yamamoto <munepi@vinelinux.org> 1.1-2
- rebuilt with new x264 (ABI 0.129) and ffmpeg 0.11.2 (libav 0.8.2)

* Wed Jun 13 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.1-1
- updated to 1.1
  - built with ffmpeg-0.11.1
- added some skins

* Sat May 26 2012 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-47.20120525
- updated snapshot 20120525 with ffmpeg 0.11
- dropped Requires(post): self-build-libdvdcss

* Sun Dec 18 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-45.20111217
- updated snapshot 20111217 (with ffmpeg 0.9)

* Wed Nov  2 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-44.rc4
- s/self-build-libdvdnav/libdvdnav/

* Fri Oct  7 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-43.rc4
- updated %%source1path
  - update to 1.8

* Sun Jun 19 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-42.rc4
- dropped Requires(post): esound-devel

* Sat Mar 26 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-41.rc4
- new upstream release
  - ready for Vine Linux 6
  - revived support for Vine Linux 5
- added Requires(post): 
  - libass-devel
  - librtmp-devel >= 2.3
  - speex-devel >= 1.1

* Tue Feb 01 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-40.20100709
- added BuildRequires:
  - aalib-devel
  - enca-devel
  - lzo-devel
  - speex-devel

* Sun Jul 25 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-39.20100709
- updated fixed %{name}-config.patch
  - applied %{name}-config-20100709-vine.patch

* Sat Jul 17 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-38.20100709
- unpacked source archives

* Sat Jul 10 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-37.20100709
- updated source snapshot 20100709
- renamed %%Source10 to mplayer-snapshot-vine.sh
- added Requires(post): libva-devel, libvpx-devel >= 0.9.1
- dropped vl4 support
- updated %%description

* Sat Jun 26 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-36.20100621
- updated source snapshot 20100621
- added Requires(post): libXinerama-devel
- dropped vl4 support

* Fri Apr 02 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-33.20100401
- updated source snapshot 20100401

* Thu Mar 18 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-31.20100317
- updated source snapshot 20100317
- renamed %%{Source0} to mplayer-vl.spec

* Wed Feb 17 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-30.20100216
- updated source snapshot 20100216
- dropped obsolete patches
- added Requires(post): libvdpau-devel libXScrnSaver-devel

* Sat Dec 26 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-28.20091031
- update mplayer-config-20091215-vine.patch
- update mplayer-20091215-x86_32-compile.patch

* Sun Nov 01 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-27.20091031
- source snapshot 20091031
  - updated mplayer-20091031-x86_32-compile.patch

* Sun Oct 04 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-26.20091003
- source snapshot 20091003

* Sun Sep 13 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-25.20090905
- added some if conditions for "vl6"

* Sun Sep 06 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-24.20090905
- source snapshot 20090905
- added settings for vl6

* Sat Aug 22 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.0-23.20090821
- source snapshot 20090821
- replaced BR: libungif-devel with BR: giflib-devel
- mentioned VDPAU support in %%description

* Thu Jul 23 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-22.20090722
- source snapshot 20090722

* Fri Jul 03 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-21.20090702
- source snapshot 20090702
- check version between original spec and self-build spec in %%prep

* Fri Jun 12 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-20.20090611
- source snapshot 20090611

* Sun Jun 07 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-19.20090522
- added Requires: TrueType-vlgothic

* Sat May 23 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-18.20090522
- source snapshot 20090522
  - build with x264 >= 0.0.0-9.20090522
  - updated mplayer-20090502-nodvdcss.patch
- avoided to execute self-build-rpm.sh on RPM transaction
  - moved %%post actions to %%posttrans

* Thu May 07 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-17.20090502
- added PreReq: self-build-mplayer-codecs

* Tue May 05 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-16.20090502
- added BuildArch: noarch
- source snapshot 20090502
- updated mplayer-20090503-x86_32-compile.patch
- updated mplayer-20090502-nodvdcss.patch

* Thu Apr 09 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-15.20090327
- included source archives: 
  - mplayer-export-20090327.tar.bz2
  - Blue-1.7.tar.bz2
- applied mplayer-config-vine.patch

* Sat Mar 28 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-14.20090327
- source snapshot 20090327
- updated mplayer-20090327-x86_32-compile.patch
- updated mplayer-20090325-nodvdcss.patch
- dropped gmplayer-about-vine.patch

* Sun Feb 08 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-10.20090206
- source snapshot 20090206
- dropped mplayer-man-zh_CN.patch
- updated mplayer-20090206-nodvdcss.patch
- changed to PreReq:  self-build-faad2 from faad2-devel
- added PreReq:  self-build-libmad

* Sun Feb 01 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-9.20090131
- source snapshot 20090131
- fixed %%files section

* Thu Jan 29 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-8.20090122
- fixed %%post: added rm -f "$pwd"/%{pkgname}-export-%{svndate}.tar.bz2

* Sun Jan 25 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-7.20090122
- source snapshot
- update mplayer-nodvdcss.patch: mplayer-20090122-nodvdcss.patch
- added PreReq:	
  - faad2-devel
  - libmpcdec-devel
  - twolame-devel
  - yasm
  - self-build-libdvdcss
  - self-build-libdvdnav
  - self-build-faac
  - self-build-lame
  - self-build-libdca
  - self-build-x264 >= 0.0.0-4.20090110
  - self-build-xvidcore >= 0.9.2
- move %%define source0Exists() from %%post section to header
- fixed %%post section: clean up source archive

* Sat Jan 10 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-6.20090109
- source snapshot
- added --disable-faac-lavc --disable-mp3lame-lavc --disable-x264-lavc 
  --disable-faad-internal in configure options
- dropped gmplayer-add-flv-extension.patch

* Sun Dec 14 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-5.20081001
- source snapshot
- fixed License
- added some patches from RPM Fusion
- updated gmplayer-about-vine.patch for 20081001 snapshot
- added BuildRequires:	libdvdread
- added BuildRequires:	self-build-libdvdcss self-build-libdvdnav
- added --disable-dvdread-internal --enable-dvdread --enable-dvdnav
  in configure options
#- applied mplayer-avoid-Warning_MVs_not_available.patch for VineSeed
- added PreReq: subversion

* Mon Nov 17 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-4.rc2
- fixed License
- added some devel packages to support OpenGL

* Sun Nov 02 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-3.rc2
- spec in utf8
- fix sybolic link of subfont for vl5

* Wed May 07 2008 Atsushi SHICHI <ats777@gmail.com> 1.0-2.rc2vl4
- add "Source105: CVE-2008-1558.patch".

* Fri May 02 2008 Atsushi SHICHI <ats777@gmail.com> 1.0-1.rc2vl4
- build with new versioning policy.
- add "Source200: gmplayer-about-vine.patch".
- add "Source201: gmplayer-add-flv-extension.patch".
- fix <BTS:VineLinux:603>.
  - add ">= 0.7-1vl4" to "PreReq: self-build-setup".
  - add mirror URLs to self-build-rpm.sh.

* Sun Feb 17 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.0-0vl0.3rc2
- add four official security patches (CVE-2008-0485, CVE-2008-0486, 
  CVE-2008-0629, CVE-2008-0630)
- add mplayer-1.0rc2-20080211-stream_cddb.patch

* Tue Feb 12 2008 Kazutaka HARADA <Kazutaka HARADA> 1.0-0vl0.2rc2
- change source download URL. <BTS:VineLinux:603>

* Sun Jan 27 2008 Kazutaka HARADA <Kazutaka HARADA> 1.0-0vl0.1rc2
- fix CONFDIR for make install in mplayer.spec. <BTS:wishes:33>

* Fri Jan 18 2008 Kazutaka HARADA <Kazutaka HARADA> 1.0-0vl0.0rc2
- initial build for Vine Linux.
