Blame ld10k1/ld10k1.m4

Packit 427e91
dnl Configure Paths for ld10k1 - stolen from ASLA (1.0.5a)
Packit 427e91
dnl Configure Paths for Alsa
Packit 427e91
dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
Packit 427e91
dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
Packit 427e91
dnl Jaroslav Kysela <perex@perex.cz>
Packit 427e91
dnl AM_PATH_LD10K1([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Packit 427e91
dnl Test for liblo10k1, and define LD10K1_CFLAGS and LD10K1_LIBS as appropriate.
Packit 427e91
dnl enables arguments --with-ld10k1-prefix=
Packit 427e91
dnl                   --with-ld10k1-enc-prefix=
Packit 427e91
dnl                   --disable-ld10k1test
Packit 427e91
dnl
Packit 427e91
dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
Packit 427e91
dnl and the ld10k1 libraries are not found, a fatal AC_MSG_ERROR() will result.
Packit 427e91
dnl
Packit 427e91
AC_DEFUN([AM_PATH_LD10K1],
Packit 427e91
[dnl Save the original CFLAGS, LDFLAGS, and LIBS
Packit 427e91
ld10k1_save_CFLAGS="$CFLAGS"
Packit 427e91
ld10k1_save_LDFLAGS="$LDFLAGS"
Packit 427e91
ld10k1_save_LIBS="$LIBS"
Packit 427e91
ld10k1_found=yes
Packit 427e91
Packit 427e91
dnl
Packit 427e91
dnl Get the cflags and libraries for ld10k1
Packit 427e91
dnl
Packit 427e91
AC_ARG_WITH(ld10k1-prefix,
Packit 427e91
[  --with-ld10k1-prefix=PFX  Prefix where ld10k1 library is installed(optional)],
Packit 427e91
[ld10k1_prefix="$withval"], [ld10k1_prefix=""])
Packit 427e91
Packit 427e91
AC_ARG_WITH(ld10k1-inc-prefix,
Packit 427e91
[  --with-ld10k1-inc-prefix=PFX  Prefix where include libraries are (optional)],
Packit 427e91
[ld10k1_inc_prefix="$withval"], [ld10k1_inc_prefix=""])
Packit 427e91
Packit 427e91
dnl FIXME: this is not yet implemented
Packit 427e91
AC_ARG_ENABLE(ld10k1test,
Packit 427e91
[  --disable-ld10k1test      Do not try to compile and run a test ld10k1 program],
Packit 427e91
[enable_ld10k1test="$enableval"],
Packit 427e91
[enable_ld10k1test=yes])
Packit 427e91
Packit 427e91
dnl Add any special include directories
Packit 427e91
AC_MSG_CHECKING(for ld10k1 CFLAGS)
Packit 427e91
if test "$ld10k1_inc_prefix" != "" ; then
Packit 427e91
	LD10K1_CFLAGS="$LD10K1_CFLAGS -I$ld10k1_inc_prefix"
Packit 427e91
	CFLAGS="$CFLAGS -I$ld10k1_inc_prefix"
Packit 427e91
fi
Packit 427e91
AC_MSG_RESULT($LD10K1_CFLAGS)
Packit 427e91
Packit 427e91
dnl add any special lib dirs
Packit 427e91
AC_MSG_CHECKING(for ld10l1 LDFLAGS)
Packit 427e91
if test "$ld10k1_prefix" != "" ; then
Packit 427e91
	LD10K1_LIBS="$LD10K1_LIBS -L$ld10k1_prefix"
Packit 427e91
	LDFLAGS="$LDFLAGS $LD10K1_LIBS"
Packit 427e91
fi
Packit 427e91
Packit 427e91
dnl add the ld10k1 library
Packit 427e91
LD10K1_LIBS="$LD10K1_LIBS -llo10k1"
Packit 427e91
dnl LIBS=`echo $LIBS | sed 's/-lm//'`
Packit 427e91
dnl LIBS=`echo $LIBS | sed 's/-ldl//'`
Packit 427e91
dnl LIBS=`echo $LIBS | sed 's/-lpthread//'`
Packit 427e91
LIBS=`echo $LIBS | sed 's/  //'`
Packit 427e91
LIBS="$LD10K1_LIBS $LIBS"
Packit 427e91
AC_MSG_RESULT($LD10K1_LIBS)
Packit 427e91
Packit 427e91
dnl Check for a working version of liblo10k1 that is of the right version.
Packit 427e91
min_ld10k1_version=ifelse([$1], ,0.1.5,$1)
Packit 427e91
AC_MSG_CHECKING(for liblo10k1 headers version >= $min_ld10k1_version)
Packit 427e91
no_ld10k1=""
Packit 427e91
    ld10k1_min_major_version=`echo $min_ld10k1_version | \
Packit 427e91
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
Packit 427e91
    ld10k1_min_minor_version=`echo $min_ld10k1_version | \
Packit 427e91
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
Packit 427e91
    ld10k1_min_micro_version=`echo $min_ld10k1_version | \
Packit 427e91
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
Packit 427e91
Packit 427e91
AC_LANG_SAVE
Packit 427e91
AC_LANG_C
Packit 427e91
AC_TRY_COMPILE([
Packit 427e91
#include <lo10k1/lo10k1.h>
Packit 427e91
], [
Packit 427e91
/* ensure backward compatibility */
Packit 427e91
#  if(LD10K1_LIB_MAJOR > $ld10k1_min_major_version)
Packit 427e91
  exit(0);
Packit 427e91
#  else
Packit 427e91
#    if(LD10K1_LIB_MAJOR < $ld10k1_min_major_version)
Packit 427e91
#       error not present
Packit 427e91
#    endif
Packit 427e91
Packit 427e91
#   if(LD10K1_LIB_MINOR > $ld10k1_min_minor_version)
Packit 427e91
  exit(0);
Packit 427e91
#   else
Packit 427e91
#     if(LD10K1_LIB_MINOR < $ld10k1_min_minor_version)
Packit 427e91
#          error not present
Packit 427e91
#      endif
Packit 427e91
Packit 427e91
#      if(LD10K1_LIB_SUBMINOR < $ld10k1_min_micro_version)
Packit 427e91
#        error not present
Packit 427e91
#      endif
Packit 427e91
#    endif
Packit 427e91
#  endif
Packit 427e91
exit(0);
Packit 427e91
],
Packit 427e91
  [AC_MSG_RESULT(found.)],
Packit 427e91
  [AC_MSG_RESULT(not present.)
Packit 427e91
   ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of liblo10k1 not found.)])
Packit 427e91
   ld10k1_found=no]
Packit 427e91
)
Packit 427e91
AC_LANG_RESTORE
Packit 427e91
Packit 427e91
dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
Packit 427e91
if test "x$enable_ld10k1test" = "xyes"; then
Packit 427e91
AC_CHECK_LIB([lo10k1], [liblo10k1_connection_init],,
Packit 427e91
	[ifelse([$3], , [AC_MSG_ERROR(No linkable liblo10k1 was found.)])
Packit 427e91
	 ld10k1_found=no]
Packit 427e91
)
Packit 427e91
fi
Packit 427e91
Packit 427e91
if test "x$ld10k1_found" = "xyes" ; then
Packit 427e91
   ifelse([$2], , :, [$2])
Packit 427e91
   LIBS=`echo $LIBS | sed 's/-llo10k1//g'`
Packit 427e91
   LIBS=`echo $LIBS | sed 's/  //'`
Packit 427e91
   LIBS="-llo10k1 $LIBS"
Packit 427e91
fi
Packit 427e91
if test "x$ld10k1_found" = "xno" ; then
Packit 427e91
   ifelse([$3], , :, [$3])
Packit 427e91
   CFLAGS="$ld10k1_save_CFLAGS"
Packit 427e91
   LDFLAGS="$ld10k1_save_LDFLAGS"
Packit 427e91
   LIBS="$ld10k1_save_LIBS"
Packit 427e91
   LD10K1_CFLAGS=""
Packit 427e91
   LD10K1_LIBS=""
Packit 427e91
fi
Packit 427e91
Packit 427e91
dnl That should be it.  Now just export out symbols:
Packit 427e91
AC_SUBST(LD10K1_CFLAGS)
Packit 427e91
AC_SUBST(LD10K1_LIBS)
Packit 427e91
])
Packit 427e91