Name:		libvpx
Version:	1.1.0
Release:	1%{?_dist_release}
Summary:        The VP8 Codec SDK
Summary(ja):	VP8 コーデックソフトウェア開発キット

Group:		System Environment/Libraries
License:	BSD
URL:		http://www.webmproject.org/tools/vp8-sdk/
Source0:        http://webm.googlecode.com/files/%{name}-v%{version}.tar.bz2
Source2:        libvpx.ver

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root
%ifarch %{ix86} x86_64
BuildRequires:  yasm
%endif

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

%description
The WebM VP8 Codec SDK allows you to integrate your applications with
the VP8 video codec, a high quality, royalty free, open source codec 
deployed on millions of computers and devices worldwide.

%description -l ja
WebM VP8 コーデック SDK は、VP8 ビデオコーデックをアプリケーションに
統合するための開発きっとです。VP8ビデオコーデックは高品質でロイヤリティ
フリーかつオープンソースのコーデックで、世界中の多くのコンピュータや
デバイスで利用されています。

%package devel
Summary:	Development files for %{name}
Summary(ja):	%{name} の開発ファイル
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}

%description devel
The %{name}-devel package contains development files for
%{name}.

%description devel -l ja
%{name}-devel パッケージは %{name} の開発用ファイルを含んでいます。

%package utils
Summary:	example programs for %{name}
Summary(ja):	%{name} のサンプルプログラム
Group:		Applications/Multimedia
Requires:	%{name} = %{version}-%{release}

%description utils
The %{name}-utils package contains example programs that
use %{name}.

%description utils -l ja
%{name}-utils パッケージは、%{name} を使用したサンプル
アプリケーションを含んでいます。


%prep
%setup -q -n %{name}-v%{version}

%build

%ifarch %{ix86}
%global vpxtarget x86-linux-gcc
%else
%ifarch x86_64
%global vpxtarget x86_64-linux-gcc
%else
%global vpxtarget generic-gnu
%endif
%endif

%if "%{vpxtarget}" == "generic-gnu"
%global generic_target 1
%else
%global generic_target 0
%endif

./configure \
 --target=%{vpxtarget} \
 --enable-pic \
%if ! %{generic_target}
 --enable-shared \
%endif
 --prefix=%{_prefix} \
 --libdir=%{_libdir} \
 --disable-install-docs \
 --disable-install-srcs

# fix up optflags
sed -i "s|-O3|%{optflags}|g" libs-%{vpxtarget}.mk
sed -i "s|-O3|%{optflags}|g" examples-%{vpxtarget}.mk
sed -i "s|-O3|%{optflags}|g" docs-%{vpxtarget}.mk

%{__make} %{?_smp_mflags} verbose=true target=libs

%if %{generic_target}
mkdir -p tmp
pushd tmp
ar x ../libvpx_g.a
popd
gcc -shared -fPIC -pthread -lm \
    -Wl,--no-undefined \
    -Wl,-soname,libvpx.so.0 \
    -Wl,--version-script,%{SOURCE2} \
    -Wl,-z,noexecstack \
    -o libvpx.so.%{version} tmp/*.o
rm -rf tmp
%endif

ln -sf libvpx.so.%{version} libvpx.so

mv libvpx.a libvpx.a.tmp
mv libvpx_g.a libvpx_g.a.tmp

make %{?_smp_mflags} verbose=true target=examples

mv libvpx.a.tmp libvpx.a
mv libvpx_g.a.tmp libvpx_g.a

%install
%{__rm} -rf $RPM_BUILD_ROOT
%{__make} DIST_DIR=$RPM_BUILD_ROOT%{_prefix} dist

%if %{generic_target}
install -p libvpx.so.%{version} %{buildroot}%{_libdir}
pushd %{buildroot}%{_libdir}
ln -sf libvpx.so.%{version} libvpx.so
ln -sf libvpx.so.%{version} libvpx.so.1
ln -sf libvpx.so.%{version} libvpx.so.1.1
popd
%endif

pushd %{buildroot}
# Rename a few examples
mv usr/bin/postproc usr/bin/vp8_postproc
mv usr/bin/simple_decoder usr/bin/vp8_simple_decoder
mv usr/bin/simple_encoder usr/bin/vp8_simple_encoder
mv usr/bin/twopass_encoder usr/bin/vp8_twopass_encoder
# Fix the binary permissions
chmod 755 usr/bin/*
popd

rm -f $RPM_BUILD_ROOT%{_prefix}/md5sums.txt
rm -f $RPM_BUILD_ROOT%{_libdir}/lib*.a
rm -f $RPM_BUILD_ROOT%{_prefix}/{CHANGELOG,README}
rm -rf $RPM_BUILD_ROOT%{_prefix}/build


%clean
rm -rf $RPM_BUILD_ROOT


%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%defattr(-,root,root,-)
%doc AUTHORS LICENSE README CHANGELOG
%{_libdir}/*.so.*

%files devel
%defattr(-,root,root,-)
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%{_includedir}/vpx/*.h

%files utils
%defattr(-,root,root,-)
%{_bindir}/*


%changelog
* Mon Oct 08 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.1.0-1
- new upstream release
- remove Patch0 (libvpx-0.9.0-no-explicit-dep-on-static-lib.patch)
- remove Source1 (libvpx.pc)

* Sun Oct 16 2011 Munehiro Yamamoto <munepi@vinelinux.org> 0.9.6-1
- new upstream release

* Mon Dec 27 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.5-1
- new upstream release

* Sun Sep 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.9.1-2
- rebuild with rpm-4.8.1 for pkg-config file

* Sun Jul 11 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.1-1
- new upstream release

* Mon May 24 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.0-1
- initial build for Vine Linux