%define name faac
%define version 1.28
%define release 8%{?_dist_release}

%define enable_libmp4v2_external 1

Summary: Reference encoder and encoding library for MPEG2/4 AAC
Name: %{name}
Version: %{version}
Release: %{release}
Source: http://prdownloads.sourceforge.net/faac/faac-%{version}.tar.bz2
Patch0: http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/media-libs/faac/files/faac-1.28-external-libmp4v2.patch
## this patch is based on http://launchpadlibrarian.net/33120980/mp4v2-strcasestr.diff
Patch1: mp4v2-strcasestr-vine.diff
License: LGPLv2+
Group: Applications/Multimedia
URL: http://www.audiocoding.com/

BuildRequires: nkf
BuildRequires: autoconf, automake, libtool, gcc-c++ 
%if %{enable_libmp4v2_external}
BuildRequires: libmp4v2-devel
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description
FAAC is an AAC audio encoder. It currently supports MPEG-4 LTP, MAIN and LOW
COMPLEXITY object types and MAIN and LOW MPEG-2 object types. It also supports
multichannel and gapless encoding.

%package devel
Summary: Development libraries of the FAAC AAC encoder
Group: Development/Libraries
Requires: %{name} = %{version}

%description devel
FAAC is an AAC audio encoder. It currently supports MPEG-4 LTP, MAIN and LOW
COMPLEXITY object types and MAIN and LOW MPEG-2 object types. It also supports
multichannel and gapless encoding.

This package contains development files and documentation for libfaac.


%if !%{enable_libmp4v2_external}
%package -n libmp4v2
Summary:        Library for working with files using the mp4 container format
Group:          System Environment/Libraries

%description -n libmp4v2
The libmp4v2 library provides an abstraction layer for working with files
using the mp4 container format. This library is developed by mpeg4ip project
and is an exact copy of the library distributed in the mpeg4ip package.

This package is built with libmp4v2 internal from %{name}-%{version}-%{release}.

%package -n libmp4v2-devel
Summary:        Development files for the mp4v2 library
Group:          Development/Libraries
Requires:       libmp4v2 = %{version}-%{release}

%description -n libmp4v2-devel
The libmp4v2 library provides an abstraction layer for working with files
using the mp4 container format. This library is developed by mpeg4ip project
and is an exact copy of the library distributed in the mpeg4ip package.

This package contains development files for libmp4v2.

This package is built with libmp4v2 internal from %{name}-%{version}-%{release}.
%endif


%prep
%setup -q
#find . -type f -print|xargs nkf --unix --overwrite 
%if %{enable_libmp4v2_external}
%patch0 -p1 -b .mp4v2
%patch1 -p1 -b .mp4v2
#touch -r configure.in.mp4v2 configure.in
%endif

# # avoid to append the string "2005-02-02" to the tag Requires:
# chmod 644 ChangeLog

# # modify configure.in to escape error
# %__mv configure.in configure.in.org
# %__sed -e 's/^CFLAGS=.*$/CFLAGS="-O2 -Wall"/' configure.in.org > configure.in


%build
sh bootstrap
%configure \
    --disable-static \
%if !%{enable_libmp4v2_external}
    --with-mp4v2
%endif
   
%{__make} %{?_smp_mflags}


%install
%{__rm} -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot}


%clean
%{__rm} -rf %{buildroot}


%post
/sbin/ldconfig 2>/dev/null

%postun
/sbin/ldconfig 2>/dev/null


%files 
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog NEWS README TODO docs/*
%{_bindir}/*
%{_libdir}/*.so.*
%{_mandir}/man1/%{name}*

%files devel
%defattr(-,root,root,-)
%exclude %{_libdir}/*.la
%{_libdir}/*.so
%{_includedir}/*.h

%if !%{enable_libmp4v2_external}
%files -n libmp4v2
%defattr(-,root,root,-)
%{_libdir}/libmp4v2.so.*

%files -n libmp4v2-devel
%defattr(-,root,root,-)
%{_libdir}/libmp4v2.so
%{_libdir}/libmp4v2.a
%endif


%changelog
* Wed Nov  2 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.28-8
- s/self-build-libmp4v2/libmp4v2/

* Sat Mar 20 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.28-7
- change release to sync with self-build-faac

* Thu Feb 18 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.28-6
- applied mp4v2-strcasestr.diff from lauchpad
  - fixed wrong declaration of strcasestr() in mpeg4ip.h

* Thu Feb 18 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.28-5
- rebuilt with mp4v2 v1.9.1
  - applied faac-1.28-external-libmp4v2.patch from Gentoo Linux

* Wed Feb 17 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.28-4
- change release to sync with self-build-faac

* Sun Jun 07 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.28-3
- added BuildRequires: nkf

* Tue May 26 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.28-2
- change release to sync with self-build-faac

* Fri Mar 20 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.28-1
- new upstream release

* Sat Jan 24 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.26-2
- fixed Summary: , %%description
  - removed internal mp4v2

* Sun Jan 11 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.26-1
- new upstream release
- added --disable-static in %%configure

* Sun Nov 02 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.25-2
- spec in utf8
- remove *.la

* Sun May 18 2008 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 1.25-1
- apply new versioning policy

* Sat Mar 8 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.25-0vl1
- initial build 

### end of file
