From 18cf5a596df32707d9ebd9cad2a0fa94860baa52 Mon Sep 17 00:00:00 2001
From: Danny Rawlins <monster.romster@gmail.com>
Date: Tue, 28 Jan 2014 22:04:06 +1100
Subject: [PATCH] faad2: build shared library, emove dependencies libsndfile
 id3lib libmp4v2

---
 faad2/.footprint                              |  9 ++++++
 faad2/.md5sum                                 |  3 ++
 faad2/Pkgfile                                 | 30 +++++++++++++------
 ...7-libmp4ff-install-mp4ff_int_types_h.patch | 13 ++++++++
 faad2/faad2-2.7-libmp4ff-shared-lib.patch     | 29 ++++++++++++++++++
 faad2/faad2-2.7-man1_MANS.patch               | 10 +++++++
 6 files changed, 85 insertions(+), 9 deletions(-)
 create mode 100644 faad2/faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch
 create mode 100644 faad2/faad2-2.7-libmp4ff-shared-lib.patch
 create mode 100644 faad2/faad2-2.7-man1_MANS.patch

diff --git a/faad2/.footprint b/faad2/.footprint
index 8e6fb4663..780919d4b 100644
--- a/faad2/.footprint
+++ b/faad2/.footprint
@@ -1,4 +1,6 @@
 drwxr-xr-x	root/root	usr/
+drwxr-xr-x	root/root	usr/bin/
+-rwxr-xr-x	root/root	usr/bin/faad
 drwxr-xr-x	root/root	usr/include/
 -rw-r--r--	root/root	usr/include/faad.h
 -rw-r--r--	root/root	usr/include/mp4ff.h
@@ -12,3 +14,10 @@ lrwxrwxrwx	root/root	usr/lib/libfaad.so -> libfaad.so.2.0.0
 lrwxrwxrwx	root/root	usr/lib/libfaad.so.2 -> libfaad.so.2.0.0
 -rwxr-xr-x	root/root	usr/lib/libfaad.so.2.0.0
 -rw-r--r--	root/root	usr/lib/libmp4ff.a
+-rwxr-xr-x	root/root	usr/lib/libmp4ff.la
+lrwxrwxrwx	root/root	usr/lib/libmp4ff.so -> libmp4ff.so.0.0.0
+lrwxrwxrwx	root/root	usr/lib/libmp4ff.so.0 -> libmp4ff.so.0.0.0
+-rwxr-xr-x	root/root	usr/lib/libmp4ff.so.0.0.0
+drwxr-xr-x	root/root	usr/man/
+drwxr-xr-x	root/root	usr/man/man1/
+-rw-r--r--	root/root	usr/man/man1/faad.1.gz
diff --git a/faad2/.md5sum b/faad2/.md5sum
index a86e592c7..3be77fe00 100644
--- a/faad2/.md5sum
+++ b/faad2/.md5sum
@@ -1 +1,4 @@
+b33354022bc1696a89b3ccc1ab94c54f  faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch
+b23d2853fec6f07ae7769fd4eabd8f42  faad2-2.7-libmp4ff-shared-lib.patch
+a8cee29241a696ab24d010af35b951b8  faad2-2.7-man1_MANS.patch
 4c332fa23febc0e4648064685a3d4332  faad2-2.7.tar.bz2
diff --git a/faad2/Pkgfile b/faad2/Pkgfile
index 0c20b879f..31a02481c 100644
--- a/faad2/Pkgfile
+++ b/faad2/Pkgfile
@@ -1,19 +1,31 @@
-# Description: An HE, LC, MAIN and LTP profile MPEG2 and MPEG-4 AAC decoder
+# Description: AAC audio decoding library.
 # URL: http://www.audiocoding.com/
 # Maintainer: Danny Rawlins, monster dot romster at gmail dot com
 # Packager: Matt Housh, jaeger at morpheus dot net
-# Depends on: libsndfile id3lib libmp4v2
 
 name=faad2
 version=2.7
-release=1
-source=(http://download.sourceforge.net/faac/$name-$version.tar.bz2)
+release=2
+source=(http://downloads.sourceforge.net/project/faac/faad2-src/$name-$version/$name-$version.tar.bz2
+	faad2-2.7-libmp4ff-shared-lib.patch
+	faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch
+	faad2-2.7-man1_MANS.patch)
 
 build() {
 	cd $name-$version
-	./configure --prefix=/usr \
-		--enable-mp4v2
-	(cd libfaad && make DESTDIR=$PKG install)
-	(cd common && make DESTDIR=$PKG install)
-	install -m 0644 common/mp4ff/mp4ff_int_types.h $PKG/usr/include
+
+	patch -p1 -i $SRC/faad2-2.7-libmp4ff-shared-lib.patch
+	patch -p0 -i $SRC/faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch
+	patch -p1 -i $SRC/faad2-2.7-man1_MANS.patch
+	sed -i -e 's|iquote |I|' libfaad/Makefile.am
+	sed -i 's|AM_CONFIG_HEADER|AC_CONFIG_HEADERS|' configure.in
+	autoreconf -fi
+
+	./configure \
+		--prefix=/usr \
+		--mandir=/usr/man \
+		--disable-dependency-tracking
+
+	make
+	make DESTDIR=$PKG install
 }
diff --git a/faad2/faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch b/faad2/faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch
new file mode 100644
index 000000000..5d39cad95
--- /dev/null
+++ b/faad2/faad2-2.7-libmp4ff-install-mp4ff_int_types_h.patch
@@ -0,0 +1,13 @@
+Install mp4ff_int_types.h for mythmusic.
+
+http://bugs.gentoo.org/275008
+
+--- common/mp4ff/Makefile.am
++++ common/mp4ff/Makefile.am
+@@ -1,5 +1,5 @@
+ lib_LTLIBRARIES = libmp4ff.la
+-include_HEADERS = mp4ff.h mp4ffint.h
++include_HEADERS = mp4ff.h mp4ffint.h mp4ff_int_types.h
+ 
+ AM_CFLAGS = -DUSE_TAGGING=1
+ 
diff --git a/faad2/faad2-2.7-libmp4ff-shared-lib.patch b/faad2/faad2-2.7-libmp4ff-shared-lib.patch
new file mode 100644
index 000000000..56a131192
--- /dev/null
+++ b/faad2/faad2-2.7-libmp4ff-shared-lib.patch
@@ -0,0 +1,29 @@
+Ripped from Debian
+
+Patch to create a shared lib for libmp4ff.
+
+--- a/common/mp4ff/Makefile.am
++++ b/common/mp4ff/Makefile.am
+@@ -1,7 +1,8 @@
+-lib_LIBRARIES = libmp4ff.a
++lib_LTLIBRARIES = libmp4ff.la
+ include_HEADERS = mp4ff.h mp4ffint.h
+ 
+-libmp4ff_a_CFLAGS = -DUSE_TAGGING=1
++AM_CFLAGS = -DUSE_TAGGING=1
+ 
+-libmp4ff_a_SOURCES = mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c \
++libmp4ff_la_LDFLAGS = -version-info 0:0:0
++libmp4ff_la_SOURCES = mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c \
+ 		     mp4tagupdate.c mp4ff.h mp4ffint.h mp4ff_int_types.h
+--- a/frontend/Makefile.am
++++ b/frontend/Makefile.am
+@@ -5,7 +5,7 @@
+ 	   -I$(top_srcdir)/common/mp4ff
+ 
+ faad_LDADD = $(top_builddir)/libfaad/libfaad.la \
+-	     $(top_builddir)/common/mp4ff/libmp4ff.a
++	     $(top_builddir)/common/mp4ff/libmp4ff.la
+ 
+ faad_SOURCES = main.c \
+ 	       audio.c audio.h \
diff --git a/faad2/faad2-2.7-man1_MANS.patch b/faad2/faad2-2.7-man1_MANS.patch
new file mode 100644
index 000000000..9c1ddb01b
--- /dev/null
+++ b/faad2/faad2-2.7-man1_MANS.patch
@@ -0,0 +1,10 @@
+diff -ur faad2-2.7.orig/frontend/Makefile.am faad2-2.7/frontend/Makefile.am
+--- faad2-2.7.orig/frontend/Makefile.am	2009-02-06 18:03:37.000000000 +0200
++++ faad2-2.7/frontend/Makefile.am	2009-07-20 20:27:29.000000000 +0300
+@@ -1,5 +1,5 @@
+ bin_PROGRAMS = faad
+-man_MANS = faad.man
++man1_MANS = faad.man
+ 
+ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/common/faad \
+ 	   -I$(top_srcdir)/common/mp4ff