shithub: sox

Download patch

ref: 60b5e4f356dfc3b16880c0aeebf684c3cc41a5ca
parent: 48d4c6c3b9c56f16f5227754fd93d3b1cb004647
author: rrt <rrt>
date: Fri May 4 20:21:37 EDT 2007

Rather than guarding the code of optional modules with #ifdefs, guard
the building of the modules in the makefile, so that they are simply
not built (or installed).

--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,7 @@
 if test "$enable_alsa" = yes; then
    AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if you have ALSA.])
 fi
+AM_CONDITIONAL(HAVE_ALSA, test x$enable_alsa = xyes)
 
 dnl Check for libao
 AC_MSG_CHECKING([whether to try building libao sound driver])
@@ -108,6 +109,7 @@
         AC_CHECK_LIB(ao, ao_play,, enable_libao=no),
         enable_libao=no)
 fi
+AM_CONDITIONAL(HAVE_LIBAO, test x$enable_libao = xyes)
 
 dnl Check for OSS
 AC_MSG_CHECKING([whether to try building OSS sound driver])
@@ -123,6 +125,7 @@
 if test "$enable_oss" = yes; then
    AC_DEFINE(HAVE_OSS, 1, [Define to 1 if you have OSS.])
 fi
+AM_CONDITIONAL(HAVE_OSS, test x$enable_oss = xyes)
 
 dnl Check for Sun audio
 AC_MSG_CHECKING([whether to try building Sun audio driver])
@@ -136,6 +139,7 @@
 if test "$enable_sun_audio" = yes; then
    AC_DEFINE(HAVE_SUN_AUDIO, 1, [Define to 1 if you have Sun audio.])
 fi
+AM_CONDITIONAL(HAVE_SUN_AUDIO, test x$enable_sun_audio = xyes)
 
 dnl Check for libgsm
 AC_CHECK_HEADERS(gsm/gsm.h, found_libgsm=yes,
@@ -159,6 +163,7 @@
   SOX_PATH_SNDFILE(, [with_sndfile=no
                        AC_MSG_NOTICE([Could not find a usable libsndfile])])
 fi
+AM_CONDITIONAL(HAVE_SNDFILE, test x$with_sndfile = xyes)
 AC_SUBST(SNDFILE_CFLAGS)
 AC_SUBST(SNDFILE_LIBS)
         
@@ -170,6 +175,7 @@
     AC_CHECK_LIB(vorbisfile, ov_clear,, with_ogg_vorbis=no)
     AC_CHECK_LIB(vorbisenc, vorbis_encode_init_vbr,, with_ogg_vorbis=no)],
     with_ogg_vorbis=no)
+AM_CONDITIONAL(HAVE_OGG_VORBIS, test x$with_ogg_vorbis = xyes)
 
 dnl Check for FLAC libraries
 AC_ARG_WITH(flac,
@@ -185,6 +191,7 @@
         AC_MSG_FAILURE([cannot find FLAC])
     fi
 fi
+AM_CONDITIONAL(HAVE_FLAC, test x$with_flac = xyes)
 
 dnl Check for ffmpeg libraries
 AC_CHECK_HEADER(ffmpeg/avformat.h,
@@ -191,6 +198,7 @@
     [with_ffmpeg=yes
     AC_CHECK_LIB(avformat, av_open_input_file,, with_ffmpeg=no)],
     with_ffmpeg=no)
+AM_CONDITIONAL(HAVE_FFMPEG, test x$with_ffmpeg = xyes)
 
 dnl Check for MAD libraries
 AC_ARG_WITH(mad,
@@ -222,6 +230,9 @@
     fi
 fi
 
+dnl MP3 library depends on libmad || LAME
+AM_CONDITIONAL(HAVE_MP3, test x$using_mad = xyes -o x$using_lame = xyes)
+
 dnl Test for libsamplerate.
 AC_ARG_WITH(samplerate,
     AC_HELP_STRING([--without-samplerate],
@@ -251,6 +262,7 @@
         AC_MSG_FAILURE([cannot find amr-wb])
     fi
 fi
+AM_CONDITIONAL(HAVE_AMR_WB, test x$using_amr_wb = xyes)
 
 dnl Generate output files.
 AX_CREATE_STDINT_H(src/soxstdint.h)
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,21 @@
 lib_LTLIBRARIES = libsox.la
 include_HEADERS = sox.h soxstdint.h
 
+# Format modules; listed first so optional ones can be added later
+pkglib_LTLIBRARIES = libsox_fmt_auto.la libsox_fmt_raw.la libsox_fmt_s1.la \
+	  libsox_fmt_s2.la libsox_fmt_s3.la libsox_fmt_s4.la libsox_fmt_u1.la	\
+	  libsox_fmt_u2.la libsox_fmt_u3.la libsox_fmt_u4.la		\
+	  libsox_fmt_al.la libsox_fmt_la.la libsox_fmt_ul.la		\
+	  libsox_fmt_lu.la libsox_fmt_svx.la libsox_fmt_aiff.la		\
+	  libsox_fmt_aifc.la libsox_fmt_au.la libsox_fmt_avr.la		\
+	  libsox_fmt_cdr.la libsox_fmt_cvsd.la libsox_fmt_dvms.la	\
+	  libsox_fmt_dat.la libsox_fmt_gsm.la libsox_fmt_hcom.la	\
+	  libsox_fmt_lpc10.la libsox_fmt_maud.la libsox_fmt_prc.la	\
+	  libsox_fmt_sf.la libsox_fmt_smp.la libsox_fmt_sndrtool.la	\
+	  libsox_fmt_sphere.la libsox_fmt_txw.la libsox_fmt_voc.la	\
+	  libsox_fmt_vox.la libsox_fmt_ima.la libsox_fmt_wav.la		\
+	  libsox_fmt_wve.la libsox_fmt_xa.la libsox_fmt_nul.la
+
 # File format detection
 libsox_fmt_auto_la_SOURCES = auto.c
 libsox_fmt_auto_la_LIBADD = libsox.la
@@ -49,8 +64,6 @@
 libsox_fmt_aiff_la_LIBADD = libsox.la
 libsox_fmt_aifc_la_SOURCES = aifc-fmt.c
 libsox_fmt_aifc_la_LIBADD = libsox.la
-libsox_fmt_amr_wb_la_SOURCES = amr-wb.c
-libsox_fmt_amr_wb_la_LIBADD = libsox.la
 libsox_fmt_au_la_SOURCES = au.c
 libsox_fmt_au_la_LIBADD = libsox.la
 libsox_fmt_avr_la_SOURCES = avr.c
@@ -63,10 +76,6 @@
 libsox_fmt_dvms_la_LIBADD = libsox.la
 libsox_fmt_dat_la_SOURCES = dat.c
 libsox_fmt_dat_la_LIBADD = libsox.la
-libsox_fmt_ffmpeg_la_SOURCES = ffmpeg.c
-libsox_fmt_ffmeg_la_LIBADD = libsox.la
-libsox_fmt_flac_la_SOURCES = flac.c
-libsox_fmt_flac_la_LIBADD = libsox.la
 libsox_fmt_gsm_la_SOURCES = gsm.c
 libsox_fmt_gsm_la_LIBADD = libsox.la
 libsox_fmt_hcom_la_SOURCES = hcom.c
@@ -75,10 +84,6 @@
 libsox_fmt_lpc10_la_LIBADD = ../lpc10/liblpc10.la libsox.la
 libsox_fmt_maud_la_SOURCES = maud.c
 libsox_fmt_maud_la_LIBADD = libsox.la
-libsox_fmt_mp3_la_SOURCES = mp3.c
-libsox_fmt_mp3_la_LIBADD = libsox.la
-libsox_fmt_nul_la_SOURCES = nulfile.c
-libsox_fmt_nul_la_LIBADD = libsox.la
 libsox_fmt_prc_la_SOURCES = prc.c
 libsox_fmt_prc_la_LIBADD = libsox.la
 libsox_fmt_sf_la_SOURCES = sf.c sfircam.h
@@ -85,8 +90,6 @@
 libsox_fmt_sf_la_LIBADD = libsox.la
 libsox_fmt_smp_la_SOURCES = smp.c
 libsox_fmt_smp_la_LIBADD = libsox.la
-libsox_fmt_sndfile_la_SOURCES = sndfile.c
-libsox_fmt_sndfile_la_LIBADD = libsox.la
 libsox_fmt_sndrtool_la_SOURCES = sndrtool.c
 libsox_fmt_sndrtool_la_LIBADD = libsox.la
 libsox_fmt_sphere_la_SOURCES = sphere.c
@@ -95,8 +98,6 @@
 libsox_fmt_txw_la_LIBADD = libsox.la
 libsox_fmt_voc_la_SOURCES = voc.c
 libsox_fmt_voc_la_LIBADD = libsox.la
-libsox_fmt_vorbis_la_SOURCES = vorbis.c
-libsox_fmt_vorbis_la_LIBADD = libsox.la
 libsox_fmt_vox_la_SOURCES = vox-fmt.c
 libsox_fmt_vox_la_LIBADD = libsox.la
 libsox_fmt_ima_la_SOURCES = ima-fmt.c
@@ -107,34 +108,60 @@
 libsox_fmt_wve_la_LIBADD = libsox.la
 libsox_fmt_xa_la_SOURCES = xa.c
 libsox_fmt_xa_la_LIBADD = libsox.la
+if HAVE_FLAC
+libsox_fmt_flac_la_SOURCES = flac.c
+libsox_fmt_flac_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_flac.la
+endif
+if HAVE_FFMPEG
+libsox_fmt_ffmpeg_la_SOURCES = ffmpeg.c
+libsox_fmt_ffmpeg_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_ffmpeg.la
+endif
+if HAVE_SNDFILE
+libsox_fmt_sndfile_la_SOURCES = sndfile.c
+libsox_fmt_sndfile_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_sndfile.la
+endif
+if HAVE_AMR_WB
+libsox_fmt_amr_wb_la_SOURCES = amr-wb.c
+libsox_fmt_amr_wb_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_amr_wb.la
+endif
+if HAVE_MP3
+libsox_fmt_mp3_la_SOURCES = mp3.c
+libsox_fmt_mp3_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_mp3.la
+endif
+if HAVE_OGG_VORBIS
+libsox_fmt_vorbis_la_SOURCES = vorbis.c
+libsox_fmt_vorbis_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_vorbis.la
+endif
 
 # I/O devices
+libsox_fmt_nul_la_SOURCES = nulfile.c
+libsox_fmt_nul_la_LIBADD = libsox.la
+if HAVE_ALSA
 libsox_fmt_alsa_la_SOURCES = alsa.c
 libsox_fmt_alsa_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_alsa.la
+endif
+if HAVE_LIBAO
 libsox_fmt_ao_la_SOURCES = ao.c
 libsox_fmt_ao_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_ao.la
+endif
+if HAVE_OSS
 libsox_fmt_oss_la_SOURCES = oss.c
 libsox_fmt_oss_la_LIBADD = libsox.la
+pkglib_LTLIBRARIES += libsox_fmt_oss.la
+endif
+if HAVE_SUN_AUDIO
 libsox_fmt_sunau_la_SOURCES = sunaudio.c
 libsox_fmt_sunau_la_LIBADD = libsox.la
-
-pkglib_LTLIBRARIES = libsox_fmt_auto.la libsox_fmt_raw.la libsox_fmt_s1.la \
-	  libsox_fmt_s2.la libsox_fmt_s3.la libsox_fmt_s4.la libsox_fmt_u1.la	\
-	  libsox_fmt_u2.la libsox_fmt_u3.la libsox_fmt_u4.la		\
-	  libsox_fmt_al.la libsox_fmt_la.la libsox_fmt_ul.la		\
-	  libsox_fmt_lu.la libsox_fmt_svx.la libsox_fmt_aiff.la		\
-	  libsox_fmt_aifc.la libsox_fmt_amr_wb.la libsox_fmt_au.la	\
-	  libsox_fmt_avr.la libsox_fmt_cdr.la libsox_fmt_cvsd.la	\
-	  libsox_fmt_dvms.la libsox_fmt_dat.la libsox_fmt_ffmpeg.la	\
-	  libsox_fmt_flac.la libsox_fmt_gsm.la libsox_fmt_hcom.la	\
-	  libsox_fmt_lpc10.la libsox_fmt_maud.la libsox_fmt_mp3.la	\
-	  libsox_fmt_nul.la libsox_fmt_prc.la libsox_fmt_sf.la		\
-	  libsox_fmt_smp.la libsox_fmt_sndfile.la			\
-	  libsox_fmt_sndrtool.la libsox_fmt_sphere.la			\
-	  libsox_fmt_txw.la libsox_fmt_voc.la libsox_fmt_vorbis.la	\
-	  libsox_fmt_vox.la libsox_fmt_ima.la libsox_fmt_wav.la		\
-	  libsox_fmt_wve.la libsox_fmt_xa.la libsox_fmt_alsa.la		\
-	  libsox_fmt_ao.la libsox_fmt_oss.la libsox_fmt_sunau.la
+pkglib_LTLIBRARIES += libsox_fmt_sunau.la
+endif
 
 effects = band.h biquad.c biquad.h biquads.c chorus.c compand.c \
 	  compandt.c compandt.h dcshift.c dither.c earwax.c echo.c echos.c \
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -9,8 +9,6 @@
 
 #include "sox_i.h"
 
-#ifdef HAVE_ALSA
-
 #include <alsa/asoundlib.h>
 
 typedef struct alsa_priv
@@ -686,5 +684,3 @@
 {
     return &sox_alsa_format;
 }
-
-#endif /* HAVE_ALSA */
--- a/src/amr-wb.c
+++ b/src/amr-wb.c
@@ -1,4 +1,6 @@
 /*
+ * File format: AMR-WB   (c) 2007 robs@users.sourceforge.net
+ * 
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at
@@ -14,14 +16,10 @@
  * Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA.
  */
 
-/* File format: AMR-WB   (c) 2007 robs@users.sourceforge.net */
-
 /* In order to use this format with SoX, first obtain, build & install:
  *   http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.0.tar.bz2
  */
 
-#ifdef HAVE_LIBAMRWB
-
 #include "sox_i.h"
 #include "amrwb/typedef.h"
 #include "amrwb/enc_if.h"
@@ -178,5 +176,3 @@
   };
   return &driver;
 }
-
-#endif
--- a/src/ffmpeg.c
+++ b/src/ffmpeg.c
@@ -43,8 +43,6 @@
 
 #include "sox_i.h"
 
-#ifdef HAVE_LIBAVFORMAT
-
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
@@ -506,5 +504,3 @@
 {
   return &sox_ffmpeg_format;
 }
-
-#endif
--- a/src/flac.c
+++ b/src/flac.c
@@ -1,4 +1,6 @@
 /*
+ * File format: FLAC   (c) 2006-7 robs@users.sourceforge.net
+ *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at
@@ -14,14 +16,9 @@
  * Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA.
  */
 
-/* File format: FLAC   (c) 2006-7 robs@users.sourceforge.net */
 
-
-
 #include "sox_i.h"
 
-#ifdef HAVE_LIBFLAC
-
 #include <math.h>
 #include <string.h>
 
@@ -532,7 +529,3 @@
   };
   return &driver;
 }
-
-
-
-#endif /* HAVE_LIBFLAC */
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -14,8 +14,6 @@
 
 #include <string.h>
 
-#if defined(HAVE_LIBMAD) || defined(HAVE_LIBMP3LAME)
-
 #ifdef HAVE_LIBMAD
 #include <mad.h>
 #endif
@@ -570,4 +568,3 @@
 {
     return &sox_mp3_format;
 }
-#endif
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -17,8 +17,6 @@
 
 #include "sox_i.h"
 
-#ifdef HAVE_SUN_AUDIO
-
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #ifdef HAVE_SUN_AUDIOIO_H
@@ -332,5 +330,3 @@
 {
     return &sox_sunau_format;
 }
-
-#endif
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -19,9 +19,9 @@
  * TODO: When reading in comments, it doesn't understand how to read
  * more then one comment and doesn't know how to parse KEY=value.
  */
+
 #include "sox_i.h"
 
-#if defined HAVE_LIBVORBISENC && defined HAVE_LIBVORBISFILE
 #include <stdio.h>
 #include <math.h>
 #include <string.h>
@@ -468,4 +468,3 @@
 {
     return &sox_vorbis_format;
 }
-#endif