diff --git a/Makefile.am b/Makefile.am index af77d2ae..c08b3529 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,6 +40,26 @@ AM_CPPFLAGS += \ -I$(top_srcdir)/src/compat \ -I$(top_srcdir)/src/common +# Automake cannot handle dependencies behind an autoconf expansion. +# So we need elaborate ifelsery here to make it see the libtool +# files for dependency rule generation. That is stupid. One point +# for those usurping build systems with new flaws. +if BUILD_LIBMPG123 +LIBMPG123 = src/libmpg123/libmpg123.la +else +LIBMPG123 = @LIBMPG123_LD@ +endif +if BUILD_LIBOUT123 +LIBOUT123 = src/libout123/libout123.la +else +LIBOUT123 = @LIBOUT123_LD@ +endif +if BUILD_LIBSYN123 +LIBSYN123 = src/libsyn123/libsyn123.la +else +LIBSYN123 = @LIBSYN123_LD@ +endif + # Include Make modules from subdirectories. include src/Makemodule.am include doc/Makemodule.am diff --git a/NEWS b/NEWS index c353896f..b9c2cb7d 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,12 @@ -- Get rid of SIZE_P, OFF_P and friends. -- Only enforce dummy module together with libout123, to be able to build individual modules using --disable-components logic. +-- Allow building of programs with installed mpg123 libraries (--enable-programs, + using pkg-config to locate libmpg123 et al., prompted by + https://github.com/madebr/mpg123/pull/11). +-- Only libmpg123 component installs fmt123.h. +- out123: +-- added --libversion 1.32.3 ------ diff --git a/configure.ac b/configure.ac index e47c7d5b..bfd2d583 100644 --- a/configure.ac +++ b/configure.ac @@ -380,6 +380,21 @@ AC_ARG_ENABLE(components, ] ) +AC_ARG_ENABLE(programs, + [AS_HELP_STRING([--enable-programs], [build (only) programs (with --disable-components)])], + [ + if test "x$enableval" = xyes + then + build_programs=yes + else + build_programs=no + fi + ], + [ + build_programs=no + ] +) + AC_ARG_ENABLE(libmpg123, [AS_HELP_STRING([--enable-libmpg123], [build (only) libmpg123 (with --disable-components)])], [ @@ -446,34 +461,69 @@ if test "x$build_all" = xyes; then build_libout123=yes build_libout123_modules=yes build_libsyn123=yes - components="programs" -else - build_programs=no fi AM_CONDITIONAL([BUILD_PROGRAMS], [ test "x$build_programs" = xyes ]) AM_CONDITIONAL([BUILD_LIBMPG123], [ test "x$build_libmpg123" = xyes ]) AM_CONDITIONAL([BUILD_LIBOUT123], [ test "x$build_libout123" = xyes ]) AM_CONDITIONAL([BUILD_LIBOUT123_MODULES], [ test "x$build_libout123_modules" = xyes ]) +AM_CONDITIONAL([BUILD_LIBOUT123_OR_MODULES], [ test "x$build_libout123" = xyes || test "x$build_libout123_modules" = xyes ]) AM_CONDITIONAL([BUILD_LIBSYN123], [ test "x$build_libsyn123" = xyes ]) -AM_CONDITIONAL([NEED_FMT123], [ test "x$build_libmpg123" = xyes || test "x$build_libout123" = xyes || test "x$build_libsyn123" = xyes ]) # If we install libraries, prompting pkgconfig and include directories. AM_CONDITIONAL([NEED_LIB], [ test "x$build_libmpg123" = xyes || test "x$build_libout123" = xyes || test "x$build_libout123_modules" = xyes || test "x$build_libsyn123" = xyes ]) AM_CONDITIONAL([NEED_MAINLIB], [ test "x$build_libmpg123" = xyes || test "x$build_libout123" = xyes || test "x$build_libsyn123" = xyes ]) +dnl Some support for using separately installed lib*123. This is not perfect, +dnl with per-library CFLAGS just being lumped into global CFLAGS. So do not +dnl expect to mix differing prefixes with possibly conflicting versions of +dnl the libraries. The expectation is a version matching this source distribution, +dnl anyway. + +missing_lib=no + +components="" + +if test "x$build_programs" = xyes; then + components="$components programs" +fi +LIBMPG123_LD=abugifused if test "x$build_libmpg123" = xyes; then components="$components libmpg123" +elif test "x$build_programs" = xyes; then + PKG_CHECK_MODULES(LIBMPG123_PKG, libmpg123, HAVE_LIBMPG123="yes", HAVE_LIBMPG123="no" missing_lib=yes) + CFLAGS="$CFLAGS $LIBMPG123_PKG_CFLAGS" + LIBMPG123_LD="$LIBMPG123_PKG_LIBS" fi +LIBOUT123_LD=abugifused if test "x$build_libout123" = xyes; then components="$components libout123" +elif test "x$build_programs" = xyes; then + PKG_CHECK_MODULES(LIBOUT123_PKG, libout123, HAVE_LIBOUT123="yes", HAVE_LIBOUT123="no" missing_lib=yes) + CFLAGS="$CFLAGS $LIBOUT123_PKG_CFLAGS" + LIBOUT123_LD="$LIBOUT123_PKG_LIBS" fi if test "x$build_libout123_modules" = xyes; then components="$components libout123-modules" fi +LIBSYN123=abugifused if test "x$build_libsyn123" = xyes; then components="$components libsyn123" +elif test "x$build_programs" = xyes; then + PKG_CHECK_MODULES(LIBSYN123_PKG, libsyn123, HAVE_LIBSYN123="yes", HAVE_LIBSYN123="no" missing_lib=yes) + CFLAGS="$CFLAGS $LIBSYN123_PKG_CFLAGS" + LIBSYN123_LD="$LIBSYN123_PKG_LIBS" fi + +if test "x$missing_lib" = xyes; then + AC_MSG_ERROR([Missing an external mpg123 library for the programs.]) +fi + +dnl Stupid names because @foo@ cannot coexist with foo. +AC_SUBST(LIBMPG123_LD) +AC_SUBST(LIBOUT123_LD) +AC_SUBST(LIBSYN123_LD) + components=$(echo $components) dnl ############## Configurable Options diff --git a/ports/cmake/src/libmpg123/CMakeLists.txt b/ports/cmake/src/libmpg123/CMakeLists.txt index 64b37540..d565867d 100644 --- a/ports/cmake/src/libmpg123/CMakeLists.txt +++ b/ports/cmake/src/libmpg123/CMakeLists.txt @@ -254,6 +254,6 @@ install(TARGETS ${TARGET} EXPORT targets RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/mpg123.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/fmt123.h" +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/fmt123.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/src/Makemodule.am b/src/Makemodule.am index 48632b57..fbde8788 100644 --- a/src/Makemodule.am +++ b/src/Makemodule.am @@ -23,17 +23,17 @@ endif src_mpg123_LDADD = \ src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - src/libout123/libout123.la \ - src/libsyn123/libsyn123.la \ + $(LIBMPG123) \ + $(LIBOUT123) \ + $(LIBSYN123) \ @PROG_LIBS@ src_mpg123_LDFLAGS = @EXEC_LT_LDFLAGS@ src_out123_LDADD = \ src/compat/libcompat.la \ - src/libsyn123/libsyn123.la \ - src/libout123/libout123.la \ + $(LIBSYN123) \ + $(LIBOUT123) \ @PROG_LIBS@ src_out123_LDFLAGS = @EXEC_LT_LDFLAGS@ @@ -47,12 +47,12 @@ CLEANFILES += src/*.a src_mpg123_id3dump_LDADD = \ src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ + $(LIBMPG123) \ @PROG_LIBS@ src_mpg123_strip_LDADD = \ src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ + $(LIBMPG123) \ @PROG_LIBS@ src_mpg123_SOURCES = \ diff --git a/src/libmpg123/fmt123.h b/src/fmt123.h similarity index 100% rename from src/libmpg123/fmt123.h rename to src/fmt123.h diff --git a/src/libmpg123/Makemodule.am b/src/libmpg123/Makemodule.am index 2557154a..00ae4788 100644 --- a/src/libmpg123/Makemodule.am +++ b/src/libmpg123/Makemodule.am @@ -21,9 +21,9 @@ src_libmpg123_calctables_LDADD = @LIBM@ if BUILD_LIBMPG123 lib_LTLIBRARIES += src/libmpg123/libmpg123.la include_HEADERS += src/libmpg123/mpg123.h -endif -if NEED_FMT123 -include_HEADERS += src/libmpg123/fmt123.h +# All libs need it, but only libmpg123 installs it. +# Placing it in src/ helps other components to always find it. +include_HEADERS += src/fmt123.h endif src_libmpg123_libmpg123_la_CFLAGS = @LIB_CFLAGS@ @@ -39,7 +39,7 @@ src_libmpg123_libmpg123_la_DEPENDENCIES = \ src/compat/libcompat.la src_libmpg123_libmpg123_la_SOURCES = \ - src/libmpg123/fmt123.h \ + src/fmt123.h \ src/libmpg123/mpeghead.h \ src/libmpg123/parse.c \ src/libmpg123/parse.h \ diff --git a/src/libout123/modules/Makemodule.am b/src/libout123/modules/Makemodule.am index e04c07e4..4d87308e 100644 --- a/src/libout123/modules/Makemodule.am +++ b/src/libout123/modules/Makemodule.am @@ -761,6 +761,7 @@ src_libout123_modules_libdefaultmodule_la_CPPFLAGS = \ endif endif +if BUILD_LIBOUT123_OR_MODULES if HAVE_MODULES # Get rid of .la files, at least _after_ install. install-exec-hook: @@ -769,3 +770,4 @@ install-exec-hook: uninstall-hook: for m in @output_modules_la@; do eval $$(grep dlname= src/libout123/modules/$$m) && rm -f $(DESTDIR)$(pkglibdir)/$$dlname; done endif +endif diff --git a/src/libout123/modules/aix.c b/src/libout123/modules/aix.c index fde2829c..b26b14a8 100644 --- a/src/libout123/modules/aix.c +++ b/src/libout123/modules/aix.c @@ -8,7 +8,7 @@ untested since quite some years now ... */ -#include "out123_int.h" +#include "../out123_int.h" #include #include diff --git a/src/libout123/modules/alib.c b/src/libout123/modules/alib.c index c16872e6..0e60f9b7 100644 --- a/src/libout123/modules/alib.c +++ b/src/libout123/modules/alib.c @@ -30,7 +30,7 @@ /**************************************************************************/ -#include "out123_int.h" +#include "../out123_int.h" #include diff --git a/src/libout123/modules/alsa.c b/src/libout123/modules/alsa.c index b76cadaf..ad94d4cb 100644 --- a/src/libout123/modules/alsa.c +++ b/src/libout123/modules/alsa.c @@ -17,7 +17,7 @@ /* Things are still missing if _DEFAULT_SOURCE is not defined (for recent glibc, I presume. */ #define _DEFAULT_SOURCE -#include "out123_int.h" +#include "../out123_int.h" #include /* make ALSA 0.9.x compatible to the 1.0.x API */ diff --git a/src/libout123/modules/arts.c b/src/libout123/modules/arts.c index 4b5b7e14..70168499 100644 --- a/src/libout123/modules/arts.c +++ b/src/libout123/modules/arts.c @@ -8,7 +8,7 @@ */ -#include "out123_int.h" +#include "../out123_int.h" #include #include "debug.h" diff --git a/src/libout123/modules/coreaudio.c b/src/libout123/modules/coreaudio.c index 48ab495a..665c9d87 100644 --- a/src/libout123/modules/coreaudio.c +++ b/src/libout123/modules/coreaudio.c @@ -9,7 +9,7 @@ */ -#include "out123_int.h" +#include "../out123_int.h" /* has been around since at least 10.4 */ #include @@ -44,7 +44,7 @@ /* Including the sfifo code locally, to avoid module linkage issues. */ #define SFIFO_STATIC -#include "sfifo.c" +#include "../sfifo.c" #include "debug.h" diff --git a/src/libout123/modules/dummy.c b/src/libout123/modules/dummy.c index a98faa79..83caa096 100644 --- a/src/libout123/modules/dummy.c +++ b/src/libout123/modules/dummy.c @@ -5,7 +5,7 @@ see COPYING and AUTHORS files in distribution or http://mpg123.org */ -#include "out123_int.h" +#include "../out123_int.h" #include "debug.h" static int open_dummy(out123_handle *ao) diff --git a/src/libout123/modules/esd.c b/src/libout123/modules/esd.c index 408758f8..1b80b224 100644 --- a/src/libout123/modules/esd.c +++ b/src/libout123/modules/esd.c @@ -8,7 +8,7 @@ /* First the common header, including config.h ...this is important for stuff like _FILE_OFFSET_BITS */ -#include "out123_int.h" +#include "../out123_int.h" #include #include diff --git a/src/libout123/modules/hp.c b/src/libout123/modules/hp.c index 255b1985..734ace91 100644 --- a/src/libout123/modules/hp.c +++ b/src/libout123/modules/hp.c @@ -6,7 +6,7 @@ initially written by Michael Hipp */ -#include "out123_int.h" +#include "../out123_int.h" #include #include #include "debug.h" diff --git a/src/libout123/modules/jack.c b/src/libout123/modules/jack.c index fa9d836b..f6fa6818 100644 --- a/src/libout123/modules/jack.c +++ b/src/libout123/modules/jack.c @@ -14,7 +14,7 @@ There's always a deadlock. --ThOr */ -#include "out123_int.h" +#include "../out123_int.h" #include diff --git a/src/libout123/modules/mint.c b/src/libout123/modules/mint.c index dbcf0c45..bd607bb3 100644 --- a/src/libout123/modules/mint.c +++ b/src/libout123/modules/mint.c @@ -6,7 +6,7 @@ initially written by Petr Stehlik */ -#include "out123_int.h" +#include "../out123_int.h" /* derived from LINUX, VOXWARE and SUN for MiNT Audio Device by Petr Stehlik */ #include diff --git a/src/libout123/modules/nas.c b/src/libout123/modules/nas.c index 2e29723b..2c083029 100644 --- a/src/libout123/modules/nas.c +++ b/src/libout123/modules/nas.c @@ -6,7 +6,7 @@ initially written by Martin Denn */ -#include "out123_int.h" +#include "../out123_int.h" #include #include