Prevent the "Connection reset by peer" messages often seen from Cygwin.
[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.6pre3cvs
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_MSG_CHECKING([default value for --modify-window])
251 case $host_os in
252         *cygwin* ) DEFAULT_MODIFY_WINDOW=${DEFAULT_MODIFY_WINDOW:-1};;
253                * ) DEFAULT_MODIFY_WINDOW=${DEFAULT_MODIFY_WINDOW:-0};;
254 esac
255 AC_MSG_RESULT($DEFAULT_MODIFY_WINDOW)
256 AC_DEFINE_UNQUOTED(DEFAULT_MODIFY_WINDOW, $DEFAULT_MODIFY_WINDOW,
257         [Set to the default value for the --modify-window option])
258
259 AC_MSG_CHECKING([whether to call shutdown on all sockets])
260 case $host_os in
261         *cygwin* ) AC_MSG_RESULT(yes)
262                    AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1, [Define if sockets need to be shutdown])
263                    ;;
264                * ) AC_MSG_RESULT(no);;
265 esac
266
267 AC_C_BIGENDIAN
268 AC_HEADER_DIRENT
269 AC_HEADER_TIME
270 AC_HEADER_SYS_WAIT
271 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
272 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
273 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h)
274 AC_CHECK_HEADERS(glob.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
275 AC_CHECK_HEADERS(netdb.h)
276 AC_CHECK_HEADERS(malloc.h)
277 AC_CHECK_HEADERS(float.h)
278
279 AC_CHECK_SIZEOF(int)
280 AC_CHECK_SIZEOF(long)
281 AC_CHECK_SIZEOF(short)
282
283 AC_C_INLINE
284
285 AC_TYPE_SIGNAL
286 AC_TYPE_UID_T
287 AC_TYPE_MODE_T
288 AC_TYPE_OFF_T
289 AC_TYPE_SIZE_T
290 AC_TYPE_PID_T
291 AC_TYPE_GETGROUPS
292 AC_CHECK_MEMBERS([struct stat.st_rdev])
293
294 AC_CHECK_TYPE([ino_t], [unsigned])
295 TYPE_SOCKLEN_T
296
297 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
298     AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
299         rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
300 if test x"$rsync_cv_errno" = x"yes"; then
301    AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
302 fi
303
304 # The following test taken from the cvs sources
305 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
306 # These need checks to be before checks for any other functions that
307 #    might be in the same libraries.
308 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
309 # libsocket.so which has a bad implementation of gethostbyname (it
310 # only looks in /etc/hosts), so we only look for -lsocket if we need
311 # it.
312 AC_CHECK_FUNCS(connect)
313 if test x"$ac_cv_func_connect" = x"no"; then
314     case "$LIBS" in
315     *-lnsl*) ;;
316     *) AC_CHECK_LIB(nsl_s, printf) ;;
317     esac
318     case "$LIBS" in
319     *-lnsl*) ;;
320     *) AC_CHECK_LIB(nsl, printf) ;;
321     esac
322     case "$LIBS" in
323     *-lsocket*) ;;
324     *) AC_CHECK_LIB(socket, connect) ;;
325     esac
326     case "$LIBS" in
327     *-linet*) ;;
328     *) AC_CHECK_LIB(inet, connect) ;;
329     esac
330     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
331     dnl has been cached.
332     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
333        test x"$ac_cv_lib_inet_connect" = x"yes"; then
334         # ac_cv_func_connect=yes
335         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
336         AC_DEFINE(HAVE_CONNECT, 1, [ ])
337     fi
338 fi
339
340 AC_CHECK_LIB(resolv, inet_ntop)
341
342 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
343
344 AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop)) 
345 AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
346
347 # Irix 6.5 has getaddrinfo but not the corresponding defines, so use
348 #   builtin getaddrinfo if one of the defines don't exist
349 AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
350                rsync_cv_HAVE_GETADDR_DEFINES,[
351                         AC_EGREP_CPP(yes, [
352                         #include <sys/types.h>
353                         #include <sys/socket.h>
354                         #include <netdb.h>
355                         #ifdef AI_PASSIVE
356                         yes
357                         #endif], 
358                         rsync_cv_HAVE_GETADDR_DEFINES=yes,
359                         rsync_cv_HAVE_GETADDR_DEFINES=no)])
360 if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
361         # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
362         # something else so we must include <netdb.h> to get the
363         # redefinition.
364         AC_CHECK_FUNCS(getaddrinfo, ,
365                 [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
366                 AC_TRY_LINK([#include <sys/types.h>
367                 #include <sys/socket.h>
368                 #include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
369                         [AC_MSG_RESULT([yes])
370                         AC_DEFINE(HAVE_GETADDRINFO, 1,
371                                 [Define if you have the `getaddrinfo' function.])],
372                         [AC_MSG_RESULT([no])
373                         AC_LIBOBJ(lib/getaddrinfo)])])
374         AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
375 else
376         AC_LIBOBJ(lib/getaddrinfo)
377         AC_LIBOBJ(lib/getnameinfo)
378 fi
379
380
381 AC_CHECK_MEMBER([struct sockaddr.sa_len], 
382                 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
383                 [],
384                 [
385 #include <sys/types.h>
386 #include <sys/socket.h>
387 ])
388
389 AC_MSG_CHECKING(struct sockaddr_storage)
390 AC_TRY_COMPILE([#include <sys/types.h>
391 #include <sys/socket.h>],
392 [struct sockaddr_storage x;],
393         AC_MSG_RESULT(yes)
394         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, 
395                 [Define if you have strct sockaddr_storage.] ),
396         AC_MSG_RESULT(no))
397
398 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
399                 [ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID) ],
400                 [],
401                 [
402 #include <sys/types.h>
403 #include <sys/socket.h>
404 #include <netinet/in.h>
405 ])
406
407 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
408 #
409 AC_CHECK_FUNCS(strcasecmp)
410 if test x"$ac_cv_func_strcasecmp" = x"no"; then
411     AC_CHECK_LIB(resolv, strcasecmp)
412 fi
413
414 dnl At the moment we don't test for a broken memcmp(), because all we
415 dnl need to do is test for equality, not comparison, and it seems that
416 dnl every platform has a memcmp that can do at least that.  
417 dnl AC_FUNC_MEMCMP
418
419 AC_FUNC_UTIME_NULL
420 AC_FUNC_ALLOCA
421 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
422 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
423 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
424 AC_CHECK_FUNCS(strlcat strlcpy strtol mtrace mallinfo setgroups)
425
426 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
427 AC_TRY_RUN([
428 #include <sys/types.h>
429 #include <sys/socket.h>
430
431 main() {
432        int fd[2];
433        exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
434 }],
435 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
436 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
437     AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
438 fi
439
440 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
441 AC_TRY_RUN([#include <fnmatch.h>
442 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
443                fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
444 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
445 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
446     AC_DEFINE(HAVE_FNMATCH, 1, [ ])
447 fi
448
449 if test x"$with_included_popt" != x"yes"
450 then
451     AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
452 fi
453
454 AC_MSG_CHECKING([whether to use included libpopt])
455 if test x"$with_included_popt" = x"yes"
456 then
457     AC_MSG_RESULT($srcdir/popt)
458     BUILD_POPT='$(popt_OBJS)'
459     CFLAGS="$CFLAGS -I$srcdir/popt"
460     if test x"$ALLOCA" != x
461     then
462         # this can be removed when/if we add an included alloca.c;
463         #  see autoconf documentation on AC_FUNC_ALLOCA
464         AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
465     fi
466 else
467     AC_MSG_RESULT(no)
468 fi
469
470 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
471 AC_TRY_RUN([#include <stdio.h>
472 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
473 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
474 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
475     AC_DEFINE(HAVE_LONGLONG, 1, [ ])
476 fi
477
478 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
479 AC_TRY_RUN([#include <stdio.h>
480 #include <sys/stat.h>
481 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
482 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
483 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
484     AC_DEFINE(HAVE_OFF64_T, 1, [ ])
485 fi
486
487 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
488 AC_TRY_RUN([#include <stdio.h>
489 #include <sys/types.h>
490 #include <sys/stat.h>
491 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
492 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
493 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
494     AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
495 fi
496
497 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
498 AC_TRY_RUN([#include <stdio.h>
499 main() { char c; c=250; exit((c > 0)?0:1); }],
500 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
501 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
502     AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
503 fi
504
505 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
506 AC_TRY_RUN([#include <sys/types.h>
507 #include <dirent.h>
508 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
509 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
510 di->d_name[0] == 0) exit(0); exit(1);} ],
511 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
512 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
513     AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
514 fi
515
516 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
517 AC_TRY_COMPILE([#include <sys/types.h>
518 #include <utime.h>],
519 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
520 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
521 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
522     AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
523 fi
524
525 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
526 AC_TRY_RUN([
527 #include <sys/time.h>
528 #include <unistd.h>
529 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
530            rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
531 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
532     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
533 fi
534
535 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
536 AC_TRY_RUN([
537 #include <sys/types.h>
538 #include <stdarg.h>
539 void foo(const char *format, ...) { 
540        va_list ap;
541        int len;
542        char buf[5];
543
544        va_start(ap, format);
545        len = vsnprintf(0, 0, format, ap);
546        va_end(ap);
547        if (len != 5) exit(1);
548
549        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
550
551        exit(0);
552 }
553 main() { foo("hello"); }
554 ],
555 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
556 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
557     AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
558 fi
559
560
561 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
562 AC_TRY_RUN([#include <stdlib.h>
563 #include <sys/types.h>
564 #include <sys/stat.h>
565 #include <unistd.h>
566 main() { 
567   struct stat st;
568   char tpl[20]="/tmp/test.XXXXXX"; 
569   int fd = mkstemp(tpl); 
570   if (fd == -1) exit(1);
571   unlink(tpl);
572   if (fstat(fd, &st) != 0) exit(1);
573   if ((st.st_mode & 0777) != 0600) exit(1);
574   exit(0);
575 }],
576 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
577 rsync_cv_HAVE_SECURE_MKSTEMP=no,
578 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
579 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
580     AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
581 fi
582
583
584 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
585 AC_TRY_RUN([
586 #include <stdio.h>
587 #include <sys/types.h>
588 #include <netinet/in.h>
589 #include <arpa/inet.h>
590 main() { struct in_addr ip; ip.s_addr = 0x12345678;
591 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
592     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); } 
593 exit(0);}],
594            rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
595 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
596     AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
597 fi
598
599
600 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
601 AC_TRY_RUN([
602 #include <stdio.h>
603 #include <sys/types.h>
604 #include <netinet/in.h>
605 #include <arpa/inet.h>
606 main() { struct in_addr ip; 
607 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
608            rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
609 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
610     AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
611 fi
612
613 #
614 # The following test was mostly taken from the tcl/tk plus patches
615 #
616 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
617 rm -rf conftest*
618 cat > conftest.$ac_ext <<EOF
619 int main() { return 0; }
620 EOF
621 ${CC-cc} -c -o conftest..o conftest.$ac_ext
622 if test -f conftest..o; then
623     rsync_cv_DASHC_WORKS_WITH_DASHO=yes
624 else
625     rsync_cv_DASHC_WORKS_WITH_DASHO=no
626 fi
627 rm -rf conftest*
628 ])
629 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
630     OBJ_SAVE="#"
631     OBJ_RESTORE="#"
632     CC_SHOBJ_FLAG='-o $@'
633 else
634     OBJ_SAVE='  @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
635     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'
636     CC_SHOBJ_FLAG=""
637 fi
638
639 AC_SUBST(OBJ_SAVE)
640 AC_SUBST(OBJ_RESTORE)
641 AC_SUBST(CC_SHOBJ_FLAG)
642 AC_SUBST(BUILD_POPT)
643
644 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
645 AC_OUTPUT
646
647 AC_MSG_RESULT()
648 AC_MSG_RESULT([    rsync ${RSYNC_VERSION} configuration successful])
649 AC_MSG_RESULT()