comparison 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
comparison
equal deleted inserted replaced
124:c8f97c889f55 125:532ec0ad5e59
69 xs_cxxflags_save="$CXXFLAGS" 69 xs_cxxflags_save="$CXXFLAGS"
70 xs_ldflags_save="$LDFLAGS" 70 xs_ldflags_save="$LDFLAGS"
71 xs_libs_save="$LIBS" 71 xs_libs_save="$LIBS"
72 ]) 72 ])
73 73
74
74 AC_DEFUN(MY_TRY_LINK_RESTORE, 75 AC_DEFUN(MY_TRY_LINK_RESTORE,
75 [ 76 [
76 CXX="$xs_cxx_save" 77 CXX="$xs_cxx_save"
77 CXXFLAGS="$xs_cxxflags_save" 78 CXXFLAGS="$xs_cxxflags_save"
78 LDFLAGS="$xs_ldflags_save" 79 LDFLAGS="$xs_ldflags_save"
79 LIBS="$xs_libs_save" 80 LIBS="$xs_libs_save"
80 ]) 81 ])
81 82
83
82 AC_DEFUN(MY_PROG_PKGCONFIG, 84 AC_DEFUN(MY_PROG_PKGCONFIG,
83 [ 85 [
84 AC_PATH_PROG(PKG_CONFIG, pkg-config, "") 86 AC_PATH_PROG(PKG_CONFIG, pkg-config, "")
85 ]) 87 ])
88
86 89
87 AC_DEFUN(MY_NEED_PKGCONFIG, 90 AC_DEFUN(MY_NEED_PKGCONFIG,
88 [ 91 [
89 AC_REQUIRE([MY_PROG_PKGCONFIG]) 92 AC_REQUIRE([MY_PROG_PKGCONFIG])
90 if test -z "$PKG_CONFIG"; then 93 if test -z "$PKG_CONFIG"; then
471 fi 474 fi
472 AC_MSG_RESULT($builders_work) 475 AC_MSG_RESULT($builders_work)
473 AC_SUBST(HARDSID_LDADD) 476 AC_SUBST(HARDSID_LDADD)
474 AC_LANG_POP(C++) 477 AC_LANG_POP(C++)
475 ]) 478 ])
479
480
481 dnl -------------------------------------------------------------------------
482 dnl Try to find NanoSID library and header files.
483 dnl $xs_have_nanosid will be "yes" or "no"
484 dnl @NANOSID_LDADD@ will be substituted with linker parameters
485 dnl @NANOSID_INCLUDES@ will be substituted with compiler parameters
486 dnl -------------------------------------------------------------------------
487
488 AC_DEFUN(XS_PATH_LIBNANOSID,
489 [
490 AC_MSG_CHECKING([for working NanoSID library and headers])
491
492 AC_LANG_PUSH(C)
493
494 # Use include path given by user (if any).
495 if test -n "$xs_nanosid_includes"; then
496 xs_nanosid_cflags="-I$xs_nanosid_includes"
497 else
498 xs_nanosid_cflags=""
499 fi
500
501 # Use library path given by user (if any).
502 if test -n "$xs_nanosid_library"; then
503 xs_nanosid_ldflags="-L$xs_nanosid_library"
504 else
505 xs_nanosid_ldflags=""
506 fi
507
508 AC_CACHE_VAL(xs_cv_have_nanosid,
509 [
510 # Run test compilation with either standard search path
511 # or user-defined paths.
512 MY_TRY_LIBNANOSID
513 if test "$xs_nanosid_works" = yes; then
514 xs_cv_have_nanosid="xs_have_nanosid=yes \
515 xs_nanosid_cflags=\"$xs_nanosid_cflags\" \
516 xs_nanosid_ldflags=\"$xs_nanosid_ldflags\" "
517 else
518 MY_FIND_LIBNANOSID
519 fi
520 ])
521
522 eval "$xs_cv_have_nanosid"
523
524 if test "$xs_have_nanosid" = yes; then
525 if test -n "$xs_nanosid_cflags" || test -n "$xs_nanosid_ldflags"; then
526 AC_MSG_RESULT([$xs_nanosid_cflags $xs_nanosid_ldflags])
527 else
528 AC_MSG_RESULT([yes])
529 fi
530
531 NANOSID_LDADD="$xs_nanosid_ldflags -lNanoSID -lm -lz"
532 NANOSID_INCLUDES="$xs_nanosid_cflags"
533 AC_SUBST(NANOSID_LDADD)
534 AC_SUBST(NANOSID_INCLUDES)
535 else
536 AC_MSG_RESULT([no])
537 fi
538
539 AC_LANG_POP(C)
540 ])
541
542 dnl Functions used by XS_PATH_LIBNANOSID.
543
544 AC_DEFUN(MY_FIND_LIBNANOSID,
545 [
546 # Search common locations where header files might be stored.
547 xs_nanosid_incdirs="$xs_nanosid_includes /usr/include /usr/local/include"
548 MY_FIND_FILE(libNanoSID.h, $xs_nanosid_incdirs, xs_nanosid_includes)
549
550 # Search common locations where library might be stored.
551 xs_nanosid_libdirs="$xs_nanosid_library /usr/lib /usr/local/lib"
552 MY_FIND_FILE(libNanoSID.a, $xs_nanosid_libdirs, xs_nanosid_library)
553
554 if test -z "$xs_nanosid_includes" || test -z "$xs_nanosid_library"; then
555 xs_cv_have_nanosid="xs_have_nanosid=no \
556 xs_nanosid_ldflags=\"\" xs_nanosid_cflags=\"\" "
557 else
558 # Test compilation with found paths.
559 xs_nanosid_ldflags="-L$xs_nanosid_library"
560 xs_nanosid_cflags="-I$xs_nanosid_includes"
561 MY_TRY_LIBNANOSID
562 xs_cv_have_nanosid="xs_have_nanosid=$xs_nanosid_works \
563 xs_nanosid_ldflags=\"$xs_nanosid_ldflags\" \
564 xs_nanosid_cflags=\"$xs_nanosid_cflags\" "
565 fi
566 ])
567
568 AC_DEFUN(MY_TRY_LIBNANOSID,
569 [
570 MY_TRY_LINK_SAVE
571
572 CFLAGS="$CFLAGS $xs_nanosid_cflags"
573 LDFLAGS="$LDFLAGS $xs_nanosid_ldflags"
574 LIBS="$LIBS -lNanoSID -lm -lz"
575
576 AC_LINK_IFELSE([AC_LANG_PROGRAM(
577 [[#include <libNanoSID.h>]],
578 [[libNanoSID_Init();libNanoSID_GetSamplingRate();libNanoSID_GetANewSIDChip();]])],
579 [xs_nanosid_works=yes],
580 [xs_nanosid_works=no]
581 )
582
583 MY_TRY_LINK_RESTORE
584 ])
585
586