From 7b161e5c41bbefc93eae703ff7842b5c650638e0 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 19 May 2012 01:05:43 +0200 Subject: [PATCH] Make using mpg123 optional, add option to linux build system Added so people can make patent-free builds (easily), for example for patent-free distro's --- configure.in | 13 ++++++++----- src/modules/sound/lullaby/Mpg123Decoder.cpp | 4 ++++ src/modules/sound/lullaby/Mpg123Decoder.h | 2 ++ src/modules/sound/lullaby/Sound.cpp | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index 12d6fd1b3..dace4d313 100644 --- a/configure.in +++ b/configure.in @@ -55,12 +55,15 @@ AC_SEARCH_LIBS([ilInit], [IL], [], AC_MSG_ERROR([Can't LÖVE without DevIL])) AC_SEARCH_LIBS([FT_Load_Glyph], [freetype], [], AC_MSG_ERROR([Can't LÖVE without FreeType])) AC_SEARCH_LIBS([PHYSFS_init], [physfs], [], AC_MSG_ERROR([Can't LÖVE without PhysicsFS])) AC_SEARCH_LIBS([ModPlug_Load], [modplug], [], AC_MSG_ERROR([Can't LÖVE without ModPlug])) -AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [], AC_MSG_ERROR([Can't LÖVE without Mpg123])) -AC_SEARCH_LIBS([mpg123_seek_64], [mpg123], AC_SUBST([FILE_OFFSET],[-D_FILE_OFFSET_BITS=64]), AC_SUBST([FILE_OFFSET],[])) AC_SEARCH_LIBS([ov_open], [vorbisfile], [], AC_MSG_ERROR([Can't LÖVE without VorbisFile])) -AC_ARG_ENABLE([headless], - [ --enable-headless Build with less SDL], - AC_DEFINE([LOVE_HEADLESS], [], [Build with less SDL]), []) + +AC_ARG_ENABLE([mpg123], AC_HELP_STRING([--disable-mpg123], [Disable mp3 support, for patent-free builds]), [], [enable_mpg123=yes]) +AS_IF([test "x$enable_mpg123" != xno], + AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [], AC_MSG_ERROR([Can't LÖVE without Mpg123])), + AC_DEFINE([LOVE_NOMPG123], [], [Build without mpg123])) +AS_IF([test "x$enable_mpg123" != xno], + AC_SEARCH_LIBS([mpg123_seek_64], [mpg123], AC_SUBST([FILE_OFFSET],[-D_FILE_OFFSET_BITS=64]), AC_SUBST([FILE_OFFSET],[]))) + AC_CONFIG_FILES([ Makefile src/Makefile diff --git a/src/modules/sound/lullaby/Mpg123Decoder.cpp b/src/modules/sound/lullaby/Mpg123Decoder.cpp index d5e305d69..f5520a517 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.cpp +++ b/src/modules/sound/lullaby/Mpg123Decoder.cpp @@ -18,6 +18,8 @@ * 3. This notice may not be removed or altered from any source distribution. **/ +#ifndef LOVE_NOMPG123 + #include "Mpg123Decoder.h" #include @@ -229,3 +231,5 @@ namespace lullaby } // lullaby } // sound } // love + +#endif // LOVE_NOMPG123 diff --git a/src/modules/sound/lullaby/Mpg123Decoder.h b/src/modules/sound/lullaby/Mpg123Decoder.h index 42954ec91..9fd3fb846 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.h +++ b/src/modules/sound/lullaby/Mpg123Decoder.h @@ -18,6 +18,7 @@ * 3. This notice may not be removed or altered from any source distribution. **/ +#ifndef LOVE_NOMPG123 #ifndef LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H #define LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H @@ -77,3 +78,4 @@ namespace lullaby } // love #endif // LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H +#endif // LOVE_NOMPG123 diff --git a/src/modules/sound/lullaby/Sound.cpp b/src/modules/sound/lullaby/Sound.cpp index dc0265d35..f582907a1 100644 --- a/src/modules/sound/lullaby/Sound.cpp +++ b/src/modules/sound/lullaby/Sound.cpp @@ -37,7 +37,9 @@ namespace lullaby Sound::~Sound() { +#ifndef LOVE_NOMPG123 Mpg123Decoder::quit(); +#endif // LOVE_NOMPG123 } const char * Sound::getName() const @@ -55,8 +57,10 @@ namespace lullaby // Find a suitable decoder here, and return it. if (ModPlugDecoder::accepts(ext)) decoder = new ModPlugDecoder(data, ext, bufferSize); +#ifndef LOVE_NOMPG123 else if (Mpg123Decoder::accepts(ext)) decoder = new Mpg123Decoder(data, ext, bufferSize); +#endif // LOVE_NOMPG123 else if (VorbisDecoder::accepts(ext)) decoder = new VorbisDecoder(data, ext, bufferSize); /*else if (FLACDecoder::accepts(ext))