%define pkgname gpac
%define name	self-build-%{pkgname}
%define version 0.4.5
%define release	11%{?_dist_release}

%define sourceurl0	http://prdownloads.sourceforge.net/gpac/%{pkgname}-%{version}.tar.gz
#% define sourceurl0	http://dl.sourceforge.net/sourceforge/gpac/%{pkgname}-%{version}.tar.gz

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

Source100:      gpac-0.4.5-makefix.patch
Source101:      gpac-0.4.5-soname.patch
Source102:      gpac-0.4.5-amr.patch
Source103:      gpac-0.4.5-lib64.patch
Source104:      gpac-0.4.5-system_openjpeg.patch
Source106:      gpac-0.4.5-shared_sggen.patch
Source107:      gpac-0.4.5-libxml2.patch
Source108:      gpac-ppc64.patch
Source109:      gpac-0.4.5-ffmpeg.patch

License:	LGPLv2+
Group:		Restricted Software

Requires(post):		self-build-setup >= 0.9.9

Requires(post):  ImageMagick
Requires(post):  SDL-devel
Requires(post):  librsvg2-devel >= 2.5.0
Requires(post):  libGLU-devel
Requires(post):  freeglut-devel
Requires(post):  freetype2-devel >= 2.1.4
Requires(post):  libjpeg-devel
Requires(post):  libpng-devel >= 1.2.5
Requires(post):  libxml2-devel
Requires(post):  openssl-devel
Requires(post):  openjpeg-devel
Requires(post):  pulseaudio-libs-devel
Requires(post):  zlib-devel
Requires(post):  libogg-devel libvorbis-devel libtheora-devel
Requires(post):  libXt-devel
Requires(post):  libXpm-devel
Requires(post):  libXv-devel
#Requires(post):  wxGTK-devel
Requires(post):  xmlrpc-epi-devel
%{?_with_mozilla:Requires(post): gecko-devel}
#Requires(post):  doxygen
Requires(post):  desktop-file-utils
%{?_with_amr:Requires(post): amrnb-devel amrwb-devel}
Requires(post):  self-build-a52dec
Requires(post):  self-build-faad2
Requires(post):  self-build-libmad
Requires(post):  self-build-xvidcore >= 1.0.0
##Requires(post):  self-build-ffmpeg

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

Packager:	munepi

%description
GPAC is a multimedia framework based on the MPEG-4 Systems standard developed
from scratch in ANSI C.  The original development goal is to provide a clean,
small and flexible alternative to the MPEG-4 Systems reference software.

GPAC features the integration of recent multimedia standards (SVG/SMIL, VRML,
X3D, SWF, 3GPP(2) tools and more) into a single framework. GPAC also features
MPEG-4 Systems encoders/multiplexers, publishing tools for content distribution
for MP4 and 3GPP(2) files and many tools for scene descriptions
(MPEG4 <-> VRML <-> X3D converters, SWF -> MPEG-4, etc).


If you install this package, it automaticaly downloads source
code ,compile it, and create rpm packages of %{pkgname}-%{version}.
And the created rpm packages are automatically installed
if installation is executed by apt-get command or synaptic
package manager.

[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
GPAC は ANSI C でスクラッチから開発されている MPEG-4 システムの標準に基づいた
マルチメディアフレームワークです。
当初の開発目標には、MPEG-4 システムリファレンスソフトウェアに
簡潔で小さく柔軟な代替を提供することです。

GPAC features the integration of recent multimedia standards (SVG/SMIL, VRML,
X3D, SWF, 3GPP(2) tools and more) into a single framework. GPAC also features
MPEG-4 Systems encoders/multiplexers, publishing tools for content distribution
for MP4 and 3GPP(2) files and many tools for scene descriptions
(MPEG4 <-> VRML <-> X3D converters, SWF -> MPEG-4, etc).


このパッケージをインストールすると、自動的にソースコードを
ダウンロードしてコンパイルし、%{pkgname}-%{version} の rpm
パッケージを作成します。
また apt-get コマンドや synaptic パッケージマネージャから実行
した場合は、作成された rpm パッケージのインストールも自動的に
行います。

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

[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 \
    %{SOURCE100} %{SOURCE101} %{SOURCE102} %{SOURCE103} %{SOURCE104} \
    %{SOURCE106} %{SOURCE107} %{SOURCE108} %{SOURCE109} \
    ${RPM_BUILD_ROOT}/%{_datadir}/%{name}

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

%posttrans
/usr/lib/rpm/self-build-rpm.sh %{name} %{pkgname}-vl.spec "%{sourceurl0}" 169000
/usr/lib/rpm/pre-allocate-rpm.sh %{pkgname}-%{version}-%{release} \
                                 %{pkgname}-libs-%{version}-%{release} \
                                 %{pkgname}-devel-%{version}-%{release} \
                                 %{pkgname}-devel-static-%{version}-%{release}

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

%changelog
* Mon Apr 18 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.5-11
- rebuilt with internal openjpeg

* Sat Mar 26 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.5-10
- rebuild

* Sat Jun 26 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.5-9
- dropped Requires(post):  doxygen

* Sat Mar 20 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.5-8
- renamed %%{Source0} to gpac-vl.spec

* Thu Feb 18 2010 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.5-7
- rebuild

* Sun Jun 07 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4.5-6
- changed from http://prdownloads.sourceforge.net in sourceurl0
- added devel-static subpackage in gpac.spec
- added gpac-0.4.5-mozjis-vine.patch 
  (do not install in /usr/share/self-build-gpac)

* Tue May 26 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4.5-5
- avoided to execute self-build-rpm.sh on RPM transaction
  - moved %%post actions to %%posttrans

* Thu May 14 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4.5-4
- changed from http://prdownloads.sourceforge.net to http://dl.sourceforge.net
  in sourceurl0
- added BuildArch: noarch

* Thu Mar 26 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4.5-3
- applied gpac-0.4.5-ffmpeg.patch (RPM Fusion #454)

* Thu Mar 12 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4.5-2
- dropped PreReq: self-build-ffmpeg
  - rebuilt with ffmpeg-devel by self-build-ffmpeg

* Sun Mar 01 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.4.5-1
- initial bulid