1 dnl Process this file with autoconf to produce a configure script.
4 AC_CONFIG_SRCDIR([byteorder.h])
5 AC_CONFIG_HEADER(config.h)
8 RSYNC_VERSION=2.5.6pre3cvs
9 AC_SUBST(RSYNC_VERSION)
10 AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
12 AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
16 AC_CANONICAL_TARGET([])
18 dnl Checks for programs.
25 AC_DEFINE([_GNU_SOURCE], 1,
26 [Define _GNU_SOURCE so that we get all necessary prototypes])
28 if test "x$ac_cv_prog_cc_stdc" = xno
30 AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
33 # We must decide this before testing the compiler.
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.
38 AC_MSG_CHECKING([whether to include debugging symbols])
40 AC_HELP_STRING([--enable-debug],
41 [including debugging symbols and features (default yes)]),
44 if test x"$enable_debug" = x"no"
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"}
58 AC_ARG_ENABLE(profile,
59 AC_HELP_STRING([--enable-profile],
60 [turn on CPU profiling (default no)],
62 if test x"$enable_profile" = xyes
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],
73 if test x"$enable_maintainer_mode" = xyes
75 CFLAGS="$CFLAGS -DMAINTAINER_MODE"
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"
83 # If GCC, turn on warnings.
84 if test "x$GCC" = "xyes"
86 CFLAGS="$CFLAGS -Wall -W"
89 AC_ARG_WITH(included-popt,
90 [ --with-included-popt use bundled popt library, not from system])
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" ])
97 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
100 AC_HELP_STRING([--with-rsh=CMD], [set rsh command to CMD (default: \"remsh\" or \"rsh\")]))
102 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
103 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [remote shell is remsh not rsh])
105 if test x"$with_rsh" != x
107 RSYNC_RSH="$with_rsh"
108 elif test x"$HAVE_REMSH" = x1
115 AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
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,[
121 #define _FILE_OFFSET_BITS 64
124 #include <sys/types.h>
125 #include <sys/wait.h>
131 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
132 lock.l_type = F_WRLCK;
133 lock.l_whence = SEEK_SET;
138 fcntl(fd,F_SETLK,&lock);
141 exit(fcntl(fd,F_SETLK,&lock) == 0);
144 unlink("conftest.dat");
145 exit(WEXITSTATUS(status));
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
158 AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
160 if test "x$enable_ipv6" != xno
162 AC_MSG_CHECKING([ipv6 stack type])
163 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
166 # http://www.kame.net/
168 #include <netinet/in.h>
169 #ifdef IPV6_INRIA_VERSION
173 AC_DEFINE(INET6, 1, [true if you have IPv6])
177 # http://www.kame.net/
179 #include <netinet/in.h>
184 AC_DEFINE(INET6, 1, [true if you have IPv6])])
187 # http://www.v6.linux.or.jp/
189 #include <features.h>
190 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
194 AC_DEFINE(INET6, 1, [true if you have IPv6])])
197 # http://www.v6.linux.or.jp/
198 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
201 ipv6libdir=/usr/inet6/lib
203 AC_DEFINE(INET6, 1, [true if you have IPv6])
204 CFLAGS="-I/usr/inet6/include $CFLAGS"
209 #include <sys/param.h>
210 #ifdef _TOSHIBA_INET6
215 ipv6libdir=/usr/local/v6/lib;
216 AC_DEFINE(INET6, 1, [true if you have IPv6])])
220 #include </usr/local/v6/include/sys/v6config.h>
226 ipv6libdir=/usr/local/v6/lib;
227 AC_DEFINE(INET6, 1, [true if you have IPv6])])
231 #include <sys/param.h>
232 #ifdef _ZETA_MINAMI_INET6
237 ipv6libdir=/usr/local/v6/lib;
238 AC_DEFINE(INET6, 1, [true if you have IPv6])])
241 if test "$ipv6type" != "unknown"; then
245 AC_MSG_RESULT($ipv6type)
247 AC_SEARCH_LIBS(getaddrinfo, inet6)
250 AC_MSG_CHECKING([whether to call shutdown on all sockets])
252 *cygwin* ) AC_MSG_RESULT(yes)
253 AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1,
254 [Define if sockets need to be shutdown])
256 * ) AC_MSG_RESULT(no);;
259 AC_MSG_CHECKING([whether generator should delay before signaling receiver])
261 *cygwin* ) AC_MSG_RESULT(yes)
262 AC_DEFINE(DELAY_BEFORE_SIGNALING_RECEIVER, 1,
263 [Define if generator should delay before signaling receiver])
265 * ) AC_MSG_RESULT(no);;
272 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
273 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
274 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h)
275 AC_CHECK_HEADERS(glob.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
276 AC_CHECK_HEADERS(netdb.h)
277 AC_CHECK_HEADERS(malloc.h)
278 AC_CHECK_HEADERS(float.h)
281 AC_CHECK_SIZEOF(long)
282 AC_CHECK_SIZEOF(short)
293 AC_CHECK_MEMBERS([struct stat.st_rdev])
295 AC_CHECK_TYPE([ino_t], [unsigned])
298 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
299 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
300 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
301 if test x"$rsync_cv_errno" = x"yes"; then
302 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
305 # The following test taken from the cvs sources
306 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
307 # These need checks to be before checks for any other functions that
308 # might be in the same libraries.
309 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
310 # libsocket.so which has a bad implementation of gethostbyname (it
311 # only looks in /etc/hosts), so we only look for -lsocket if we need
313 AC_CHECK_FUNCS(connect)
314 if test x"$ac_cv_func_connect" = x"no"; then
317 *) AC_CHECK_LIB(nsl_s, printf) ;;
321 *) AC_CHECK_LIB(nsl, printf) ;;
325 *) AC_CHECK_LIB(socket, connect) ;;
329 *) AC_CHECK_LIB(inet, connect) ;;
331 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
333 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
334 test x"$ac_cv_lib_inet_connect" = x"yes"; then
335 # ac_cv_func_connect=yes
336 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
337 AC_DEFINE(HAVE_CONNECT, 1, [ ])
341 AC_CHECK_LIB(resolv, inet_ntop)
343 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
345 AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop))
346 AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
348 # Irix 6.5 has getaddrinfo but not the corresponding defines, so use
349 # builtin getaddrinfo if one of the defines don't exist
350 AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
351 rsync_cv_HAVE_GETADDR_DEFINES,[
353 #include <sys/types.h>
354 #include <sys/socket.h>
359 rsync_cv_HAVE_GETADDR_DEFINES=yes,
360 rsync_cv_HAVE_GETADDR_DEFINES=no)])
361 if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
362 # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
363 # something else so we must include <netdb.h> to get the
365 AC_CHECK_FUNCS(getaddrinfo, ,
366 [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
367 AC_TRY_LINK([#include <sys/types.h>
368 #include <sys/socket.h>
369 #include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
370 [AC_MSG_RESULT([yes])
371 AC_DEFINE(HAVE_GETADDRINFO, 1,
372 [Define if you have the `getaddrinfo' function.])],
374 AC_LIBOBJ(lib/getaddrinfo)])])
375 AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
377 AC_LIBOBJ(lib/getaddrinfo)
378 AC_LIBOBJ(lib/getnameinfo)
382 AC_CHECK_MEMBER([struct sockaddr.sa_len],
383 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
386 #include <sys/types.h>
387 #include <sys/socket.h>
390 AC_MSG_CHECKING(struct sockaddr_storage)
391 AC_TRY_COMPILE([#include <sys/types.h>
392 #include <sys/socket.h>],
393 [struct sockaddr_storage x;],
395 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
396 [Define if you have strct sockaddr_storage.] ),
399 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
400 [ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID) ],
403 #include <sys/types.h>
404 #include <sys/socket.h>
405 #include <netinet/in.h>
408 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
410 AC_CHECK_FUNCS(strcasecmp)
411 if test x"$ac_cv_func_strcasecmp" = x"no"; then
412 AC_CHECK_LIB(resolv, strcasecmp)
415 dnl At the moment we don't test for a broken memcmp(), because all we
416 dnl need to do is test for equality, not comparison, and it seems that
417 dnl every platform has a memcmp that can do at least that.
422 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
423 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
424 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
425 AC_CHECK_FUNCS(strlcat strlcpy strtol mtrace mallinfo setgroups)
427 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
429 #include <sys/types.h>
430 #include <sys/socket.h>
434 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
436 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
437 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
438 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
441 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
442 AC_TRY_RUN([#include <fnmatch.h>
443 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
444 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
445 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
446 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
447 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
450 if test x"$with_included_popt" != x"yes"
452 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
455 AC_MSG_CHECKING([whether to use included libpopt])
456 if test x"$with_included_popt" = x"yes"
458 AC_MSG_RESULT($srcdir/popt)
459 BUILD_POPT='$(popt_OBJS)'
460 CFLAGS="$CFLAGS -I$srcdir/popt"
461 if test x"$ALLOCA" != x
463 # this can be removed when/if we add an included alloca.c;
464 # see autoconf documentation on AC_FUNC_ALLOCA
465 AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
471 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
472 AC_TRY_RUN([#include <stdio.h>
473 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
474 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
475 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
476 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
479 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
480 AC_TRY_RUN([#include <stdio.h>
481 #include <sys/stat.h>
482 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
483 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
484 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
485 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
488 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
489 AC_TRY_RUN([#include <stdio.h>
490 #include <sys/types.h>
491 #include <sys/stat.h>
492 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
493 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
494 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
495 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
498 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
499 AC_TRY_RUN([#include <stdio.h>
500 main() { char c; c=250; exit((c > 0)?0:1); }],
501 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
502 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
503 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
506 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
507 AC_TRY_RUN([#include <sys/types.h>
509 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
510 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
511 di->d_name[0] == 0) exit(0); exit(1);} ],
512 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
513 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
514 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
517 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
518 AC_TRY_COMPILE([#include <sys/types.h>
520 [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
521 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
522 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
523 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
526 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
528 #include <sys/time.h>
530 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
531 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
532 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
533 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
536 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
538 #include <sys/types.h>
540 void foo(const char *format, ...) {
545 va_start(ap, format);
546 len = vsnprintf(0, 0, format, ap);
548 if (len != 5) exit(1);
550 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
554 main() { foo("hello"); }
556 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
557 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
558 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
562 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
563 AC_TRY_RUN([#include <stdlib.h>
564 #include <sys/types.h>
565 #include <sys/stat.h>
569 char tpl[20]="/tmp/test.XXXXXX";
570 int fd = mkstemp(tpl);
571 if (fd == -1) exit(1);
573 if (fstat(fd, &st) != 0) exit(1);
574 if ((st.st_mode & 0777) != 0600) exit(1);
577 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
578 rsync_cv_HAVE_SECURE_MKSTEMP=no,
579 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
580 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
581 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
585 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
588 #include <sys/types.h>
589 #include <netinet/in.h>
590 #include <arpa/inet.h>
591 main() { struct in_addr ip; ip.s_addr = 0x12345678;
592 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
593 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
595 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
596 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
597 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
601 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
604 #include <sys/types.h>
605 #include <netinet/in.h>
606 #include <arpa/inet.h>
607 main() { struct in_addr ip;
608 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
609 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
610 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
611 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
615 # The following test was mostly taken from the tcl/tk plus patches
617 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
619 cat > conftest.$ac_ext <<EOF
620 int main() { return 0; }
622 ${CC-cc} -c -o conftest..o conftest.$ac_ext
623 if test -f conftest..o; then
624 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
626 rsync_cv_DASHC_WORKS_WITH_DASHO=no
630 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
633 CC_SHOBJ_FLAG='-o $@'
635 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
636 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'
641 AC_SUBST(OBJ_RESTORE)
642 AC_SUBST(CC_SHOBJ_FLAG)
645 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
649 AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])