From bb07299daed8577836aeb8388e94aa3c0c7bc833 Mon Sep 17 00:00:00 2001 From: bnnm Date: Mon, 20 Aug 2018 19:21:51 +0200 Subject: [PATCH] Make libvorbis/libmpg123 optional in autotools --- BUILD.md | 2 +- configure.ac | 34 +++++++++++++++++++------------- src/Makefile.autotools.am | 13 +++++++++++- src/layout/Makefile.autotools.am | 9 +++++++++ src/meta/Makefile.autotools.am | 9 +++++++++ 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/BUILD.md b/BUILD.md index 7f720a4a..4fc53ed6 100644 --- a/BUILD.md +++ b/BUILD.md @@ -85,7 +85,7 @@ Requires the dev version of Audacious (and dependencies), automake/autoconf, and The plugin needs Audacious 3.5 or higher. New Audacious releases can break plugin compatibility so it may not work with the latest version unless adapted first. -FFmpeg and other external libraries aren't enabled, thus some formats are not supported. libvorbis and libmpg123 can be disabled with -DVGM_DISABLE_VORBIS and -DVGM_DISABLE_MPEG. +libvorbis and libmpg123 will be used if found, while FFmpeg and other external libraries aren't enabled, thus some formats won't work. Windows builds aren't supported at the moment (should be possible but there are complex dependency chains). diff --git a/configure.ac b/configure.ac index 94f61852..3e4456d8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ -dnl audacious-vgmstream m4 script +dnl automake-vgmstream m4 script dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.53) -AC_INIT(audacious-vgmstream,1.3.0) +AC_INIT(automake-vgmstream,1.3.0) AM_INIT_AUTOMAKE([subdir-objects]) AC_CONFIG_HEADERS(audacious/config.h) AM_DISABLE_STATIC @@ -17,22 +17,28 @@ AM_PROG_LIBTOOL AC_PATH_X AC_PATH_XTRA +have_vorbis=no +PKG_CHECK_MODULES(VORBIS, [vorbis], have_vorbis=yes, + [AC_MSG_WARN([Cannot find libvorbis - will not enable Vorbis formats])] +) +AM_CONDITIONAL(HAVE_VORBIS, test "$have_vorbis" = yes) + +have_vorbisfile=no +PKG_CHECK_MODULES(VORBISFILE, [vorbisfile], have_vorbisfile=yes, + [AC_MSG_WARN([Cannot find libvorbisfile - will not enable Vorbis formats])] +) +AM_CONDITIONAL(HAVE_VORBISFILE, test "$have_vorbisfile" = yes) + +have_libmpg123=no +PKG_CHECK_MODULES(MPG123, [libmpg123], have_libmpg123=yes, + [AC_MSG_WARN([Cannot find libmpg123 - will not enable MPEG formats])] +) +AM_CONDITIONAL(HAVE_LIBMPG123, test "$have_libmpg123" = yes) + PKG_CHECK_MODULES(AUDACIOUS, [audacious >= 3.5.0],, [AC_MSG_ERROR([Cannot find audacious >= 3.5.0 correctly installed])] ) -PKG_CHECK_MODULES(VORBIS, [vorbis],, - [AC_MSG_ERROR([Cannot find libvorbis])] -) - -PKG_CHECK_MODULES(VORBISFILE, [vorbisfile],, - [AC_MSG_ERROR([Cannot find libvorbisfile])] -) - -PKG_CHECK_MODULES(MPG123, [libmpg123],, - [AC_MSG_ERROR([Cannot find libmpg123])] -) - PKG_CHECK_MODULES(GTK, [glib-2.0 >= 2.6.0 gtk+-2.0 >= 2.6.0 gthread-2.0 pango], , [AC_MSG_ERROR([Cannot find glib2/gtk2/pango])] ) diff --git a/src/Makefile.autotools.am b/src/Makefile.autotools.am index a15eb51f..68104532 100644 --- a/src/Makefile.autotools.am +++ b/src/Makefile.autotools.am @@ -11,6 +11,17 @@ SUBDIRS = coding layout meta libvgmstream_la_LDFLAGS = coding/libcoding.la layout/liblayout.la meta/libmeta.la libvgmstream_la_SOURCES = (auto-updated) libvgmstream_la_SOURCES += ../ext_libs/clHCA.c -libvgmstream_la_LIBADD = $(AUDACIOUS_LIBS) $(GTK_LIBS) $(VORBISFILE_LIBS) $(VORBIS_LIBS) $(MPG123_LIBS) -lm +libvgmstream_la_LIBADD = $(AUDACIOUS_LIBS) $(GTK_LIBS) -lm EXTRA_DIST = (auto-updated) EXTRA_DIST += ../ext_includes/clHCA.h + +if HAVE_VORBIS +if HAVE_VORBISFILE +AM_CFLAGS += -DVGM_USE_VORBIS +libvgmstream_la_LIBADD += $(VORBISFILE_LIBS) $(VORBIS_LIBS) +endif +endif +if HAVE_LIBMPG123 +AM_CFLAGS += -DVGM_USE_MPEG +libvgmstream_la_LIBADD += $(MPG123_LIBS) +endif diff --git a/src/layout/Makefile.autotools.am b/src/layout/Makefile.autotools.am index 9d0ea898..cd877881 100644 --- a/src/layout/Makefile.autotools.am +++ b/src/layout/Makefile.autotools.am @@ -9,3 +9,12 @@ AM_MAKEFLAGS=-f Makefile.autotools liblayout_la_LDFLAGS = liblayout_la_SOURCES = (auto-updated) EXTRA_DIST = (auto-updated) + +if HAVE_VORBIS +if HAVE_VORBISFILE +AM_CFLAGS += -DVGM_USE_VORBIS +endif +endif +if HAVE_LIBMPG123 +AM_CFLAGS += -DVGM_USE_MPEG +endif diff --git a/src/meta/Makefile.autotools.am b/src/meta/Makefile.autotools.am index 03a89813..c6081a67 100644 --- a/src/meta/Makefile.autotools.am +++ b/src/meta/Makefile.autotools.am @@ -9,3 +9,12 @@ AM_MAKEFLAGS=-f Makefile.autotools libmeta_la_LDFLAGS = libmeta_la_SOURCES = (auto-updated) EXTRA_DIST = (auto-updated) + +if HAVE_VORBIS +if HAVE_VORBISFILE +AM_CFLAGS += -DVGM_USE_VORBIS +endif +endif +if HAVE_LIBMPG123 +AM_CFLAGS += -DVGM_USE_MPEG +endif