acffi.m4
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:3k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. AC_DEFUN([md_FIND_FFI],
  2. [USE_FFCALL=0
  3. dnl Tests if with_ffidir or with_ffcalldir specified and sets ffidir
  4. if test -n "$with_ffidir" && test "$with_ffidir" != no; then
  5.   case $target_cpu in
  6.     i?86|sparc)
  7.       AC_MSG_WARN(Ignoring --with-ffidir: libffi is known to be less reliable than avcall on this platform.)
  8.       with_ffidir=no
  9.       ;;
  10.     *)
  11.       ffidir=$with_ffidir 
  12.       ;;
  13.   esac
  14. else
  15.   if test -n "$with_ffcalldir" ; then
  16.     ffidir=$with_ffcalldir
  17.     USE_FFCALL=1
  18.   fi
  19. fi
  20. if test -n "$ffidir" ; then
  21.   dnl This section for libffi
  22.   if test $USE_FFCALL = 0; then
  23.     if test "$with_ffidir" != no ; then
  24.       test -n "$ffidir" || ffidir=$defaultdir
  25.       FFILDFLAGS=''
  26.       AC_MSG_CHECKING(directory of libffi)
  27.       for dir in $ffidir /usr ; do
  28.         ffidir_expand=`eval echo $dir`
  29. for suffix in .dylib .so .sl; do
  30. for subdir in /lib /; do
  31. if test -f $ffidir_expand$subdir/libffi$suffix ; then
  32.   FFILDFLAGS="-L${ffilibdir} -R ${ffilibdir}"
  33.   AC_MSG_RESULT($ffidir_expand$subdir/libffi${suffix})
  34.   break
  35. else
  36.   if test -f $ffidir_expand/lib/libffi.a ; then
  37. FFILDFLAGS='-L${ffilibdir}'
  38. AC_MSG_RESULT($dir/lib/libffi.a)
  39. break
  40.   fi
  41. fi
  42. done
  43. if test -n "$FFILDFLAGS" ; then
  44. break
  45. fi
  46. done
  47. if test -n "$FFILDFLAGS" ; then
  48. break
  49. fi
  50.       done
  51.       if test -z "$FFILDFLAGS" ; then
  52.         AC_MSG_RESULT(no)    
  53.       else
  54.         ffidir=$dir
  55.         AC_MSG_CHECKING(directory of libffi include)
  56.         for dir in $ffidir /usr ; do
  57.     ffidir_expand=`eval echo $dir`
  58. if test -f $ffidir_expand/include/ffi.h ; then
  59.   AC_MSG_RESULT($ffidir_expand/include)
  60.   FFILIB=-lffi
  61.   SWFFILIB=${FFILIB}
  62.   break
  63. fi
  64. done
  65.         if test -z "$FFILIB" ; then
  66.           AC_MSG_RESULT(no)
  67.         fi
  68.       fi
  69.     fi
  70.   else 
  71.   dnl This section for libavcall
  72.     if test "$with_ffcalldir" != no; then
  73.       use_avcall=1  
  74.       FFILIB=-lavcall
  75.       test -n "$ffidir" || ffidir=$defaultdir
  76.       ffidir_expand=`eval echo $ffidir`
  77.       AC_MSG_CHECKING(directory of libavcall.la)
  78.       if test -f $ffidir_expand/lib/libavcall.la ; then
  79.         FFILDFLAGS=''
  80.         AC_MSG_RESULT($ffidir/lib)
  81. if test  x$ONELIB = xyes; then
  82.   FFILIB=''
  83.   SWFFILIB='${ffidir}/lib/libavcall.la'
  84. else
  85.   FFILIB='${ffidir}/lib/libavcall.la'
  86.   SWFFILIB=''
  87. fi
  88.   else
  89.         ffidir='WRONG!'
  90. AC_MSG_RESULT(no)    
  91.         AC_MSG_ERROR(Please use --with-ffcalldir to specify location of avcall library.)
  92.       fi
  93.       AC_MSG_CHECKING(directory of avcall include)
  94.       if test -f $ffidir_expand/include/avcall.h ; then
  95.         AC_MSG_RESULT($ffidir/include)
  96.       else
  97.         ffidir='WRONG!'
  98. AC_MSG_RESULT(no)
  99.         AC_MSG_ERROR(Please use --with-ffcalldir to specify locatin of avcall header file.) 
  100.       fi
  101.     fi
  102.   fi
  103. fi
  104. dnl Sets up includes.
  105. if test -n "$ffidir"; then
  106.   ffilibdir=${ffidir}/lib
  107.   if test $ffidir_expand = /usr; then
  108.     FFIINCLUDES=''
  109.   else
  110.     FFIINCLUDES='-I${ffidir}/include'
  111.   fi
  112.   AM_CONDITIONAL(USEBUILTINAVCALL, false)
  113. dnl If no ffidir specified use builtin avcall and setup FFILIB
  114. else
  115.   use_avcall=1
  116.   ffidir=
  117.   ffilibdir=
  118.   FFIINCLUDES='-I${top_builddir}/avcall'
  119.   FFILDFLAGS=
  120.   FFILIB='${top_builddir}/avcall/libavcall.la'
  121.   AM_CONDITIONAL(USEBUILTINAVCALL, true)
  122. fi
  123. if test -n "$use_avcall"; then
  124.   AC_DEFINE(USE_AVCALL,1,[define if avcall will be used])
  125. fi
  126. AC_SUBST(ffidir)
  127. AC_SUBST(ffilibdir)
  128. AC_SUBST(FFIINCLUDES)
  129. AC_SUBST(FFILDFLAGS)
  130. AC_SUBST(FFILIB)
  131. AC_SUBST(SWFFILIB)
  132. ])