changeset 800:1fe6005ed58c

Make it so that both libSIDPlay2 and libSIDPlay-FP can co-exist, though not at run-time, but either one can be chosen via --with-/--without- configure options.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Nov 2012 11:58:46 +0200
parents 13483b855058
children c83c08b2ede4
files acinclude.m4 configure.ac src/config.h.in
diffstat 3 files changed, 54 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/acinclude.m4	Wed Nov 07 11:26:31 2012 +0200
+++ b/acinclude.m4	Wed Nov 07 11:58:46 2012 +0200
@@ -187,33 +187,66 @@
 dnl @SIDPLAY_LIBS@ will be substituted with linker parameters
 dnl @SIDPLAY_INCLUDES@ will be substituted with compiler parameters
 dnl -------------------------------------------------------------------------
-AC_DEFUN([XS_PATH_LIBSIDPLAY2],
+
+
+AC_DEFUN([XS_PATH_LIBSIDPLAYFP],
 [
-    AC_MSG_CHECKING([for working SIDPlay2/FP library and headers])
+    AC_MSG_CHECKING([for working SIDPlayFP library and headers])
 
     AC_LANG_PUSH([C++])
     
-    PKG_CHECK_EXISTS([libsidplay2 >= 2.1.1], [xs_pkg_sidplay2="yes"], [])
     PKG_CHECK_EXISTS([libsidplayfp >= 0.3.7], [xs_pkg_sidplayfp="yes"], [])
 
     if test "x$xs_pkg_sidplayfp" = "xyes"; then
         AC_CACHE_VAL([xs_cv_have_sidplayfp],
         [
-            xs_sidplay2_cflags=`$PKG_CONFIG --libs libsidplayfp`
-            xs_sidplay2_ldflags=`$PKG_CONFIG --libs libsidplayfp`
+            xs_sidplayfp_cflags=`$PKG_CONFIG --libs libsidplayfp`
+            xs_sidplayfp_ldflags=`$PKG_CONFIG --libs libsidplayfp`
 
-            XS_TRY_LIBRARY([sidplay2],
-                [$xs_sidplay2_cxxflags -DHAVE_UNIX], [$xs_sidplay2_ldflags],
+            XS_TRY_LIBRARY([sidplayfp],
+                [$xs_sidplayfp_cxxflags -DHAVE_UNIX], [$xs_sidplayfp_ldflags],
                 [sidplayfp], [sidplayfp/sidplay2.h], [sidplay2 *myEngine;])
 
-            if test "x$xs_sidplay2_works" = "xyes"; then
-              xs_cv_have_sidplay2="xs_have_sidplayfp=yes  \
-                xs_sidplay2_cxxflags=\"$xs_sidplay2_cxxflags\"  \
-                xs_sidplay2_ldflags=\"$xs_sidplay2_ldflags\""
+            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\""
             fi
         ])
+    fi
 
-    elif test "x$xs_pkg_sidplay2" = "xyes"; then
+    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
+
+        SIDPLAY2_LIBS="$xs_sidplayfp_ldflags"
+        SIDPLAY2_CFLAGS="$xs_sidplayfp_cxxflags"
+        AC_SUBST([SIDPLAY2_LIBS])dnl
+        AC_SUBST([SIDPLAY2_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],
         [
@@ -256,9 +289,8 @@
     fi
 
     eval "$xs_cv_have_sidplay2"
-    eval "$xs_cv_have_sidplayfp"
 
-    if test "x$xs_have_sidplay2" = "xyes" -o "x$xs_have_sidplayfp" = "xyes"; then
+    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
--- a/configure.ac	Wed Nov 07 11:26:31 2012 +0200
+++ b/configure.ac	Wed Nov 07 11:58:46 2012 +0200
@@ -97,7 +97,7 @@
 
 
 xs_have_sidplay2_api=""
-XS_ARG_WITH([sidplay2], [libSIDPlay2], [XS_PATH_LIBSIDPLAY2])
+XS_ARG_WITH([sidplayfp], [libSIDPlayFP], [XS_PATH_LIBSIDPLAYFP])
 
 if test "x$xs_have_sidplayfp" = "xyes"; then
 	xs_have_sidplay2_api="(FP)"
@@ -108,7 +108,9 @@
 	AC_DEFINE([HAVE_RESID_BUILDER])
 	AC_DEFINE([HAVE_RESID_FP_BUILDER])
 
-elif test "x$xs_have_sidplay2" = "xyes"; then
+else
+XS_ARG_WITH([sidplay2], [libSIDPlay2], [XS_PATH_LIBSIDPLAY2])
+if test "x$xs_have_sidplay2" = "xyes"; then
 	xs_have_sidplay2_api="(non-COMI)"
 	xs_have_sidplay2_lib="yes"
 	AC_DEFINE([HAVE_SIDPLAY2])
@@ -126,6 +128,7 @@
 
 	AC_LANG_POP([C++])
 fi
+fi
 
 
 dnl ***
--- a/src/config.h.in	Wed Nov 07 11:26:31 2012 +0200
+++ b/src/config.h.in	Wed Nov 07 11:58:46 2012 +0200
@@ -53,6 +53,9 @@
    http://sourceforge.net/projects/sidplay-residfp/ */
 #undef HAVE_SIDPLAY2_FP
 
+/* Define if you have and want to use libSIDPlayFP */
+#undef HAVE_SIDPLAYFP
+
 /* Define if you have XMMS patched with the songpos patch. */
 #undef HAVE_SONG_POSITION