From d0906f1453d37b463ffefdf92491bc18de7e5fcf Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 11 Aug 2010 23:42:42 +0000 Subject: [PATCH] conditionally build the sound format support files Rather than using an ifdef around the entire code, get autoconf to do the work for us. For one thing, this allows doxygen to produce decent docs. It also makes for less compalation when building without support for various formats. --- configure.ac | 27 ++++++++++++++------------- libs/audio/renderer/Makefile.am | 33 +++++++++++++++++++++++++++++---- libs/audio/renderer/flac.c | 4 ---- libs/audio/renderer/midi.c | 3 --- libs/audio/renderer/vorbis.c | 4 ---- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/configure.ac b/configure.ac index e883a62dd..d70ca12e7 100644 --- a/configure.ac +++ b/configure.ac @@ -579,6 +579,17 @@ case "$target_os" in ;; esac +AC_ARG_ENABLE(flac, +[ --disable-flac disable flac support], +) +HAVE_FLAC=no +if test "x$enable_flac" != "xno"; then + AM_PATH_LIBFLAC(HAVE_FLAC=yes, HAVE_FLAC=no) + if test "x$HAVE_FLAC" = xyes; then + AC_DEFINE(HAVE_FLAC, 1, [define this if you have flac libs]) + fi +fi + AC_ARG_ENABLE(wildmidi, [ --disable-wildmidi disable libWildMidi support], ) @@ -594,13 +605,11 @@ if test "x$enable_wildmidi" != "xno"; then fi fi fi - AC_SUBST(WM_LIBS) AC_ARG_ENABLE(vorbis, [ --disable-vorbis disable ogg vorbis support], ) - HAVE_VORBIS=no if test "x$enable_vorbis" != "xno"; then XIPH_PATH_OGG(HAVE_OGG=yes, HAVE_OGG=no) @@ -612,17 +621,9 @@ if test "x$enable_vorbis" != "xno"; then fi fi -AC_ARG_ENABLE(flac, -[ --disable-flac disable flac support], -) - -HAVE_FLAC=no -if test "x$enable_flac" != "xno"; then - AM_PATH_LIBFLAC(HAVE_FLAC=yes, HAVE_FLAC=no) - if test "x$HAVE_FLAC" = xyes; then - AC_DEFINE(HAVE_FLAC, 1, [define this if you have flac libs]) - fi -fi +AM_CONDITIONAL(HAVE_FLAC, test "x$HAVE_FLAC" = "xyes") +AM_CONDITIONAL(HAVE_MIDI, test "x$HAVE_MIDI" = "xyes") +AM_CONDITIONAL(HAVE_VORBIS, test "x$HAVE_VORBIS" = "xyes") AC_ARG_ENABLE(zlib, [ --disable-zlib disable zlib support], diff --git a/libs/audio/renderer/Makefile.am b/libs/audio/renderer/Makefile.am index 48cd5f50b..45e8848bd 100644 --- a/libs/audio/renderer/Makefile.am +++ b/libs/audio/renderer/Makefile.am @@ -12,15 +12,40 @@ EXTRA_LTLIBRARIES= snd_render_default.la snd_render_jack.la noinst_LTLIBRARIES= @SND_REND_STATIC@ -snd_common=snd_channels.c snd_mem.c snd_mix.c snd_resample.c snd_sfx.c \ - flac.c vorbis.c wav.c midi.c +flac_src=flac.c +midi_src=midi.c +vorbis_src=vorbis.c +wav_src=wav.c + +if HAVE_FLAC +have_flac_src=$(flac_src) +else +have_flac_src= +endif +if HAVE_MIDI +have_midi_src=$(midi_src) +else +have_midi_src= +endif +if HAVE_VORBIS +have_vorbis_src=$(vorbis_src) +else +have_vorbis_src= +endif +have_wav_src=$(wav_src) + +format_src=$(have_flac_src) $(have_midi_src) $(have_vorbis_src) $(have_wav_src) +extra_format_src=flac.c midi.c vorbis.c wav.c +snd_common=snd_channels.c snd_mem.c snd_mix.c snd_resample.c snd_sfx.c snd_render_default_la_LDFLAGS= $(plugin_ldflags) -snd_render_default_la_SOURCES= snd_dma.c $(snd_common) +snd_render_default_la_SOURCES= snd_dma.c $(snd_common) $(format_src) snd_render_default_la_LIBADD= $(VORBISFILE_LIBS) $(VORBIS_LIBS) $(LIBFLAC_LIBS) $(OGG_LIBS) $(WM_LIBS) $(top_builddir)/libs/util/libQFutil.la $(top_builddir)/libs/models/libQFmodels.la snd_render_default_la_DEPENDENCIES= +EXTRA_snd_render_default_la_SOURCES= $(extra_format_src) snd_render_jack_la_LDFLAGS= $(plugin_ldflags) -snd_render_jack_la_SOURCES= snd_jack.c $(snd_common) +snd_render_jack_la_SOURCES= snd_jack.c $(snd_common) $(format_src) snd_render_jack_la_LIBADD= $(VORBISFILE_LIBS) $(VORBIS_LIBS) $(LIBFLAC_LIBS) $(OGG_LIBS) $(WM_LIBS) $(JACK_LIBS) $(top_builddir)/libs/util/libQFutil.la $(top_builddir)/libs/models/libQFmodels.la snd_render_jack_la_DEPENDENCIES= +EXTRA_snd_render_jack_la_SOURCES= $(extra_format_src) diff --git a/libs/audio/renderer/flac.c b/libs/audio/renderer/flac.c index 728eb876a..3377ac110 100644 --- a/libs/audio/renderer/flac.c +++ b/libs/audio/renderer/flac.c @@ -34,8 +34,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; -#ifdef HAVE_FLAC - #ifdef HAVE_STRING_H # include "string.h" #endif @@ -503,5 +501,3 @@ SND_LoadFLAC (QFile *file, sfx_t *sfx, char *realname) } return 0; } - -#endif//HAVE_FLAC diff --git a/libs/audio/renderer/midi.c b/libs/audio/renderer/midi.c index 4a9465b75..c53eaf1fd 100644 --- a/libs/audio/renderer/midi.c +++ b/libs/audio/renderer/midi.c @@ -31,8 +31,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; -#ifdef HAVE_WILDMIDI - #ifdef HAVE_STRING_H # include #endif @@ -184,4 +182,3 @@ SND_LoadMidi (QFile *file, sfx_t *sfx, char *realname) SND_SFX_Stream (sfx, realname, info, midi_stream_open); return 0; } -#endif // HAVE_WILDMIDI diff --git a/libs/audio/renderer/vorbis.c b/libs/audio/renderer/vorbis.c index 51336ed76..bb9687025 100644 --- a/libs/audio/renderer/vorbis.c +++ b/libs/audio/renderer/vorbis.c @@ -34,8 +34,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; -#ifdef HAVE_VORBIS - #ifdef HAVE_STRING_H # include "string.h" #endif @@ -296,5 +294,3 @@ SND_LoadOgg (QFile *file, sfx_t *sfx, char *realname) } return 0; } - -#endif//HAVE_VORBIS