%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

Summary: 	A voice compression format/codec
Summary(ja): 	音声圧縮フォーマット/コーデック
Name: 		speex
Version: 	1.2
Release:	0.rc1.3%{?_dist_release}
License: 	BSD
Group: 		System Environment/Libraries
URL: 		http://www.speex.org/
Source0: 	http://www.speex.org/download/%{name}-%{version}rc1.tar.gz

# Security fix
Patch100: speex-1.2-CVE-2008-1686.diff

BuildRoot: 	%{_tmppath}/%{name}-%{version}-root
BuildRequires:	libogg-devel

%description
Speex is a patent-free compression format designed especially for
speech. It is specialized for voice communications at low bit-rates in
the 2-45 kbps range. Possible applications include Voice over IP
(VoIP), Internet audio streaming, audio books, and archiving of speech
data (e.g. voice mail).

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

%description devel
Speex is a patent-free compression format designed especially for
speech. This package contains development files for %{name}

# compat32
%package -n compat32-%{name}
Summary: 	A voice compression format/codec
Summary(ja): 	音声圧縮フォーマット/コーデック
Group: 		System Environment/Libraries

%description -n compat32-%{name}
Speex is a patent-free compression format designed especially for
speech. It is specialized for voice communications at low bit-rates in
the 2-45 kbps range. Possible applications include Voice over IP
(VoIP), Internet audio streaming, audio books, and archiving of speech
data (e.g. voice mail).

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

%description -n compat32-%{name}-devel
Speex is a patent-free compression format designed especially for
speech. This package contains development files for %{name}

%prep
%setup -q -n %{name}-%{version}rc1
%patch100 -p1 -b .CVE-2008-1686
chmod a-x README

%build
%configure --enable-static --with-ogg-libraries=%{_libdir}
# Remove rpath from speexenc and speexdec
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
rm -f $RPM_BUILD_ROOT%{_docdir}/speex/manual.pdf

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%post -n compat32-%{name} -p /sbin/ldconfig
%postun -n compat32-%{name} -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING TODO ChangeLog README NEWS doc/manual.pdf
%{_bindir}/speexenc
%{_bindir}/speexdec
%{_mandir}/man1/speexenc.1*
%{_mandir}/man1/speexdec.1*
%{_libdir}/lib*.so.*

%files devel
%defattr(-,root,root,-)
%exclude %{_libdir}/lib*.a
%exclude %{_libdir}/lib*.la
%{_includedir}/*
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%{_datadir}/aclocal/*.m4

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%exclude %{_libdir}/lib*.a
%exclude %{_libdir}/lib*.la
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%endif

%changelog
* Sun Sep 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.2.0-0.rc1.3
- rebuild with rpm-4.8.1 for pkg-config file

* Sun May 10 2009 NAKAMURA Kenta <kenta@vinelinux.org> 1.2.0-0.rc1.2
- added compat32 package for x86_64 arch support
- removed lib*.a from devel package

* Mon Sep 15 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2.0-0.rc1.1
- new upstream release

* Mon May 19 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2.0-0.beta3.1
- new upstream release
- added Patch100 for security fix
  * Tue Apr 15 2008 Tomas Hoger <thoger@redhat.com> - 1.2-0.7.beta3
  - Security update: Add mode checks to speex_packet_to_header() to protect
    applications using speex library and not having proper checks
    (CVE-2008-1686, #441239, https://trac.xiph.org/changeset/14701)

* Sun Jun  5 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.5-0vl1
- new upstream release

* Mon Mar  1 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0.3-2vl1
- initial build for Vine Linux

* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Fri Dec 12 2003 Bill Nottingham <notting@redhat.com> 1.0.3-1
- build 1.0.3, adapt specfile from linva.org

* Thu Nov 20 2003 Dams <anvil[AT]livna.org> 0:1.0.3-0.fdr.1
- Updated to 1.0.3

* Tue Sep 30 2003 Dams <anvil[AT]livna.org> 0:1.0.2-0.fdr.1
- Updated to 1.0.2

* Mon Sep 15 2003 Dams <anvil[AT]livna.org> 0:1.0.1-0.fdr.3
- README doc file is no more +x

* Tue Sep  9 2003 Dams <anvil[AT]livna.org> 0:1.0.1-0.fdr.2
- Added missing scriplets (ldconfig)

* Sat Aug 16 2003 Dams <anvil[AT]livna.org> 
- Initial build.
