#% global svndate  20111217

%define pkgname gpac
%define name	self-build-%{pkgname}
%define version 0.5.2
%define release	2%{?svndate:.svn%svndate}%{?_dist_release}

%define sourceurl0	https://github.com/gpac/gpac/archive/v%{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

#Source9:     gpac-snapshot-vine.sh

Source102:      gpac-0.4.6-amr.patch

License:	LGPLv2+
Group:		Restricted Software

Obsoletes:      %{pkgname} < %{version}, %{pkgname}-libs < %{version}
Obsoletes:      %{pkgname}-devel < %{version}
Obsoletes:      %{pkgname}-devel-static < %{version}
Obsoletes:      %{name} < %{version}-%{release}

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

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
%{?_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 %{SOURCE102} \
    ${RPM_BUILD_ROOT}/%{_datadir}/%{name}

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

%posttrans
# ## 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}-%{svndate}.tar.bz2 %{_datadir}/%{name}/ || exit 1
# )

/usr/lib/rpm/self-build-rpm.sh %{name} %{pkgname}-vl.spec %{sourceurl0} 57000
/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
* Sat Jul 11 2015 Munehiro Yamamoto <munepi@vinelinux.org> 0.5.2-2
- rebuilt

* Mon Mar 09 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.2-1
- new upstream release
- remove Source101 (gpac-0.5.0-libdir.patch)

* Fri Jan  2 2015 Munehiro Yamamoto <munepi@vinelinux.org> 0.5.0-5
- rebuilt

* Tue Jun 17 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.0-4
- remove Requires(post): xmlrpc-epi-devel

* Wed Oct  2 2013 Munehiro Yamamoto <munepi@vinelinux.org> 0.5.0-3
- added Obsoletes: %{name} < %{version}-%{release}, 
  Obsoletes: %{pkgname} < %{version} and so on.

* Sun Sep 29 2013 Munehiro Yamamoto <munepi@vinelinux.org> 0.5.0-2
- rebuild

* Sat Jan 19 2013 Munehiro Yamamoto <munepi@vinelinux.org> 0.5.0-1
- new upstream release

* Sat May 26 2012 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.6-2.svn20111217
- rebuild

* Sun Dec 18 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.4.6-1.svn20111217
- update snapshot svn20111217
- removed upstreamed/obsolated patches
- added Requires(post): subversion

* 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
