shithub: sox

Download patch

ref: 782397021adc5418db9e172464034b3a318b0dcf
parent: ee8d1ad4cb1d26ed5246ecba42741160ef67aace
author: robs <robs>
date: Sat Feb 7 16:49:44 EST 2009

trying configurable static/dynamic linking

--- a/configure.ac
+++ b/configure.ac
@@ -407,16 +407,16 @@
   ;;
 esac
 
-AC_ARG_WITH(flac,
-    AC_HELP_STRING([--without-flac],
-        [Don't try to use FLAC]))
+AC_ARG_WITH(flac, AC_HELP_STRING([--without-flac], [Don't try to use FLAC]),
+    [], with_flac=yes)
+AC_ARG_WITH(flac, AC_HELP_STRING([--with-flac=dyn], [Try to use FLAC dynamically]))
 using_flac=no
 if test "$with_flac" != "no"; then
-    using_flac=yes
-    dnl Note passing in OGG_LIBS.  That is because FLAC has optional
-    dnl support for OGG and if OGG libraries are found ont this
-    dnl system then its highly likely to be compiled into FLAC
-    dnl and will require these at link time.
+    using_flac=$with_flac
+    dnl  Note passing in OGG_LIBS.  That is because FLAC has optional
+    dnl  support for OGG and if OGG libraries are found on this
+    dnl  system then its highly likely to be compiled into FLAC
+    dnl  and will require these at link time.
     AC_CHECK_HEADER(FLAC/all.h,
         [AC_CHECK_LIB(FLAC, FLAC__stream_encoder_new, FLAC_LIBS="-lFLAC $FLAC_LIBS $OGG_LIBS",using_flac=no, $FLAC_LIBS $OGG_LIBS)],
         using_flac=no)
@@ -424,10 +424,14 @@
         AC_MSG_FAILURE([cannot find FLAC])
     fi
 fi
-if test "$using_flac" = yes; then
-   AC_DEFINE(HAVE_FLAC, 1, [Define to 1 if you have FLAC.])
+if test "$using_flac" != no; then
+  AC_DEFINE(HAVE_FLAC, 1, [Define to 1 if you have FLAC.])
+  if test "$using_flac" = yes; then
+    AC_DEFINE(STATIC_FLAC, 1, [Define to 1 if you have static FLAC.])
+  fi
 fi
-AM_CONDITIONAL(HAVE_FLAC, test x$using_flac = xyes)
+AM_CONDITIONAL(HAVE_FLAC, test $using_flac != no)
+AM_CONDITIONAL(STATIC_FLAC, test $using_flac = yes)
 AC_SUBST(FLAC_LIBS)
 
 dnl Check for ffmpeg libraries
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,10 +50,12 @@
 
 # File formats
 if HAVE_FLAC
+if !STATIC_FLAC
 libsox_fmt_flac_la_SOURCES = flac.c
 libsox_fmt_flac_la_LIBADD = libsox.la @FLAC_LIBS@
 pkglib_LTLIBRARIES += libsox_fmt_flac.la
 endif
+endif
 if HAVE_FFMPEG
 libsox_fmt_ffmpeg_la_SOURCES = ffmpeg.c
 libsox_fmt_ffmpeg_la_LIBADD = libsox.la @FFMPEG_LIBS@
@@ -206,6 +208,12 @@
 libsox_la_LIBADD += @GSM_LIBS@ @LIBGSM_LIBADD@
 libsox_la_LIBADD += @LPC10_LIBS@ @LIBLPC10_LIBADD@
 
+if STATIC_FLAC
+    libsox_la_SOURCES += flac.c
+    libsox_la_LIBADD += @FLAC_LIBS@
+    sox_LDADD += @FLAC_LIBS@
+endif
+
 if HAVE_LIBLTDL
   libsox_la_CFLAGS += $(LTDLINCL) 
   libsox_la_LDFLAGS += $(LIBLTDL) 
@@ -213,11 +221,6 @@
 sox_LDADD += @GSM_LIBS@ @LIBGSM_LIBADD@
 sox_LDADD += @LPC10_LIBS@ @LIBLPC10_LIBADD@
 
-if HAVE_FLAC
-    libsox_la_SOURCES += flac.c
-    libsox_la_LIBADD += @FLAC_LIBS@
-    sox_LDADD += @FLAC_LIBS@
-endif
 if HAVE_FFMPEG
     libsox_la_SOURCES += ffmpeg.h ffmpeg.c
     libsox_la_LIBADD += @FFMPEG_LIBS@
--- a/src/formats.h
+++ b/src/formats.h
@@ -61,6 +61,10 @@
   FORMAT(wve)
   FORMAT(xa)
 
+#if defined HAVE_FLAC && (defined STATIC_FLAC || !defined HAVE_LIBLTDL)
+  FORMAT(flac)
+#endif
+
 #ifndef HAVE_LIBLTDL /* Plugin format handlers */
 
 #if defined HAVE_ALSA
@@ -77,9 +81,6 @@
 #endif
 #if defined HAVE_FFMPEG
   FORMAT(ffmpeg)
-#endif
-#if defined HAVE_FLAC
-  FORMAT(flac)
 #endif
 #if defined(HAVE_MP3)
   FORMAT(mp3)