aclocal.m4 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
  2. dnl if the cache file is inconsistent with the current host,
  3. dnl target and build system types, execute CMD or print a default
  4. dnl error message.
  5. AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
  6. AC_REQUIRE([AC_CANONICAL_SYSTEM])
  7. AC_MSG_CHECKING([config.cache system type])
  8. if { test x"${ac_cv_host_system_type+set}" = x"set" &&
  9. test x"$ac_cv_host_system_type" != x"$host"; } ||
  10. { test x"${ac_cv_build_system_type+set}" = x"set" &&
  11. test x"$ac_cv_build_system_type" != x"$build"; } ||
  12. { test x"${ac_cv_target_system_type+set}" = x"set" &&
  13. test x"$ac_cv_target_system_type" != x"$target"; }; then
  14. AC_MSG_RESULT([different])
  15. ifelse($#, 1, [$1],
  16. [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
  17. else
  18. AC_MSG_RESULT([same])
  19. fi
  20. ac_cv_host_system_type="$host"
  21. ac_cv_build_system_type="$build"
  22. ac_cv_target_system_type="$target"
  23. ])
  24. dnl Check for socklen_t: historically on BSD it is an int, and in
  25. dnl POSIX 1g it is a type of its own, but some platforms use different
  26. dnl types for the argument to getsockopt, getpeername, etc. So we
  27. dnl have to test to find something that will work.
  28. dnl This is no good, because passing the wrong pointer on C compilers is
  29. dnl likely to only generate a warning, not an error. We don't call this at
  30. dnl the moment.
  31. AC_DEFUN([TYPE_SOCKLEN_T],
  32. [
  33. AC_CHECK_TYPE([socklen_t], ,[
  34. AC_MSG_CHECKING([for socklen_t equivalent])
  35. AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
  36. [
  37. # Systems have either "struct sockaddr *" or
  38. # "void *" as the second argument to getpeername
  39. rsync_cv_socklen_t_equiv=
  40. for arg2 in "struct sockaddr" void; do
  41. for t in int size_t unsigned long "unsigned long"; do
  42. AC_TRY_COMPILE([
  43. #include <sys/types.h>
  44. #include <sys/socket.h>
  45. int getpeername (int, $arg2 *, $t *);
  46. ],[
  47. $t len;
  48. getpeername(0,0,&len);
  49. ],[
  50. rsync_cv_socklen_t_equiv="$t"
  51. break
  52. ])
  53. done
  54. done
  55. if test "x$rsync_cv_socklen_t_equiv" = x; then
  56. AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
  57. fi
  58. ])
  59. AC_MSG_RESULT($rsync_cv_socklen_t_equiv)
  60. AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv,
  61. [type to use in place of socklen_t if not defined])],
  62. [#include <sys/types.h>
  63. #include <sys/socket.h>])
  64. ])
  65. dnl AC_HAVE_TYPE(TYPE,INCLUDES)
  66. AC_DEFUN([AC_HAVE_TYPE], [
  67. AC_REQUIRE([AC_HEADER_STDC])
  68. cv=`echo "$1" | sed 'y%./+- %__p__%'`
  69. AC_MSG_CHECKING(for $1)
  70. AC_CACHE_VAL([ac_cv_type_$cv],
  71. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  72. AC_INCLUDES_DEFAULT
  73. $2]],
  74. [[$1 foo;]])],
  75. [eval "ac_cv_type_$cv=yes"],
  76. [eval "ac_cv_type_$cv=no"]))dnl
  77. ac_foo=`eval echo \\$ac_cv_type_$cv`
  78. AC_MSG_RESULT($ac_foo)
  79. if test "$ac_foo" = yes; then
  80. ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
  81. if false; then
  82. AC_CHECK_TYPES($1)
  83. fi
  84. AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
  85. fi
  86. ])