acinclude.m4
上传用户:awang829
上传日期:2019-07-14
资源大小:2356k
文件大小:7k
源码类别:

网络

开发平台:

Unix_Linux

  1. dnl $Id$
  2. dnl Helper macros for Tor configure.in
  3. dnl Copyright (c) 2001-2004, Roger Dingledine
  4. dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
  5. dnl Copyright (c) 2007-2008, Roger Dingledine, Nick Mathewson
  6. dnl See LICENSE for licensing information
  7. AC_DEFUN([TOR_EXTEND_CODEPATH],
  8. [
  9.   if test -d "$1/lib"; then
  10.     LDFLAGS="-L$1/lib $LDFLAGS"
  11.   else
  12.     LDFLAGS="-L$1 $LDFLAGS"
  13.   fi
  14.   if test -d "$1/include"; then
  15.     CPPFLAGS="-I$1/include $CPPFLAGS"
  16.   else
  17.     CPPFLAGS="-I$1 $CPPFLAGS"
  18.   fi
  19. ])
  20. AC_DEFUN([TOR_DEFINE_CODEPATH],
  21. [
  22.   if test x$1 = "x(system)"; then
  23.     TOR_LDFLAGS_$2=""
  24.     TOR_CPPFLAGS_$2=""
  25.   else
  26.    if test -d "$1/lib"; then
  27.      TOR_LDFLAGS_$2="-L$1/lib"
  28.    else
  29.      TOR_LDFLAGS_$2="-L$1"
  30.    fi
  31.    if test -d "$1/include"; then
  32.      TOR_CPPFLAGS_$2="-I$1/include"
  33.    else
  34.      TOR_CPPFLAGS_$2="-I$1"
  35.    fi
  36.   fi
  37.   AC_SUBST(TOR_CPPFLAGS_$2)
  38.   AC_SUBST(TOR_LDFLAGS_$2)
  39. ])
  40. dnl 1:libname
  41. AC_DEFUN([TOR_WARN_MISSING_LIB], [
  42. h=""
  43. if test x$2 = xdevpkg; then
  44.   h=" headers for"
  45. fi
  46. if test -f /etc/debian_version && test x"$tor_$1_$2_debian" != x; then
  47.   AC_WARN([On Debian, you can install$h $1 using "apt-get install $tor_$1_$2_debian"])
  48.   if test x"$tor_$1_$2_debian" != x"$tor_$1_devpkg_debian"; then 
  49.     AC_WARN([   You will probably need $tor_$1_devpkg_debian too.])
  50.   fi 
  51. fi
  52. if test -f /etc/fedora-release && test x"$tor_$1_$2_redhat" != x; then
  53.   AC_WARN([On Fedora Core, you can install$h $1 using "yum install $tor_$1_$2_redhat"])
  54.   if test x"$tor_$1_$2_redhat" != x"$tor_$1_devpkg_redhat"; then 
  55.     AC_WARN([   You will probably need to install $tor_$1_devpkg_redhat too.])
  56.   fi 
  57. else
  58.   if test -f /etc/redhat-release && test x"$tor_$1_$2_redhat" != x; then
  59.     AC_WARN([On most Redhat-based systems, you can get$h $1 by installing the $tor_$1_$2_redhat" RPM package])
  60.     if test x"$tor_$1_$2_redhat" != x"$tor_$1_devpkg_redhat"; then 
  61.       AC_WARN([   You will probably need to install $tor_$1_devpkg_redhat too.])
  62.     fi 
  63.   fi
  64. fi
  65. ])
  66. dnl Look for a library, and its associated includes, and how to link
  67. dnl against it.
  68. dnl
  69. dnl TOR_SEARCH_LIBRARY(1:libname, 2:IGNORED, 3:linkargs, 4:headers,
  70. dnl                    5:prototype,
  71. dnl                    6:code, 7:IGNORED, 8:searchextra)
  72. dnl
  73. dnl Special variables:
  74. dnl   ALT_{libname}_WITHVAL -- another possible value for --with-$1-dir.
  75. dnl       Used to support renaming --with-ssl-dir to --with-openssl-dir
  76. dnl
  77. AC_DEFUN([TOR_SEARCH_LIBRARY], [
  78. try$1dir=""
  79. AC_ARG_WITH($1-dir,
  80.   [  --with-$1-dir=PATH    Specify path to $1 installation ],
  81.   [
  82.      if test x$withval != xno ; then
  83.         try$1dir="$withval"
  84.      fi
  85.   ])
  86. if test "x$try$1dir" = x && test "x$ALT_$1_WITHVAL" != x ; then
  87.   try$1dir="$ALT_$1_WITHVAL"
  88. fi
  89. tor_saved_LIBS="$LIBS"
  90. tor_saved_LDFLAGS="$LDFLAGS"
  91. tor_saved_CPPFLAGS="$CPPFLAGS"
  92. AC_CACHE_CHECK([for $1 directory], tor_cv_library_$1_dir, [
  93.   tor_$1_dir_found=no
  94.   tor_$1_any_linkable=no
  95.   for tor_trydir in "$try$1dir" "(system)" "$prefix" /usr/local /usr/pkg $8; do
  96.     LDFLAGS="$tor_saved_LDFLAGS"
  97.     LIBS="$tor_saved_LIBS $3"
  98.     CPPFLAGS="$tor_saved_CPPFLAGS"
  99.     if test -z "$tor_trydir" ; then
  100.       continue;
  101.     fi
  102.     # Skip the directory if it isn't there.
  103.     if test ! -d "$tor_trydir" && test "$tor_trydir" != "(system)"; then
  104.       continue;
  105.     fi
  106.     # If this isn't blank, try adding the directory (or appropriate
  107.     # include/libs subdirectories) to the command line.
  108.     if test "$tor_trydir" != "(system)"; then
  109.       TOR_EXTEND_CODEPATH($tor_trydir)
  110.     fi
  111.     # Can we link against (but not necessarily run, or find the headers for)
  112.     # the binary?
  113.     AC_LINK_IFELSE(AC_LANG_PROGRAM([$5], [$6]),
  114.                    [linkable=yes], [linkable=no])
  115.     if test "$linkable" = yes; then
  116.       tor_$1_any_linkable=yes
  117.       # Okay, we can link against it.  Can we find the headers?
  118.       AC_COMPILE_IFELSE(AC_LANG_PROGRAM([$4], [$6]),
  119.                         [buildable=yes], [buildable=no])
  120.       if test "$buildable" = yes; then
  121.          tor_cv_library_$1_dir=$tor_trydir
  122.          tor_$1_dir_found=yes
  123.          break
  124.       fi
  125.     fi
  126.   done
  127.   if test "$tor_$1_dir_found" = no; then
  128.     if test "$tor_$1_any_linkable" = no ; then
  129.       AC_MSG_WARN([Could not find a linkable $1.  If you have it installed somewhere unusual, you can specify an explicit path using --with-$1-dir])
  130.       TOR_WARN_MISSING_LIB($1, pkg)
  131.       AC_MSG_ERROR([Missing libraries; unable to proceed.])
  132.     else
  133.       AC_MSG_WARN([We found the libraries for $1, but we could not find the C header files.  You may need to install a devel package.])
  134.       TOR_WARN_MISSING_LIB($1, devpkg)
  135.       AC_MSG_ERROR([Missing headers; unable to proceed.])
  136.     fi
  137.   fi
  138.   LDFLAGS="$tor_saved_LDFLAGS"
  139.   LIBS="$tor_saved_LIBS"
  140.   CPPFLAGS="$tor_saved_CPPFLAGS"
  141. ]) dnl end cache check
  142. LIBS="$LIBS $3"
  143. if test "$tor_cv_library_$1_dir" != "(system)"; then
  144.    TOR_EXTEND_CODEPATH($tor_cv_library_$1_dir)
  145. fi
  146. TOR_DEFINE_CODEPATH($tor_cv_library_$1_dir, $1)
  147. if test "$cross_compiling" != yes; then
  148.   AC_CACHE_CHECK([whether we need extra options to link $1],
  149.                  tor_cv_library_$1_linker_option, [
  150.    orig_LDFLAGS="$LDFLAGS"
  151.    runs=no
  152.    linked_with=nothing
  153.    if test -d "$tor_cv_library_$1_dir/lib"; then
  154.      tor_trydir="$tor_cv_library_$1_dir/lib"
  155.    else
  156.      tor_trydir="$tor_cv_library_$1_dir"
  157.    fi
  158.    for tor_tryextra in "(none)" "-Wl,-R$tor_trydir" "-R$tor_trydir" 
  159.                        "-Wl,-rpath,$tor_trydir" ; do
  160.      if test "$tor_tryextra" = "(none)"; then
  161.        LDFLAGS="$orig_LDFLAGS"
  162.      else
  163.        LDFLAGS="$tor_tryextra $orig_LDFLAGS"
  164.      fi
  165.      AC_RUN_IFELSE(AC_LANG_PROGRAM([$5], [$6]),
  166.                    [runnable=yes], [runnable=no])
  167.      if test "$runnable" = yes; then
  168.         tor_cv_library_$1_linker_option=$tor_tryextra
  169.         break
  170.      fi
  171.    done
  172.    if test "$runnable" = no; then
  173.      AC_MSG_ERROR([Found linkable $1 in $tor_cv_library_$1_dir, but it does not seem to run, even with -R. Maybe specify another using --with-$1-dir}])
  174.    fi
  175.    LDFLAGS="$orig_LDFLAGS"
  176.   ]) dnl end cache check check for extra options.
  177.   if test "$tor_cv_library_$1_linker_option" != "(none)" ; then
  178.     TOR_LDFLAGS_$1="$TOR_LDFLAGS_$1 $tor_cv_library_$1_linker_option"
  179.   fi
  180. fi # cross-compile
  181. LIBS="$tor_saved_LIBS"
  182. LDFLAGS="$tor_saved_LDFLAGS"
  183. CPPFLAGS="$tor_saved_CPPFLAGS"
  184. ]) dnl end defun
  185. dnl Check whether the prototype for a function is present or missing.
  186. dnl Apple has a nasty habit of putting functions in their libraries (so that
  187. dnl AC_CHECK_FUNCS passes) but not actually declaring them in the headers.
  188. dnl
  189. dnl TOR_CHECK_PROTYPE(1:functionname, 2:macroname, 2: includes)
  190. AC_DEFUN([TOR_CHECK_PROTOTYPE], [
  191.  AC_CACHE_CHECK([for declaration of $1], tor_cv_$1_declared, [
  192.    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([$3],[void *ptr= $1 ;]),
  193.                      tor_cv_$1_declared=yes,tor_cv_$1_declared=no)])
  194. if test x$tor_cv_$1_declared != xno ; then
  195.   AC_DEFINE($2, 1,
  196.        [Defined if the prototype for $1 seems to be present.])
  197. fi
  198. ])