shithub: opus-tools

Download patch

ref: 71adeb9f5af77168aa4db5dc232ff29511c23310
parent: 4689efe4ffd02be889858e1e8cff7f38637a99ae
author: Ron <[email protected]>
date: Mon Jun 10 18:55:47 EDT 2013

Get rid of LIBM altogether

And the exp() check too.  Nothing in the code actually tests for that
and it's irrelevant whether it needs libm or not, since plenty of other
things definitely do need it.

So add the hardcoded -lm back where it is definitely needed (at the
very least for the speex resampler), and make sure it is in LIBS when
we test for lrint and f{min,max}f, since those tests do fail on Linux
if libm isn't linked.

--- a/Makefile.am
+++ b/Makefile.am
@@ -55,12 +55,12 @@
 
 opusenc_SOURCES = src/opus_header.c src/opusenc.c src/picture.c src/resample.c src/audio-in.c src/diag_range.c src/flac.c src/lpc.c win32/unicode_support.c
 opusenc_CPPFLAGS = $(AM_CPPFLAGS) $(resampler_CPPFLAGS)
-opusenc_LDADD = $(OGG_LIBS) $(OPUS_LIBS) $(LIBM)
+opusenc_LDADD = $(OGG_LIBS) $(OPUS_LIBS) -lm
 opusenc_MANS = man/opusenc.1
 
 opusdec_SOURCES = src/opus_header.c src/wav_io.c src/wave_out.c src/opusdec.c src/resample.c src/diag_range.c win32/unicode_support.c
 opusdec_CPPFLAGS = $(AM_CPPFLAGS) $(resampler_CPPFLAGS)
-opusdec_LDADD = $(OGG_LIBS) $(OPUS_LIBS) $(LIBM)
+opusdec_LDADD = $(OGG_LIBS) $(OPUS_LIBS) -lm
 opusdec_MANS = man/opusdec.1
 
 opusinfo_SOURCES = src/opus_header.c src/opusinfo.c src/info_opus.c src/picture.c win32/unicode_support.c
--- a/configure.ac
+++ b/configure.ac
@@ -79,9 +79,6 @@
     ])
 AC_MSG_RESULT([$has_var_arrays])
 
-AC_CHECK_FUNC([exp],,[AC_CHECK_LIB([m],[exp],[LIBM="-lm"])])
-AC_SUBST([LIBM])
-
 AC_CHECK_LIB([winmm], [main])
 
 AC_ARG_ENABLE([assertions],
@@ -291,10 +288,21 @@
     ])
 
 AC_FUNC_FSEEKO
+
+dnl This is a bit of a mess.  Really we should probably use AC_SEARCH_LIBS to
+dnl check for these, since on Linux at least they aren't found unless libm is
+dnl linked, but that may not be true everywhere.  But we also don't want LIBS
+dnl to contain -lm, since not everything we build actually needs that.
+dnl However the only thing that uses them is opusdec, and since it also uses
+dnl the speex resampler, it already needs libm for lots of other things too.
+dnl So check for them with -lm in LIBS, and then clear it after we're done.
+saved_LIBS="$LIBS"
+LIBS="$LIBS -lm"
 AC_CHECK_FUNCS([lrintf])
 AC_CHECK_FUNCS([lrint])
 AC_CHECK_FUNCS([fminf])
 AC_CHECK_FUNCS([fmaxf])
+LIBS="$saved_LIBS"
 
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_HEADERS([config.h])