Mercurial > hg > xmms-sid
view acinclude.m4 @ 957:0e60e5d56fdd
Change how the backend emulator library is initialized for libSIDPlay2 and
FP, as it seems the engine configuration has some persistence despite
reconfiguration between loaded files if same engine object is retained. This
caused, for example, 2SID stereo tunes being played "mono" if played after a
normal 1-SID tune. Duh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 20 Nov 2012 22:13:48 +0200 |
parents | 6820177eb6da |
children | a3ad20eb0f26 |
line wrap: on
line source
dnl *** These m4-macros are originally based on XSIDPLAY v1.6.5's acinclude.m4 dnl *** (C) Copyright 2002 Michael Schwendt, licensed under GNU GPL v2. dnl *** dnl *** Updated for new autotools, plus namespace, added portability dnl *** fixes and other minor changes by Matti 'ccr' Hamalainen dnl *** (C) Copyright 2003-2008 Tecnic Software productions (TNSP) AC_DEFUN([XS_CHECK_FEATURE], [ if test "x[]$$1" != "xyes"; then AC_MSG_ERROR([Required feature $2 not detected. See config.log for more information.]) fi ]) AC_DEFUN([XS_FIND_FILE], [ $3="" for i in $2; do for j in $1; do if test -r "$i/$j"; then $3="$i" break 2 fi done done ]) AC_DEFUN([XS_TRY_LIBRARY], [ AC_LANG_ASSERT([C++]) m4_ifvaln([$2], [xs_cxxflags_save="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $2"])dnl m4_ifvaln([$3], [xs_ldflags_save="$LDFLAGS" LDFLAGS="$LDFLAGS $3"])dnl m4_ifvaln([$4], [xs_libs_save="$LIBS" LIBS="$LIBS -l$4"])dnl AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [ #include <stdio.h> #include <$5> ], [$6] )], [xs_$1_works="yes"], [xs_$1_works="no"] ) m4_ifvaln([$2], [CXXFLAGS="$xs_cxxflags_save"])dnl m4_ifvaln([$3], [LDFLAGS="$xs_ldflags_save"])dnl m4_ifvaln([$4], [LIBS="$xs_libs_save"])dnl ]) AC_DEFUN([XS_ARG_WITH], [dnl define([Name], [translit([$1], [a-z], [A-Z])])dnl define([roflCopter], [Enable $2 with install-PREFIX])dnl AH_TEMPLATE(HAVE_[]Name, [Define if you have and want to use $2])dnl AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1=PREFIX], roflCopter)], [dnl if test "x$withval" = "xyes"; then xs_use_$1="yes" xs_$1_library="" xs_$1_includes="" else if test "x$withval" = "xno"; then xs_use_$1="no" else xs_use_$1="yes" xs_$1_includes="$withval/include" xs_$1_library="$withval/lib" fi fi ],[dnl xs_use_$1="try" xs_$1_library="" xs_$1_includes="" ])dnl define([roflCopter], [Where the $2 headers are located])dnl AC_ARG_WITH([$1-inc], [AS_HELP_STRING([--with-$1-inc=DIR], roflCopter)], [xs_$1_includes="$withval"])dnl define([roflCopter], [Where the $2 library is installed])dnl AC_ARG_WITH([$1-lib], [AS_HELP_STRING([--with-$1-lib=DIR], roflCopter)], [xs_$1_library="$withval"])dnl dnl Okay, handle this xs_have_$1="no" if test "x$xs_use_$1" = "xtry"; then $3 elif test "x$xs_use_$1" = "xyes"; then $3 if test "x$xs_have_$1" = "xno"; then AC_MSG_ERROR([$2 library and/or headers were not found!]) fi fi ]) dnl ------------------------------------------------------------------------- dnl Try to find SIDPLAY library and header files. dnl $xs_have_sidplay1 will be "yes" or "no" dnl @SIDPLAY1_LIBS@ will be substituted with linker parameters dnl @SIDPLAY1_INCLUDES@ will be substituted with compiler parameters dnl ------------------------------------------------------------------------- AC_DEFUN([XS_PATH_LIBSIDPLAY1], [ AC_MSG_CHECKING([for working SIDPlay1 library and headers]) AC_LANG_PUSH([C++]) dnl Use include path given by user (if any). if test "x$xs_sidplay1_includes" != "x"; then xs_sidplay1_cxxflags="-I$xs_sidplay1_includes" else xs_sidplay1_cxxflags="" fi dnl Use library path given by user (if any). if test "x$xs_sidplay1_library" != "x"; then xs_sidplay1_ldflags="-L$xs_sidplay1_library" else xs_sidplay1_ldflags="" fi AC_CACHE_VAL([xs_cv_have_sidplay1], [ dnl Run test compilation with either standard search path dnl or user-defined paths. XS_TRY_LIBSIDPLAY1 if test "x$xs_sidplay1_works" = "xyes"; then xs_cv_have_sidplay1="xs_have_sidplay1=yes \ xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" \ xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" " else XS_FIND_LIBSIDPLAY1 fi ]) eval "$xs_cv_have_sidplay1" if test "x$xs_have_sidplay1" = "xyes"; then if test "x$xs_sidplay1_cxxflags" != "x" || test "x$xs_sidplay1_ldflags" != "x"; then AC_MSG_RESULT([$xs_sidplay1_cxxflags $xs_sidplay1_ldflags -lsidplay]) else AC_MSG_RESULT([yes]) fi SIDPLAY1_LIBS="$xs_sidplay1_ldflags -lsidplay" SIDPLAY1_CFLAGS="$xs_sidplay1_cxxflags" AC_SUBST([SIDPLAY1_LIBS])dnl AC_SUBST([SIDPLAY1_CFLAGS])dnl else AC_MSG_RESULT([no]) fi AC_LANG_POP([C++]) ]) dnl Functions used by XS_PATH_LIBSIDPLAY1. AC_DEFUN([XS_FIND_LIBSIDPLAY1], [ dnl Search common locations where header files might be stored. XS_FIND_FILE([xs_sidplay1_includes], [sidplay/sidtune.h], [$xs_sidplay1_includes /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include /opt/sfw/include /opt/csw/include]) dnl Search common locations where library might be stored. XS_FIND_FILE([xs_sidplay1_library], [libsidplay.a libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37], [$xs_sidplay1_library /usr/lib /usr/lib/sidplay /usr/local/lib/sidplay /opt/sfw/lib /opt/csw/lib]) if test "x$xs_sidplay1_includes" = "x" || test "x$xs_sidplay1_library" = "x"; then xs_cv_have_sidplay1="xs_have_sidplay1=no \ xs_sidplay1_ldflags=\"\" xs_sidplay1_cxxflags=\"\" " else dnl Test compilation with found paths. xs_sidplay1_ldflags="-L$xs_sidplay1_library" xs_sidplay1_cxxflags="-I$xs_sidplay1_includes" XS_TRY_LIBSIDPLAY1 xs_cv_have_sidplay1="xs_have_sidplay1=$xs_sidplay1_works \ xs_sidplay1_ldflags=\"$xs_sidplay1_ldflags\" \ xs_sidplay1_cxxflags=\"$xs_sidplay1_cxxflags\" " fi ]) AC_DEFUN([XS_TRY_LIBSIDPLAY1],[ XS_TRY_LIBRARY([sidplay1], [$xs_sidplay1_cxxflags], [$xs_sidplay1_ldflags], [sidplay], [sidplay/sidtune.h], [sidTune* myTest = new sidTune(0);]) ]) dnl ------------------------------------------------------------------------- dnl Try to find SIDPLAY2 library and header files. dnl $xs_have_sidplay2 will be "yes" or "no" dnl @SIDPLAY_LIBS@ will be substituted with linker parameters dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters dnl ------------------------------------------------------------------------- AC_DEFUN([XS_PATH_LIBSIDPLAYFP], [ AC_MSG_CHECKING([for working SIDPlayFP library and headers]) AC_LANG_PUSH([C++]) PKG_CHECK_EXISTS([libsidplayfp >= 0.3.5], [xs_pkg_sidplayfp="yes"], []) PKG_CHECK_EXISTS([libsidplayfp >= 1.0.0], [xs_pkg_sidplayfp_v1="yes"], []) if test "x$xs_pkg_sidplayfp" = "xyes"; then AC_CACHE_VAL([xs_cv_have_sidplayfp], [ xs_sidplayfp_cflags=`$PKG_CONFIG --libs libsidplayfp` xs_sidplayfp_ldflags=`$PKG_CONFIG --libs libsidplayfp` if test "x$xs_pkg_sidplayfp_v1" = "xyes"; then XS_TRY_LIBRARY([sidplayfp], [$xs_sidplayfp_cxxflags -DHAVE_UNIX], [$xs_sidplayfp_ldflags], [sidplayfp], [sidplayfp/sidplayfp.h], [sidplayfp *myEngine;]) else XS_TRY_LIBRARY([sidplayfp], [$xs_sidplayfp_cxxflags -DHAVE_UNIX], [$xs_sidplayfp_ldflags], [sidplayfp], [sidplayfp/sidplay2.h], [sidplay2 *myEngine;]) fi if test "x$xs_sidplayfp_works" = "xyes"; then xs_cv_have_sidplayfp="xs_have_sidplayfp=yes \ xs_sidplayfp_cxxflags=\"$xs_sidplayfp_cxxflags\" \ xs_sidplayfp_ldflags=\"$xs_sidplayfp_ldflags\" \ xs_pkg_sidplayfp_v1=\"$xs_pkg_sidplayfp_v1\" " fi ]) fi eval "$xs_cv_have_sidplayfp" if test "x$xs_have_sidplayfp" = "xyes"; then if test "x$xs_sidplayfp_cxxflags" != "x" || test "x$xs_sidplayfp_ldflags" != "x"; then AC_MSG_RESULT([$xs_sidplayfp_cxxflags $xs_sidplayfp_ldflags]) else AC_MSG_RESULT([yes]) fi SIDPLAYFP_LIBS="$xs_sidplayfp_ldflags" SIDPLAYFP_CFLAGS="$xs_sidplayfp_cxxflags" AC_SUBST([SIDPLAYFP_LIBS])dnl AC_SUBST([SIDPLAYFP_CFLAGS])dnl else AC_MSG_RESULT([no]) fi AC_LANG_POP([C++]) ]) AC_DEFUN([XS_PATH_LIBSIDPLAY2], [ AC_MSG_CHECKING([for working SIDPlay2 library and headers]) AC_LANG_PUSH([C++]) PKG_CHECK_EXISTS([libsidplay2 >= 2.1.1], [xs_pkg_sidplay2="yes"], []) if test "x$xs_pkg_sidplay2" = "xyes"; then AC_CACHE_VAL([xs_cv_have_sidplay2], [ xs_sidplay2_cflags=`$PKG_CONFIG --libs libsidplay2` xs_sidplay2_ldflags=`$PKG_CONFIG --libs libsidplay2` dnl Derive sidbuilders path from libsidplay2 root. if test "x$xs_sidplay2_library" != "x"; then xs_sidplay2_builders="$xs_sidplay2_library/sidplay/builders" else xs_sidplay2_builders=`$PKG_CONFIG --variable=builders libsidplay2` fi dnl *** Check for new COMI API xs_api_ok="yes" AC_MSG_CHECKING([libSIDPlay2 API compatibility]) tmp_CPPFLAGS="$CPPFLAGS" if test -d "$xs_sidplay2_includes"; then CPPFLAGS="$CPPFLAGS -I${xs_sidplay2_includes}" fi AC_EGREP_HEADER([::Iid], [sidplay/sidplay2.h], [xs_api_ok="no"], [ AC_EGREP_HEADER([SIDIID], [sidplay/sidplay2.h], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sidplay/sidunknown.h>], [ISidUnknown *i;])], [xs_api_ok="no"], [])]) ]) if test "x$xs_api_ok" = "xyes"; then XS_TRY_LIBRARY([sidplay2], [$xs_sidplay2_cxxflags -DHAVE_UNIX], [$xs_sidplay2_ldflags], [sidplay2], [sidplay/sidplay2.h], [sidplay2 *myEngine;]) fi if test "x$xs_sidplay2_works" = "xyes"; then xs_cv_have_sidplay2="xs_have_sidplay2=yes \ xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\" \ xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\" \ xs_sidplay2_builders=\"$xs_sidplay2_builders\" " fi ]) fi eval "$xs_cv_have_sidplay2" if test "x$xs_have_sidplay2" = "xyes"; then if test "x$xs_sidplay2_cxxflags" != "x" || test "x$xs_sidplay2_ldflags" != "x"; then AC_MSG_RESULT([$xs_sidplay2_cxxflags $xs_sidplay2_ldflags]) else AC_MSG_RESULT([yes]) fi SIDPLAY2_LIBS="$xs_sidplay2_ldflags" SIDPLAY2_CFLAGS="$xs_sidplay2_cxxflags" AC_SUBST([SIDPLAY2_LIBS])dnl AC_SUBST([SIDPLAY2_CFLAGS])dnl else AC_MSG_RESULT([no]) fi AC_LANG_POP([C++]) ]) dnl ------------------------------------------------------------------------- dnl Find libsidplay2 builders (sidbuilders) dir. dnl @BUILDERS_CFLAGS@ dnl @BUILDERS_LDFLAGS@ dnl ------------------------------------------------------------------------- AC_DEFUN([XS_BUILDERS_CHECK], [ AC_MSG_CHECKING([for SIDPlay2 builders directory]) AC_LANG_ASSERT([C++]) AC_REQUIRE([XS_PATH_LIBSIDPLAY2]) dnl Sidbuilder headers are included with "builders" prefix. builders_includedir="$xs_sidplay2_includes" builders_libdir="$xs_sidplay2_builders" dnl If libsidplay2 is in standard library search path, we need dnl to get an argument whether /usr, /usr/local, etc. Else we dnl can only use ${libdir}/sidplay/builders, but then are dnl unable to check whether files exist as long as ${exec_prefix} dnl is not defined in the configure script. So, this is a bit dnl ugly, but a satisfactory fallback default for those who dnl define ${prefix} and ${exec_prefix}. if test "x$builders_libdir" = "x"; then eval "builders_libdir=$libdir/sidplay/builders" fi AC_ARG_WITH([sidbuilders], [AS_HELP_STRING([--with-sidbuilders=DIR], [What the SIDPlay2 builders install PREFIX is])], [builders_includedir="$withval/include" builders_libdir="$withval/lib/sidplay/builders"]) AC_ARG_WITH([builders-inc], [AS_HELP_STRING([--with-builders-inc=DIR], [Where the SIDPlay2 builders headers are located])], [builders_includedir="$withval"]) AC_ARG_WITH([builders-lib], [AS_HELP_STRING([--with-builders-lib=DIR], [Where the SIDPlay2 builders libraries are installed])], [builders_libdir="$withval"]) if test "x$builders_includedir" != "x"; then BUILDERS_CFLAGS="-I$builders_includedir" fi if test "x$builders_libdir" != "x"; then BUILDERS_LDFLAGS="-L$builders_libdir" fi if test -d "$builders_libdir"; then xs_have_sidbuilders_dir="yes" AC_MSG_RESULT([$builders_libdir]) else xs_have_sidbuilders_dir="no" AC_MSG_RESULT([$xs_have_sidbuilders_dir]) AC_MSG_ERROR([$builders_libdir not found! Check --help on how to specify SIDPlay2 and/or builders library and header path, or set --exec-prefix to the same prefix as your installation of libsidplay2. ]) fi AC_SUBST([BUILDERS_CFLAGS]) AC_SUBST([BUILDERS_LDFLAGS]) ]) dnl ------------------------------------------------------------------------- dnl Test for working builders dnl ------------------------------------------------------------------------- AC_DEFUN([XS_BUILDERS_FIND], [dnl define([Name], [translit([$1], [a-z], [A-Z])])dnl AH_TEMPLATE(HAVE_[]Name[]_BUILDER, [Define if you have $1 for libSIDPlay 2]) AC_MSG_CHECKING([for $1 builder module]) XS_TRY_LIBRARY([builders], [$BUILDERS_CFLAGS], [$BUILDERS_LDFLAGS], [$2], [sidplay/builders/$3], [$4 *sid;]) if test "x$xs_builders_works" = "xyes"; then xs_builders_available="yes" xs_builders="$1 $xs_builders" AC_DEFINE(HAVE_[]Name[]_BUILDER) BUILDERS_LIBS="$BUILDERS_LIBS -l$2" fi AC_MSG_RESULT([$xs_builders_works]) AC_SUBST([BUILDERS_LIBS]) ])