Skip to content

Commit

Permalink
Added dynamic library loading support for mpg123
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Oct 18, 2017
1 parent 453c94f commit db8ede7
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 69 deletions.
120 changes: 85 additions & 35 deletions configure
Expand Up @@ -920,6 +920,7 @@ with_smpeg_exec_prefix
enable_smpegtest
enable_music_mp3_mad_gpl
enable_music_mp3_mpg123
enable_music_mp3_mpg123_shared
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1591,7 +1592,9 @@ Optional Features:
--enable-music-mp3-mad-gpl
enable MP3 music via libmad GPL code [[default=no]]
--enable-music-mp3-mpg123
enable MP3 music via libmpg123 [[default=no]]
enable MP3 music via libmpg123 [[default=yes]]
--enable-music-mp3-mpg123-shared
dynamically load libmpg123 library [[default=yes]]

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
Expand Down Expand Up @@ -3924,13 +3927,13 @@ if ${lt_cv_nm_interface+:} false; then :
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:3927: $ac_compile\"" >&5)
(eval echo "\"\$as_me:3930: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
(eval echo "\"\$as_me:3930: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval echo "\"\$as_me:3933: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
(eval echo "\"\$as_me:3933: output\"" >&5)
(eval echo "\"\$as_me:3936: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
Expand Down Expand Up @@ -5141,7 +5144,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 5144 "configure"' > conftest.$ac_ext
echo '#line 5147 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
Expand Down Expand Up @@ -6971,11 +6974,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:6974: $lt_compile\"" >&5)
(eval echo "\"\$as_me:6977: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:6978: \$? = $ac_status" >&5
echo "$as_me:6981: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -7310,11 +7313,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7313: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7316: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7317: \$? = $ac_status" >&5
echo "$as_me:7320: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -7415,11 +7418,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7418: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7421: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:7422: \$? = $ac_status" >&5
echo "$as_me:7425: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -7470,11 +7473,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7473: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7476: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:7477: \$? = $ac_status" >&5
echo "$as_me:7480: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -9839,7 +9842,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 9842 "configure"
#line 9845 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -9935,7 +9938,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 9938 "configure"
#line 9941 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12217,7 +12220,7 @@ fi
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
echo "-- dynamic libfluidsyth -> $fluidsynth_lib"
echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
Expand Down Expand Up @@ -12887,41 +12890,88 @@ fi
if test "${enable_music_mp3_mpg123+set}" = set; then :
enableval=$enable_music_mp3_mpg123;
else
enable_music_mp3_mpg123=no
enable_music_mp3_mpg123=yes
fi

if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mpg123 = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmpg123 headers" >&5
$as_echo_n "checking for libmpg123 headers... " >&6; }
have_libmpg123=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
# Check whether --enable-music-mp3-mpg123-shared was given.
if test "${enable_music_mp3_mpg123_shared+set}" = set; then :
enableval=$enable_music_mp3_mpg123_shared;
else
enable_music_mp3_mpg123_shared=yes
fi

if test x$enable_music_mp3_mpg123 = xyes; then
ac_fn_c_check_header_mongrel "$LINENO" "mpg123.h" "ac_cv_header_mpg123_h" "$ac_includes_default"
if test "x$ac_cv_header_mpg123_h" = xyes; then :
have_mpg123_hdr=yes
fi

#include "mpg123.h"

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpg123_init in -lmpg123" >&5
$as_echo_n "checking for mpg123_init in -lmpg123... " >&6; }
if ${ac_cv_lib_mpg123_mpg123_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmpg123 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char mpg123_init ();
int
main ()
{
return mpg123_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :

have_libmpg123=yes

if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_mpg123_mpg123_init=yes
else
ac_cv_lib_mpg123_mpg123_init=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_libmpg123" >&5
$as_echo "$have_libmpg123" >&6; }
if test x$have_libmpg123 = xyes; then
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpg123_mpg123_init" >&5
$as_echo "$ac_cv_lib_mpg123_mpg123_init" >&6; }
if test "x$ac_cv_lib_mpg123_mpg123_init" = xyes; then :
have_mpg123_lib=yes
fi

if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
have_mpg123=yes
case "$host" in
*-*-darwin*)
mpg123_lib=`find_lib libmpg123.dylib`
;;
*-*-cygwin* | *-*-mingw32*)
mpg123_lib=`find_lib "libmpg123*.dll"`
;;
*)
mpg123_lib=`find_lib "libmpg123.so.*"`
;;
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
echo "-- dynamic libmpg123 -> $mpg123_lib"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&5
$as_echo "$as_me: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mpg123 support disabled" >&5
$as_echo "$as_me: WARNING: mpg123 support disabled" >&2;}
fi
fi

Expand Down
44 changes: 29 additions & 15 deletions configure.in
Expand Up @@ -420,7 +420,7 @@ AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidS
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
echo "-- dynamic libfluidsyth -> $fluidsynth_lib"
echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
Expand Down Expand Up @@ -627,23 +627,37 @@ if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
fi

AC_ARG_ENABLE(music-mp3-mpg123,
AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=no]]]),
[], [enable_music_mp3_mpg123=no])
if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mpg123 = xyes; then
AC_MSG_CHECKING(for libmpg123 headers)
have_libmpg123=no
AC_TRY_COMPILE([
#include "mpg123.h"
],[
],[
have_libmpg123=yes
])
AC_MSG_RESULT($have_libmpg123)
if test x$have_libmpg123 = xyes; then
AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]),
[], [enable_music_mp3_mpg123=yes])
AC_ARG_ENABLE([music-mp3-mpg123-shared],
AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]),
[], [enable_music_mp3_mpg123_shared=yes])
if test x$enable_music_mp3_mpg123 = xyes; then
AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
AC_CHECK_LIB([mpg123], [mpg123_init], [have_mpg123_lib=yes])
if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
have_mpg123=yes
case "$host" in
*-*-darwin*)
mpg123_lib=[`find_lib libmpg123.dylib`]
;;
*-*-cygwin* | *-*-mingw32*)
mpg123_lib=[`find_lib "libmpg123*.dll"`]
;;
*)
mpg123_lib=[`find_lib "libmpg123.so.*"`]
;;
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
echo "-- dynamic libmpg123 -> $mpg123_lib"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
fi
else
AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
AC_MSG_WARN([mpg123 support disabled])
fi
fi

Expand Down

0 comments on commit db8ede7

Please sign in to comment.