From d47ddfb4724553533cf7bd2758b339329b483622 Mon Sep 17 00:00:00 2001
From: Ralph Giles <giles@thaumas.net>
Date: Sun, 16 Sep 2012 23:09:21 -0700
Subject: [PATCH] Add -lm to the pkg-config link line.

The floating-point build calls a number of math library
functions, and linking with libm is technically necessary.
It wasn't obvious because most systems support shlib
dependencies and pulled it in that way, or supply the
referenced functions with intrinsics. Discovered the issue
trying to build libopusfile against the uninstalled static
libopus, which unlike opus-tools, doesn't itself need libm.

The -lm argument is only added to Libs for the floating-
point (default) build. It's not necessary for the fixed-
point build.

Also mark which build was used in the .pc file description.
---
 configure.ac           | 11 +++++++++++
 opus-uninstalled.pc.in |  4 ++--
 opus.pc.in             |  4 ++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3091a7340..098379754 100644
--- a/configure.ac
+++ b/configure.ac
@@ -275,6 +275,17 @@ AC_SUBST(SIZE32)
 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
 AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
 
+dnl subsitutions for the pkg-config files
+if test x$ac_enable_float = xyes; then
+  PC_BUILD="floating-point"
+  PC_LIBM=$LIBM
+else
+  PC_BUILD="fixed-point"
+  PC_LIBM=
+fi
+AC_SUBST([PC_BUILD])
+AC_SUBST([PC_LIBM])
+
 AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc
            doc/Makefile doc/Doxyfile])
 
diff --git a/opus-uninstalled.pc.in b/opus-uninstalled.pc.in
index deb6719f3..b26b208c1 100644
--- a/opus-uninstalled.pc.in
+++ b/opus-uninstalled.pc.in
@@ -4,9 +4,9 @@ libdir=${pcfiledir}/.libs
 includedir=${pcfiledir}
 
 Name: opus uninstalled
-Description: Opus IETF audio codec (not installed)
+Description: Opus IETF audio codec (not installed, @PC_BUILD@)
 Version: @VERSION@
 Requires:
 Conflicts:
-Libs: ${libdir}/libopus.a
+Libs: ${libdir}/libopus.a @PC_LIBM@
 Cflags: -I${includedir}/include
diff --git a/opus.pc.in b/opus.pc.in
index 4e25e0bd2..58e2247da 100644
--- a/opus.pc.in
+++ b/opus.pc.in
@@ -6,10 +6,10 @@ libdir=@libdir@
 includedir=@includedir@
 
 Name: Opus
-Description: Opus IETF audio codec
+Description: Opus IETF audio codec (@PC_BUILD@ build)
 URL: http://opus-codec.org/
 Version: @VERSION@
 Requires:
 Conflicts:
-Libs: -L${libdir} -lopus
+Libs: -L${libdir} -lopus @PC_LIBM@
 Cflags: -I${includedir}/opus
-- 
GitLab