Including my extern-squishing script, which just found an
[rsync/rsync.git] / aclocal.m4
CommitLineData
8de330a3
AT
1dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
2dnl if the cache file is inconsistent with the current host,
3dnl target and build system types, execute CMD or print a default
4dnl error message.
5AC_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])
3fa64fd0 24
12458878
MP
25dnl Check for socklen_t: historically on BSD it is an int, and in
26dnl POSIX 1g it is a type of its own, but some platforms use different
27dnl types for the argument to getsockopt, getpeername, etc. So we
28dnl have to test to find something that will work.
29
fab9a9c5
MP
30dnl This is no good, because passing the wrong pointer on C compilers is
31dnl likely to only generate a warning, not an error. We don't call this at
32dnl the moment.
12458878
MP
33
34AC_DEFUN([TYPE_SOCKLEN_T],
35[
7ca6e856 36 AC_CHECK_TYPE([socklen_t], ,[
12458878 37 AC_MSG_CHECKING([for socklen_t equivalent])
7ca6e856 38 AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
12458878 39 [
7ca6e856
MP
40 # Systems have either "struct sockaddr *" or
41 # "void *" as the second argument to getpeername
42 rsync_cv_socklen_t_equiv=
43 for arg2 in "struct sockaddr" void; do
44 for t in int size_t unsigned long "unsigned long"; do
45 AC_TRY_COMPILE([
1691bdca
MP
46#include <sys/types.h>
47#include <sys/socket.h>
7ca6e856
MP
48
49 int getpeername (int, $arg2 *, $t *);
50 ],[
51 $t len;
52 getpeername(0,0,&len);
53 ],[
54 rsync_cv_socklen_t_equiv="$t"
55 break
56 ])
57 done
12458878 58 done
7ca6e856
MP
59
60 if test "x$rsync_cv_socklen_t_equiv" = x; then
61 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
62 fi
12458878 63 ])
7ca6e856
MP
64 AC_MSG_RESULT($rsync_cv_socklen_t_equiv)
65 AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv,
66 [type to use in place of socklen_t if not defined])],
67 [#include <sys/types.h>
68#include <sys/socket.h>])
12458878 69])
bf5c2bf6 70
6ec0f697
WD
71dnl AC_HAVE_TYPE(TYPE,INCLUDES)
72AC_DEFUN([AC_HAVE_TYPE], [
73AC_REQUIRE([AC_HEADER_STDC])
74cv=`echo "$1" | sed 'y%./+- %__p__%'`
75AC_MSG_CHECKING(for $1)
76AC_CACHE_VAL([ac_cv_type_$cv],
77AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
78AC_INCLUDES_DEFAULT
79$2]],
80[[$1 foo;]])],
81[eval "ac_cv_type_$cv=yes"],
82[eval "ac_cv_type_$cv=no"]))dnl
83ac_foo=`eval echo \\$ac_cv_type_$cv`
84AC_MSG_RESULT($ac_foo)
85if test "$ac_foo" = yes; then
86 ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
87if false; then
88 AC_CHECK_TYPES($1)
89fi
90 AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
91fi
92])