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