Mercurial > hg > xmms-sid
diff acinclude.m4 @ 125:532ec0ad5e59
Added support/detection for libNanoSID.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Jan 2004 03:56:01 +0000 |
parents | edec1818cf48 |
children | 89844080b44b |
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 +]) + +