changeset 125:532ec0ad5e59

Added support/detection for libNanoSID.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 14 Jan 2004 03:56:01 +0000
parents c8f97c889f55
children 4f4dba82011e
files acinclude.m4 configure.in
diffstat 2 files changed, 173 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/acinclude.m4	Wed Jan 14 03:55:05 2004 +0000
+++ b/acinclude.m4	Wed Jan 14 03:56:01 2004 +0000
@@ -71,6 +71,7 @@
     xs_libs_save="$LIBS"
 ])
 
+
 AC_DEFUN(MY_TRY_LINK_RESTORE,
 [
     CXX="$xs_cxx_save"
@@ -79,11 +80,13 @@
     LIBS="$xs_libs_save"
 ])
 
+
 AC_DEFUN(MY_PROG_PKGCONFIG,
 [
     AC_PATH_PROG(PKG_CONFIG, pkg-config, "")
 ])
 
+
 AC_DEFUN(MY_NEED_PKGCONFIG,
 [
     AC_REQUIRE([MY_PROG_PKGCONFIG])
@@ -473,3 +476,111 @@
     AC_SUBST(HARDSID_LDADD)
     AC_LANG_POP(C++)
 ])
+
+
+dnl -------------------------------------------------------------------------
+dnl Try to find NanoSID library and header files.
+dnl $xs_have_nanosid will be "yes" or "no"
+dnl @NANOSID_LDADD@ will be substituted with linker parameters
+dnl @NANOSID_INCLUDES@ will be substituted with compiler parameters
+dnl -------------------------------------------------------------------------
+
+AC_DEFUN(XS_PATH_LIBNANOSID,
+[
+    AC_MSG_CHECKING([for working NanoSID library and headers])
+
+    AC_LANG_PUSH(C)
+
+    # Use include path given by user (if any).
+    if test -n "$xs_nanosid_includes"; then
+        xs_nanosid_cflags="-I$xs_nanosid_includes"
+    else
+        xs_nanosid_cflags=""
+    fi
+
+    # Use library path given by user (if any).
+    if test -n "$xs_nanosid_library"; then
+        xs_nanosid_ldflags="-L$xs_nanosid_library"
+    else
+        xs_nanosid_ldflags=""
+    fi
+
+    AC_CACHE_VAL(xs_cv_have_nanosid,
+    [
+        # Run test compilation with either standard search path
+        # or user-defined paths.
+        MY_TRY_LIBNANOSID
+        if test "$xs_nanosid_works" = yes; then
+          xs_cv_have_nanosid="xs_have_nanosid=yes  \
+            xs_nanosid_cflags=\"$xs_nanosid_cflags\"  \
+            xs_nanosid_ldflags=\"$xs_nanosid_ldflags\"  "
+        else
+            MY_FIND_LIBNANOSID        
+        fi
+    ])
+
+    eval "$xs_cv_have_nanosid"
+
+    if test "$xs_have_nanosid" = yes; then
+        if test -n "$xs_nanosid_cflags" || test -n "$xs_nanosid_ldflags"; then
+            AC_MSG_RESULT([$xs_nanosid_cflags $xs_nanosid_ldflags])
+        else
+            AC_MSG_RESULT([yes])
+        fi
+
+    NANOSID_LDADD="$xs_nanosid_ldflags -lNanoSID -lm -lz"
+    NANOSID_INCLUDES="$xs_nanosid_cflags"
+    AC_SUBST(NANOSID_LDADD)
+    AC_SUBST(NANOSID_INCLUDES)
+    else
+        AC_MSG_RESULT([no])
+    fi
+
+    AC_LANG_POP(C)
+])
+
+dnl Functions used by XS_PATH_LIBNANOSID.
+
+AC_DEFUN(MY_FIND_LIBNANOSID,
+[
+    # Search common locations where header files might be stored.
+    xs_nanosid_incdirs="$xs_nanosid_includes /usr/include /usr/local/include"
+    MY_FIND_FILE(libNanoSID.h, $xs_nanosid_incdirs, xs_nanosid_includes)
+
+    # Search common locations where library might be stored.
+    xs_nanosid_libdirs="$xs_nanosid_library /usr/lib /usr/local/lib"
+    MY_FIND_FILE(libNanoSID.a, $xs_nanosid_libdirs, xs_nanosid_library)
+
+    if test -z "$xs_nanosid_includes" || test -z "$xs_nanosid_library"; then
+        xs_cv_have_nanosid="xs_have_nanosid=no  \
+          xs_nanosid_ldflags=\"\" xs_nanosid_cflags=\"\"  "
+    else
+        # Test compilation with found paths.
+        xs_nanosid_ldflags="-L$xs_nanosid_library"
+        xs_nanosid_cflags="-I$xs_nanosid_includes"
+        MY_TRY_LIBNANOSID
+        xs_cv_have_nanosid="xs_have_nanosid=$xs_nanosid_works  \
+          xs_nanosid_ldflags=\"$xs_nanosid_ldflags\"  \
+          xs_nanosid_cflags=\"$xs_nanosid_cflags\"  "
+    fi
+])
+
+AC_DEFUN(MY_TRY_LIBNANOSID,
+[
+    MY_TRY_LINK_SAVE
+
+    CFLAGS="$CFLAGS $xs_nanosid_cflags"
+    LDFLAGS="$LDFLAGS $xs_nanosid_ldflags"
+    LIBS="$LIBS -lNanoSID -lm -lz"
+
+    AC_LINK_IFELSE([AC_LANG_PROGRAM(
+        [[#include <libNanoSID.h>]],
+        [[libNanoSID_Init();libNanoSID_GetSamplingRate();libNanoSID_GetANewSIDChip();]])],
+        [xs_nanosid_works=yes],
+        [xs_nanosid_works=no]
+    )
+
+    MY_TRY_LINK_RESTORE
+])
+
+
--- a/configure.in	Wed Jan 14 03:55:05 2004 +0000
+++ b/configure.in	Wed Jan 14 03:56:01 2004 +0000
@@ -21,6 +21,7 @@
 AH_TEMPLATE([HAVE_UNSIGNEDPCM],[Define if your audiodevice supports _ONLY_ UNSIGNED PCM samples, otherwise leave undefined.])
 AH_TEMPLATE([HAVE_SIDPLAY1],[Define if you have and want to use libSIDPlay 1])
 AH_TEMPLATE([HAVE_SIDPLAY2],[Define if you have and want to use libSIDPlay 2])
+AH_TEMPLATE([HAVE_NANOSID],[Define if you have and want to use libNanoSID])
 AH_TEMPLATE([HAVE_RESID_BUILDER],[Define if you have reSID with libSIDPlay 2])
 AH_TEMPLATE([HAVE_HARDSID_BUILDER],[Define if you have HardSID with libSIDPlay 2])
 
@@ -154,7 +155,44 @@
 [xs_sidplay2_library="$withval"],)
 
 
+dnl ***
+dnl *** libNanoSID options
+dnl ***
+AC_ARG_WITH(nanosid,
+[
+  --with-nanosid=PREFIX   Enable NanoSID with PREFIX],
+[
+if test "$withval" = yes; then
+xs_nanosid=yes
+xs_nanosid_library=""
+xs_nanosid_includes=""
+else
+if test "$withval" = no; then
+	xs_nanosid=no
+	else
+	xs_nanosid=yes
+	xs_nanosid_includes="$withval/include"
+	xs_nanosid_library="$withval/lib"
+	fi
+fi
+],[
+xs_nanosid=xtry
+xs_nanosid_library=""
+xs_nanosid_includes=""
+])
+
+AC_ARG_WITH(nanosid-inc,
+[  --with-nanosid-inc=DIR    Where the NanoSID headers are located],
+[xs_nanosid_includes="$withval"],)
+
+AC_ARG_WITH(sidplay1-lib,
+[  --with-nanosid-lib=DIR    Where the NanoSID library is installed],
+[xs_nanosid_library="$withval"],)
+
+
+dnl ***
 dnl *** Determine if libraries are wanted and available
+dnl ***
 OPT_SIDPLAY1="no"
 if test "$xs_sidplay1" = xtry; then
 	XS_PATH_LIBSIDPLAY1
@@ -198,12 +236,34 @@
 	fi
 fi
 
+
+OPT_NANOSID="no"
+if test "$xs_nanosid" = xtry; then
+	XS_PATH_LIBNANOSID
+	else
+	if test "$xs_nanosid" = yes; then
+		XS_PATH_LIBNANOSID
+		if test "$xs_have_nanosid" = no; then
+		AC_MSG_ERROR([libNanoSID library and/or headers were not found!])
+		fi
+	fi
+fi
+if test "$xs_have_nanosid" = yes; then
+	AC_DEFINE(HAVE_NANOSID)
+	OPT_NANOSID="yes"
+fi
+
+
 AC_SUBST(REQUIRE_LIBRARY,$xs_reqlib)
 
+dnl ***
 dnl *** Check if we have some emulator library available?
+dnl ***
 if test "$OPT_SIDPLAY1" = no; then
 if test "$OPT_SIDPLAY2" = no; then
-AC_MSG_ERROR([Either libSIDPlay1 or libSIDPlay2 is required! Please read INSTALL for more information!])
+if test "$OPT_NANOSID" = no; then
+AC_MSG_ERROR([Either libSIDPlay1, libSIDPlay2 or libNanoSID is required! Please read INSTALL for more information!])
+fi
 fi
 fi
 
@@ -269,5 +329,6 @@
 	libSIDPlay 1 support          : $OPT_SIDPLAY1
 	libSIDPlay 2 support          : $OPT_SIDPLAY2
 		Included builders     : $xs_builders
+	libNanoSID support            : $OPT_NANOSID
 
 ])