Hi,
please find attached two patches (against current git master) that fix overlinking issues in the pkg-config files and "locally", respectively. The first patch is originally due to Brad Smith, see the commit message for details.

Here is some general information regarding overlinking in case anyone is wondering: http://wiki.mandriva.com/en/Overlinking

Ulrich
>From be6302c9c9f2babd8dd24fddc31b2adf2dcfa63f Mon Sep 17 00:00:00 2001
From: Ulrich Klauer <ulr...@chirlu.de>
Date: Sat, 6 Apr 2013 20:41:12 +0200
Subject: [PATCH 1/2] Fix pkg-config files to avoid overlinking

Libraries that are used internally by libFLAC(++) but are not part of
their API should be listed in pkg-config "private" clauses. Otherwise
executables that are linked dynamically against libFLAC(++) will have
unneeded direct dependencies (overlinking).

Based on a patch by Brad Smith from
  https://sourceforge.net/p/flac/bugs/397/
that I updated to only include ogg if libFLAC is actually built with
ogg support.
---
 configure.ac               |    2 ++
 src/libFLAC++/flac++.pc.in |    4 ++--
 src/libFLAC/flac.pc.in     |    4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index b35e44d..b4094ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,9 +308,11 @@ fi
 AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes])
 if test "x$have_ogg" = xyes ; then
 	AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],1,[define if you have the ogg library])
+	OGG_PACKAGE="ogg"
 else
 	AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],0)
 fi
+AC_SUBST(OGG_PACKAGE)
 
 dnl check for i18n(internationalization); these are from libiconv/gettext
 AM_ICONV
diff --git a/src/libFLAC++/flac++.pc.in b/src/libFLAC++/flac++.pc.in
index 8f55499..242998d 100644
--- a/src/libFLAC++/flac++.pc.in
+++ b/src/libFLAC++/flac++.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: FLAC++
 Description: Free Lossless Audio Codec Library (C++ API)
 Version: @VERSION@
-Requires: flac
-Libs: -L${libdir} -lFLAC++ @OGG_LIBS@ -lm
+Requires.private: flac
+Libs: -L${libdir} -lFLAC++
 Cflags: -I${includedir}
diff --git a/src/libFLAC/flac.pc.in b/src/libFLAC/flac.pc.in
index 5f9be59..56e8594 100644
--- a/src/libFLAC/flac.pc.in
+++ b/src/libFLAC/flac.pc.in
@@ -6,5 +6,7 @@ includedir=@includedir@
 Name: FLAC
 Description: Free Lossless Audio Codec Library
 Version: @VERSION@
-Libs: -L${libdir} -lFLAC @OGG_LIBS@ -lm
+Requires.private: @OGG_PACKAGE@
+Libs: -L${libdir} -lFLAC
+Libs.private: -lm
 Cflags: -I${includedir}
-- 
1.7.10.4

>From cdfc00d283d70117e2eeec1834c18372e309d456 Mon Sep 17 00:00:00 2001
From: Ulrich Klauer <ulr...@chirlu.de>
Date: Sat, 6 Apr 2013 21:28:25 +0200
Subject: [PATCH 2/2] Only link against libogg (and libm) if needed

Most of the programs don't use libogg or libm directly and should not
link to them (overlinking).
---
 examples/c/decode/file/Makefile.am    |    4 +---
 src/flac/Makefile.am                  |    1 -
 src/metaflac/Makefile.am              |    4 +---
 src/plugin_xmms/Makefile.am           |    1 -
 src/test_grabbag/cuesheet/Makefile.am |    4 +---
 src/test_grabbag/picture/Makefile.am  |    4 +---
 src/test_seeking/Makefile.am          |    4 +---
 7 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/examples/c/decode/file/Makefile.am b/examples/c/decode/file/Makefile.am
index 7926e48..d3b2b0e 100644
--- a/examples/c/decode/file/Makefile.am
+++ b/examples/c/decode/file/Makefile.am
@@ -22,8 +22,6 @@ EXTRA_DIST = \
 AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
 noinst_PROGRAMS = example_c_decode_file
 example_c_decode_file_LDADD = \
-	$(top_builddir)/src/libFLAC/libFLAC.la \
-	@OGG_LIBS@ \
-	-lm
+	$(top_builddir)/src/libFLAC/libFLAC.la
 
 example_c_decode_file_SOURCES = main.c
diff --git a/src/flac/Makefile.am b/src/flac/Makefile.am
index 6f0145b..ceae6a5 100644
--- a/src/flac/Makefile.am
+++ b/src/flac/Makefile.am
@@ -50,7 +50,6 @@ flac_LDADD = \
 	$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
 	$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
 	$(top_builddir)/src/libFLAC/libFLAC.la \
-	@OGG_LIBS@ \
 	@LIBICONV@ \
 	-lm
 
diff --git a/src/metaflac/Makefile.am b/src/metaflac/Makefile.am
index dc286dc..bd54356 100644
--- a/src/metaflac/Makefile.am
+++ b/src/metaflac/Makefile.am
@@ -47,8 +47,6 @@ metaflac_LDADD = \
 	$(top_builddir)/src/share/getopt/libgetopt.la \
 	$(top_builddir)/src/share/utf8/libutf8.la \
 	$(top_builddir)/src/libFLAC/libFLAC.la \
-	@OGG_LIBS@ \
-	@LIBICONV@ \
-	-lm
+	@LIBICONV@
 
 CLEANFILES = metaflac.exe
diff --git a/src/plugin_xmms/Makefile.am b/src/plugin_xmms/Makefile.am
index 84c4106..ffb76a1 100644
--- a/src/plugin_xmms/Makefile.am
+++ b/src/plugin_xmms/Makefile.am
@@ -60,7 +60,6 @@ libxmms_flac_la_LIBADD = \
 	$(top_builddir)/src/share/utf8/libutf8.la \
 	$(top_builddir)/src/libFLAC/libFLAC.la \
 	-L$(top_builddir)/src/libFLAC/.libs \
-	@OGG_LIBS@ \
 	@XMMS_LIBS@ \
 	@LIBICONV@
 libxmms_flac_la_LDFLAGS = -module -avoid-version
diff --git a/src/test_grabbag/cuesheet/Makefile.am b/src/test_grabbag/cuesheet/Makefile.am
index 2b240e1..b4d7824 100644
--- a/src/test_grabbag/cuesheet/Makefile.am
+++ b/src/test_grabbag/cuesheet/Makefile.am
@@ -26,8 +26,6 @@ test_cuesheet_SOURCES = \
 test_cuesheet_LDADD = \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
 	$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
-	$(top_builddir)/src/libFLAC/libFLAC.la \
-	@OGG_LIBS@ \
-	-lm
+	$(top_builddir)/src/libFLAC/libFLAC.la
 
 CLEANFILES = test_cuesheet.exe
diff --git a/src/test_grabbag/picture/Makefile.am b/src/test_grabbag/picture/Makefile.am
index d40eb68..d7e0c54 100644
--- a/src/test_grabbag/picture/Makefile.am
+++ b/src/test_grabbag/picture/Makefile.am
@@ -26,8 +26,6 @@ test_picture_SOURCES = \
 
 test_picture_LDADD = \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
-	$(top_builddir)/src/libFLAC/libFLAC.la \
-	@OGG_LIBS@ \
-	-lm
+	$(top_builddir)/src/libFLAC/libFLAC.la
 
 CLEANFILES = test_picture.exe
diff --git a/src/test_seeking/Makefile.am b/src/test_seeking/Makefile.am
index 806f3a1..55d0fe0 100644
--- a/src/test_seeking/Makefile.am
+++ b/src/test_seeking/Makefile.am
@@ -25,9 +25,7 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
 
 noinst_PROGRAMS = test_seeking
 test_seeking_LDADD = \
-	$(top_builddir)/src/libFLAC/libFLAC.la \
-	@OGG_LIBS@ \
-	-lm
+	$(top_builddir)/src/libFLAC/libFLAC.la
 
 test_seeking_SOURCES = \
 	main.c
-- 
1.7.10.4

_______________________________________________
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev

Reply via email to