Also need to include lib/getnameinfo when the getaddrinfo defines don't exist.
[rsync/rsync.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT()
4 AC_CONFIG_SRCDIR([byteorder.h])
5 AC_CONFIG_HEADER(config.h)
6 AC_PREREQ(2.52)
7
8 RSYNC_VERSION=2.5.6pre2cvs
9 AC_SUBST(RSYNC_VERSION)
10 AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
11
12 AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
13
14 LDFLAGS=${LDFLAGS-""}
15
16 AC_CANONICAL_TARGET([])
17
18 dnl Checks for programs.
19 AC_PROG_CC
20 AC_PROG_CPP
21 AC_PROG_INSTALL
22 AC_PROG_CC_STDC
23 AC_SUBST(SHELL)
24
25 AC_DEFINE([_GNU_SOURCE], 1,
26           [Define _GNU_SOURCE so that we get all necessary prototypes])
27
28 if test "x$ac_cv_prog_cc_stdc" = xno
29 then
30         AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
31 fi
32
33 # We must decide this before testing the compiler.
34
35 # Please allow this to default to yes, so that your users have more
36 # chance of getting a useful stack trace if problems occur.
37
38 AC_MSG_CHECKING([whether to include debugging symbols])
39 AC_ARG_ENABLE(debug,
40         AC_HELP_STRING([--enable-debug],
41                 [including debugging symbols and features (default yes)]),
42                 [], [])
43
44 if test x"$enable_debug" = x"no"
45 then
46     AC_MSG_RESULT(no)
47     CFLAGS=${CFLAGS-"-O"}
48 else
49     AC_MSG_RESULT([yes])
50     # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
51     dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
52     dnl CFLAGS=${CFLAGS-"-g"}
53 fi
54
55
56
57
58 AC_ARG_ENABLE(profile,
59         AC_HELP_STRING([--enable-profile],      
60                 [turn on CPU profiling (default no)],
61                 [], []))
62 if test x"$enable_profile" = xyes
63 then
64         CFLAGS="$CFLAGS -pg"
65 fi
66
67
68 # Specifically, this turns on panic_action handling.
69 AC_ARG_ENABLE(maintainer-mode,
70         AC_HELP_STRING([--enable-maintainer-mode],      
71                 [turn on extra debug features],
72                 [], []))
73 if test x"$enable_maintainer_mode" = xyes
74 then
75         CFLAGS="$CFLAGS -DMAINTAINER_MODE"
76 fi
77
78
79 # This is needed for our included version of popt.  Kind of silly, but
80 # I don't want our version too far out of sync.
81 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
82
83 # If GCC, turn on warnings.
84 if test "x$GCC" = "xyes"
85 then
86         CFLAGS="$CFLAGS -Wall -W"
87 fi
88
89 AC_ARG_WITH(included-popt,
90         [  --with-included-popt    use bundled popt library, not from system])
91
92 AC_ARG_WITH(rsync-path,
93         [  --with-rsync-path=PATH  set default --rsync-path to PATH (default: \"rsync\")],
94         [ RSYNC_PATH="$with_rsync_path" ],
95         [ RSYNC_PATH="rsync" ])
96
97 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
98
99 AC_ARG_WITH(rsh,
100         AC_HELP_STRING([--with-rsh=CMD], [set rsh command to CMD (default: \"remsh\" or \"rsh\")]))
101
102 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
103 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [remote shell is remsh not rsh])
104
105 if test x"$with_rsh" != x
106 then
107         RSYNC_RSH="$with_rsh"
108 elif test x"$HAVE_REMSH" = x1
109 then 
110         RSYNC_RSH="remsh"
111 else
112         RSYNC_RSH="rsh"
113 fi
114
115 AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
116
117 # arrgh. libc in the current debian stable screws up the largefile
118 # stuff, getting byte range locking wrong
119 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
120 AC_TRY_RUN([
121 #define _FILE_OFFSET_BITS 64
122 #include <stdio.h>
123 #include <fcntl.h>
124 #include <sys/types.h>
125 #include <sys/wait.h>
126
127 int main(void) 
128 {
129         struct flock lock;
130         int status;
131         int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
132         lock.l_type = F_WRLCK;
133         lock.l_whence = SEEK_SET;
134         lock.l_start = 0;
135         lock.l_len = 1;
136         lock.l_pid = 0;
137         
138         fcntl(fd,F_SETLK,&lock);
139         if (fork() == 0) {
140                 lock.l_start = 1;               
141                 exit(fcntl(fd,F_SETLK,&lock) == 0);
142         }
143         wait(&status);
144         unlink("conftest.dat");
145         exit(WEXITSTATUS(status));
146 }
147 ],
148 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
149 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
150    AC_SYS_LARGEFILE
151 fi
152
153 ipv6type=unknown
154 ipv6lib=none
155 ipv6trylibc=yes
156
157 AC_ARG_ENABLE(ipv6, 
158         AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
159
160 if test "x$enable_ipv6" != xno
161 then
162         AC_MSG_CHECKING([ipv6 stack type])
163         for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
164                 case $i in
165                 inria)
166                         # http://www.kame.net/
167                         AC_EGREP_CPP(yes, [
168 #include <netinet/in.h>
169 #ifdef IPV6_INRIA_VERSION
170 yes
171 #endif],
172                                 [ipv6type=$i;
173                                 AC_DEFINE(INET6, 1, [true if you have IPv6])
174                                 ])
175                         ;;
176                 kame)
177                         # http://www.kame.net/
178                         AC_EGREP_CPP(yes, [
179 #include <netinet/in.h>
180 #ifdef __KAME__
181 yes
182 #endif],
183                                 [ipv6type=$i; 
184                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
185                         ;;
186                 linux-glibc)
187                         # http://www.v6.linux.or.jp/
188                         AC_EGREP_CPP(yes, [
189 #include <features.h>
190 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
191 yes
192 #endif],
193                                 [ipv6type=$i;
194 AC_DEFINE(INET6, 1, [true if you have IPv6])])
195                         ;;
196                 linux-inet6)
197                         # http://www.v6.linux.or.jp/
198                         if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
199                                 ipv6type=$i
200                                 ipv6lib=inet6
201                                 ipv6libdir=/usr/inet6/lib
202                                 ipv6trylibc=yes;
203                                 AC_DEFINE(INET6, 1, [true if you have IPv6])
204                                 CFLAGS="-I/usr/inet6/include $CFLAGS"
205                         fi
206                         ;;
207                 toshiba)
208                         AC_EGREP_CPP(yes, [
209 #include <sys/param.h>
210 #ifdef _TOSHIBA_INET6
211 yes
212 #endif],
213                                 [ipv6type=$i;
214                                 ipv6lib=inet6;
215                                 ipv6libdir=/usr/local/v6/lib;
216                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
217                         ;;
218                 v6d)
219                         AC_EGREP_CPP(yes, [
220 #include </usr/local/v6/include/sys/v6config.h>
221 #ifdef __V6D__
222 yes
223 #endif],
224                                 [ipv6type=$i;
225                                 ipv6lib=v6;
226                                 ipv6libdir=/usr/local/v6/lib;
227                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
228                         ;;
229                 zeta)
230                         AC_EGREP_CPP(yes, [
231 #include <sys/param.h>
232 #ifdef _ZETA_MINAMI_INET6
233 yes
234 #endif],
235                                 [ipv6type=$i;
236                                 ipv6lib=inet6;
237                                 ipv6libdir=/usr/local/v6/lib;
238                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
239                         ;;
240                 esac
241                 if test "$ipv6type" != "unknown"; then
242                         break
243                 fi
244         done
245         AC_MSG_RESULT($ipv6type)
246
247         AC_SEARCH_LIBS(getaddrinfo, inet6)
248 fi
249
250 AC_C_BIGENDIAN
251 AC_HEADER_DIRENT
252 AC_HEADER_TIME
253 AC_HEADER_SYS_WAIT
254 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
255 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
256 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h)
257 AC_CHECK_HEADERS(glob.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
258 AC_CHECK_HEADERS(netdb.h)
259 AC_CHECK_HEADERS(malloc.h)
260 AC_CHECK_HEADERS(float.h)
261
262 AC_CHECK_SIZEOF(int)
263 AC_CHECK_SIZEOF(long)
264 AC_CHECK_SIZEOF(short)
265
266 AC_C_INLINE
267
268 AC_TYPE_SIGNAL
269 AC_TYPE_UID_T
270 AC_TYPE_MODE_T
271 AC_TYPE_OFF_T
272 AC_TYPE_SIZE_T
273 AC_TYPE_PID_T
274 AC_TYPE_GETGROUPS
275 AC_CHECK_MEMBERS([struct stat.st_rdev])
276
277 AC_CHECK_TYPE([ino_t], [unsigned])
278 TYPE_SOCKLEN_T
279
280 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
281     AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
282         rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
283 if test x"$rsync_cv_errno" = x"yes"; then
284    AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
285 fi
286
287 # The following test taken from the cvs sources
288 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
289 # These need checks to be before checks for any other functions that
290 #    might be in the same libraries.
291 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
292 # libsocket.so which has a bad implementation of gethostbyname (it
293 # only looks in /etc/hosts), so we only look for -lsocket if we need
294 # it.
295 AC_CHECK_FUNCS(connect)
296 if test x"$ac_cv_func_connect" = x"no"; then
297     case "$LIBS" in
298     *-lnsl*) ;;
299     *) AC_CHECK_LIB(nsl_s, printf) ;;
300     esac
301     case "$LIBS" in
302     *-lnsl*) ;;
303     *) AC_CHECK_LIB(nsl, printf) ;;
304     esac
305     case "$LIBS" in
306     *-lsocket*) ;;
307     *) AC_CHECK_LIB(socket, connect) ;;
308     esac
309     case "$LIBS" in
310     *-linet*) ;;
311     *) AC_CHECK_LIB(inet, connect) ;;
312     esac
313     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
314     dnl has been cached.
315     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
316        test x"$ac_cv_lib_inet_connect" = x"yes"; then
317         # ac_cv_func_connect=yes
318         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
319         AC_DEFINE(HAVE_CONNECT, 1, [ ])
320     fi
321 fi
322
323 AC_CHECK_LIB(resolv, inet_ntop)
324
325 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
326
327 AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop)) 
328 AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
329
330 # Irix 6.5 has getaddrinfo but not the corresponding defines, so use
331 #   builtin getaddrinfo if one of the defines don't exist
332 AC_MSG_CHECKING([whether defines needed by getaddrinfo exist])
333 AC_EGREP_CPP(yes, [
334 #include <sys/types.h>
335 #include <sys/socket.h>
336 #include <netdb.h>
337 #ifdef AI_PASSIVE
338 yes
339 #endif], [
340         AC_MSG_RESULT(yes)
341         # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
342         # something else so we must include <netdb.h> to get the
343         # redefinition.
344         AC_CHECK_FUNCS(getaddrinfo, ,
345                 [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
346                 AC_TRY_LINK([#include <sys/types.h>
347                 #include <sys/socket.h>
348                 #include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
349                         [AC_MSG_RESULT([yes])
350                         AC_DEFINE(HAVE_GETADDRINFO, 1,
351                                 [Define if you have the `getaddrinfo' function.])],
352                         [AC_MSG_RESULT([no])
353                         AC_LIBOBJ(lib/getaddrinfo)])])
354         AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
355         ],
356         [AC_MSG_RESULT(no)
357         AC_LIBOBJ(lib/getaddrinfo)
358         AC_LIBOBJ(lib/getnameinfo)])
359
360
361 AC_CHECK_MEMBER([struct sockaddr.sa_len], 
362                 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
363                 [],
364                 [
365 #include <sys/types.h>
366 #include <sys/socket.h>
367 ])
368
369 AC_MSG_CHECKING(struct sockaddr_storage)
370 AC_TRY_COMPILE([#include <sys/types.h>
371 #include <sys/socket.h>],
372 [struct sockaddr_storage x;],
373         AC_MSG_RESULT(yes)
374         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, 
375                 [Define if you have strct sockaddr_storage.] ),
376         AC_MSG_RESULT(no))
377
378 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
379                 [ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID) ],
380                 [],
381                 [
382 #include <sys/types.h>
383 #include <sys/socket.h>
384 #include <netinet/in.h>
385 ])
386
387 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
388 #
389 AC_CHECK_FUNCS(strcasecmp)
390 if test x"$ac_cv_func_strcasecmp" = x"no"; then
391     AC_CHECK_LIB(resolv, strcasecmp)
392 fi
393
394 dnl At the moment we don't test for a broken memcmp(), because all we
395 dnl need to do is test for equality, not comparison, and it seems that
396 dnl every platform has a memcmp that can do at least that.  
397 dnl AC_FUNC_MEMCMP
398
399 AC_FUNC_UTIME_NULL
400 AC_FUNC_ALLOCA
401 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
402 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
403 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
404 AC_CHECK_FUNCS(strlcat strlcpy strtol mtrace mallinfo setgroups)
405
406 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
407 AC_TRY_RUN([
408 #include <sys/types.h>
409 #include <sys/socket.h>
410
411 main() {
412        int fd[2];
413        exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
414 }],
415 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
416 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
417     AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
418 fi
419
420 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
421 AC_TRY_RUN([#include <fnmatch.h>
422 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
423                fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
424 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
425 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
426     AC_DEFINE(HAVE_FNMATCH, 1, [ ])
427 fi
428
429 if test x"$with_included_popt" != x"yes"
430 then
431     AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
432 fi
433
434 AC_MSG_CHECKING([whether to use included libpopt])
435 if test x"$with_included_popt" = x"yes"
436 then
437     AC_MSG_RESULT($srcdir/popt)
438     BUILD_POPT='$(popt_OBJS)'
439     CFLAGS="$CFLAGS -I$srcdir/popt"
440     if test x"$ALLOCA" != x
441     then
442         # this can be removed when/if we add an included alloca.c;
443         #  see autoconf documentation on AC_FUNC_ALLOCA
444         AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
445     fi
446 else
447     AC_MSG_RESULT(no)
448 fi
449
450 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
451 AC_TRY_RUN([#include <stdio.h>
452 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
453 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
454 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
455     AC_DEFINE(HAVE_LONGLONG, 1, [ ])
456 fi
457
458 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
459 AC_TRY_RUN([#include <stdio.h>
460 #include <sys/stat.h>
461 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
462 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
463 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
464     AC_DEFINE(HAVE_OFF64_T, 1, [ ])
465 fi
466
467 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
468 AC_TRY_RUN([#include <stdio.h>
469 #include <sys/types.h>
470 #include <sys/stat.h>
471 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
472 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
473 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
474     AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
475 fi
476
477 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
478 AC_TRY_RUN([#include <stdio.h>
479 main() { char c; c=250; exit((c > 0)?0:1); }],
480 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
481 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
482     AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
483 fi
484
485 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
486 AC_TRY_RUN([#include <sys/types.h>
487 #include <dirent.h>
488 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
489 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
490 di->d_name[0] == 0) exit(0); exit(1);} ],
491 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
492 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
493     AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
494 fi
495
496 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
497 AC_TRY_COMPILE([#include <sys/types.h>
498 #include <utime.h>],
499 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
500 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
501 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
502     AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
503 fi
504
505 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
506 AC_TRY_RUN([
507 #include <sys/time.h>
508 #include <unistd.h>
509 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
510            rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
511 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
512     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
513 fi
514
515 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
516 AC_TRY_RUN([
517 #include <sys/types.h>
518 #include <stdarg.h>
519 void foo(const char *format, ...) { 
520        va_list ap;
521        int len;
522        char buf[5];
523
524        va_start(ap, format);
525        len = vsnprintf(0, 0, format, ap);
526        va_end(ap);
527        if (len != 5) exit(1);
528
529        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
530
531        exit(0);
532 }
533 main() { foo("hello"); }
534 ],
535 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
536 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
537     AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
538 fi
539
540
541 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
542 AC_TRY_RUN([#include <stdlib.h>
543 #include <sys/types.h>
544 #include <sys/stat.h>
545 #include <unistd.h>
546 main() { 
547   struct stat st;
548   char tpl[20]="/tmp/test.XXXXXX"; 
549   int fd = mkstemp(tpl); 
550   if (fd == -1) exit(1);
551   unlink(tpl);
552   if (fstat(fd, &st) != 0) exit(1);
553   if ((st.st_mode & 0777) != 0600) exit(1);
554   exit(0);
555 }],
556 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
557 rsync_cv_HAVE_SECURE_MKSTEMP=no,
558 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
559 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
560     AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
561 fi
562
563
564 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
565 AC_TRY_RUN([
566 #include <stdio.h>
567 #include <sys/types.h>
568 #include <netinet/in.h>
569 #include <arpa/inet.h>
570 main() { struct in_addr ip; ip.s_addr = 0x12345678;
571 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
572     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); } 
573 exit(0);}],
574            rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
575 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
576     AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
577 fi
578
579
580 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
581 AC_TRY_RUN([
582 #include <stdio.h>
583 #include <sys/types.h>
584 #include <netinet/in.h>
585 #include <arpa/inet.h>
586 main() { struct in_addr ip; 
587 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
588            rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
589 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
590     AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
591 fi
592
593 #
594 # The following test was mostly taken from the tcl/tk plus patches
595 #
596 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
597 rm -rf conftest*
598 cat > conftest.$ac_ext <<EOF
599 int main() { return 0; }
600 EOF
601 ${CC-cc} -c -o conftest..o conftest.$ac_ext
602 if test -f conftest..o; then
603     rsync_cv_DASHC_WORKS_WITH_DASHO=yes
604 else
605     rsync_cv_DASHC_WORKS_WITH_DASHO=no
606 fi
607 rm -rf conftest*
608 ])
609 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
610     OBJ_SAVE="#"
611     OBJ_RESTORE="#"
612     CC_SHOBJ_FLAG='-o $@'
613 else
614     OBJ_SAVE='  @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
615     OBJ_RESTORE='       @b=`basename $@ .o`;if test "$$b.o" != "$@"; then mv $$b.o $@; if test -f $$b.o.sav; then mv $$b.o.sav $$b.o; fi; fi'
616     CC_SHOBJ_FLAG=""
617 fi
618
619 AC_SUBST(OBJ_SAVE)
620 AC_SUBST(OBJ_RESTORE)
621 AC_SUBST(CC_SHOBJ_FLAG)
622 AC_SUBST(BUILD_POPT)
623
624 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
625 AC_OUTPUT
626
627 AC_MSG_RESULT()
628 AC_MSG_RESULT([    rsync ${RSYNC_VERSION} configuration successful])
629 AC_MSG_RESULT()