1 dnl Process this file with autoconf to produce a configure script.
4 AC_CONFIG_SRCDIR([byteorder.h])
5 AC_CONFIG_HEADER(config.h)
10 AC_CANONICAL_TARGET([])
12 dnl Checks for programs.
18 RSYNC_VERSION=2.4.7pre3
19 AC_SUBST(RSYNC_VERSION)
20 AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
22 # compile with optimisation and without debugging by default, unless
23 # --debug is given. We must decide this before testing the compiler.
25 AC_MSG_CHECKING([whether to include debugging symbols])
27 AC_HELP_STRING([--enable-debug],
28 [including debugging symbols and features (default yes)]),
31 if test x"$enable_debug" = x"no"
37 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
38 AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
39 dnl CFLAGS=${CFLAGS-"-g"}
42 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
44 AC_ARG_WITH(included-popt,
45 [ --with-included-popt use bundled popt library, not from system])
47 AC_ARG_WITH(rsync-path,
48 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
49 [ RSYNC_PATH="$with_rsync_path" ],
50 [ RSYNC_PATH="rsync" ])
51 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
53 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
54 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
57 # arrgh. libc in the current debian stable screws up the largefile
58 # stuff, getting byte range locking wrong
59 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
61 #define _FILE_OFFSET_BITS 64
64 #include <sys/types.h>
71 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
72 lock.l_type = F_WRLCK;
73 lock.l_whence = SEEK_SET;
78 fcntl(fd,F_SETLK,&lock);
81 exit(fcntl(fd,F_SETLK,&lock) == 0);
84 unlink("conftest.dat");
85 exit(WEXITSTATUS(status));
88 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
89 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
95 AC_DEFINE(ss_family, __ss_family, [KAME hack])
96 AC_DEFINE(ss_len, __ss_len, [KAME hack])
100 AC_HELP_STRING([--enable-ipv6], [try to support IPv6]))
101 AC_MSG_CHECKING([whether IPv6 is requested])
102 if test "$xenable_ipv6" = xyes
115 if test "$ipv6" = "yes"; then
116 AC_MSG_CHECKING([ipv6 stack type])
117 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
120 # http://www.kame.net/
122 #include <netinet/in.h>
123 #ifdef IPV6_INRIA_VERSION
127 AC_DEFINE(INET6, 1, [true if you have IPv6])
131 # http://www.kame.net/
133 #include <netinet/in.h>
138 AC_DEFINE(INET6, 1, [true if you have IPv6])])
141 # http://www.v6.linux.or.jp/
143 #include <features.h>
144 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
148 AC_DEFINE(INET6, 1, [true if you have IPv6])])
151 # http://www.v6.linux.or.jp/
152 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
155 ipv6libdir=/usr/inet6/lib
157 AC_DEFINE(INET6, 1, [true if you have IPv6])
158 CFLAGS="-I/usr/inet6/include $CFLAGS"
163 #include <sys/param.h>
164 #ifdef _TOSHIBA_INET6
169 ipv6libdir=/usr/local/v6/lib;
170 AC_DEFINE(INET6, 1, [true if you have IPv6])])
174 #include </usr/local/v6/include/sys/v6config.h>
180 ipv6libdir=/usr/local/v6/lib;
181 AC_DEFINE(INET6, 1, [true if you have IPv6])])
185 #include <sys/param.h>
186 #ifdef _ZETA_MINAMI_INET6
191 ipv6libdir=/usr/local/v6/lib;
192 AC_DEFINE(INET6, 1, [true if you have IPv6])])
195 if test "$ipv6type" != "unknown"; then
199 AC_MSG_RESULT($ipv6type)
202 if test "$ipv6" = "yes" -a -f /usr/local/v6/lib/libinet6.a; then
203 ac_inet6_LDFLAGS="inet6"
204 ipv6libdir=/usr/local/v6/lib
205 LDFLAGS="$LDFLAGS -L/usr/local/v6/lib"
206 AC_CHECK_LIB(inet6, getaddrinfo, , ipv6lib="$ac_inet6_LDFLAGS")
209 if test "$ipv6" = "yes" -a -f /usr/lib/libinet6.a; then
210 ac_inet6_LDFLAGS="inet6"
211 AC_CHECK_LIB(inet6, getaddrinfo, , ipv6lib="$ac_inet6_LDFLAGS")
214 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
215 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
216 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
217 AC_MSG_NOTICE([You have $ipv6lib library, using it])
219 if test "$ipv6trylibc" = "yes"; then
220 AC_MSG_WARN([You do not have $ipv6lib library, using libc])
222 AC_MSG_ERROR([No $ipv6lib library found. cannot continue. You need to fetch lib$ipv6lib.a from appropriate ipv6 kit and compile beforehand.])
228 AC_MSG_CHECKING(getaddrinfo bug)
230 #include <sys/types.h>
233 #include <sys/socket.h>
234 #include <netinet/in.h>
238 int passive, gaierr, inet4 = 0, inet6 = 0;
239 struct addrinfo hints, *ai, *aitop;
240 char straddr[INET6_ADDRSTRLEN], strport[16];
242 for (passive = 0; passive <= 1; passive++) {
243 memset(&hints, 0, sizeof(hints));
244 hints.ai_family = AF_UNSPEC;
245 hints.ai_flags = passive ? AI_PASSIVE : 0;
246 hints.ai_socktype = SOCK_STREAM;
247 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
248 (void)gai_strerror(gaierr);
251 for (ai = aitop; ai; ai = ai->ai_next) {
252 if (ai->ai_addr == NULL ||
253 ai->ai_addrlen == 0 ||
254 getnameinfo(ai->ai_addr, ai->ai_addrlen,
255 straddr, sizeof(straddr), strport, sizeof(strport),
256 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
259 switch (ai->ai_family) {
261 if (strcmp(strport, "54321") != 0) {
265 if (strcmp(straddr, "0.0.0.0") != 0) {
269 if (strcmp(straddr, "127.0.0.1") != 0) {
276 if (strcmp(strport, "54321") != 0) {
280 if (strcmp(straddr, "::") != 0) {
284 if (strcmp(straddr, "::1") != 0) {
294 /* another family support? */
300 if (!(inet4 == 0 || inet4 == 2))
302 if (!(inet6 == 0 || inet6 == 2))
318 buggygetaddrinfo=yes,
320 buggygetaddrinfo=yes)
322 if test "$buggygetaddrinfo" = "yes"; then
323 if test "$ipv6" = "yes" -a "$ipv6type" != "linux"; then
324 AC_MSG_ERROR([You must get working getaddrinfo() function or you can specify "--disable-ipv6"])
325 elif test "$ipv6type" = "linux"; then
326 AC_MSG_ERROR([getaddrinfo() implementation on your system seems be buggy. Better upgrade your system library to newest version of GNU C library (aka glibc).])
329 AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
331 AC_CHECK_MEMBER([struct sockaddr.sa_len],
332 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
335 #include <sys/types.h>
336 #include <sys/socket.h>
343 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
344 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
345 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
346 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
349 AC_CHECK_SIZEOF(long)
350 AC_CHECK_SIZEOF(short)
361 AC_CHECK_MEMBERS([struct stat.st_rdev])
363 AC_CHECK_TYPE([ino_t], [unsigned])
366 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
367 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
368 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
369 if test x"$rsync_cv_errno" = x"yes"; then
370 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
373 # The following test taken from the cvs sources
374 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
375 # These need checks to be before checks for any other functions that
376 # might be in the same libraries.
377 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
378 # libsocket.so which has a bad implementation of gethostbyname (it
379 # only looks in /etc/hosts), so we only look for -lsocket if we need
381 AC_CHECK_FUNCS(connect)
382 if test x"$ac_cv_func_connect" = x"no"; then
385 *) AC_CHECK_LIB(nsl_s, printf) ;;
389 *) AC_CHECK_LIB(nsl, printf) ;;
393 *) AC_CHECK_LIB(socket, connect) ;;
397 *) AC_CHECK_LIB(inet, connect) ;;
399 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
401 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
402 test x"$ac_cv_lib_inet_connect" = x"yes"; then
403 # ac_cv_func_connect=yes
404 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
405 AC_DEFINE(HAVE_CONNECT, 1, [ ])
410 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
412 AC_CHECK_FUNCS(strcasecmp)
413 if test x"$ac_cv_func_strcasecmp" = x"no"; then
414 AC_CHECK_LIB(resolv, strcasecmp)
419 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
420 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
421 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
422 AC_CHECK_FUNCS(strlcat strlcpy mtrace)
424 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
425 AC_TRY_RUN([#include <sys/types.h>
426 #include <sys/socket.h>
429 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
431 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
432 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
433 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
436 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
437 AC_TRY_RUN([#include <fnmatch.h>
438 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
439 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
440 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
441 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
442 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
445 if test x"$with_included_popt" != x"yes"
447 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
450 AC_MSG_CHECKING([whether to use included libpopt])
451 if test x"$with_included_popt" = x"yes"
453 AC_MSG_RESULT($srcdir/popt)
454 BUILD_POPT='$(popt_OBJS)'
455 CFLAGS="$CFLAGS -I$srcdir/popt"
460 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
461 AC_TRY_RUN([#include <stdio.h>
462 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
463 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
464 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
465 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
468 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
469 AC_TRY_RUN([#include <stdio.h>
470 #include <sys/stat.h>
471 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
472 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
473 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
474 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
477 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
478 AC_TRY_RUN([#include <stdio.h>
479 #include <sys/types.h>
480 #include <sys/stat.h>
481 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
482 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
483 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
484 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
487 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
488 AC_TRY_RUN([#include <stdio.h>
489 main() { char c; c=250; exit((c > 0)?0:1); }],
490 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
491 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
492 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
495 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
496 AC_TRY_RUN([#include <sys/types.h>
498 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
499 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
500 di->d_name[0] == 0) exit(0); exit(1);} ],
501 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
502 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
503 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
506 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
507 AC_TRY_COMPILE([#include <sys/types.h>
509 [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
510 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
511 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
512 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
515 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
517 #include <sys/time.h>
519 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
520 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
521 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
522 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
525 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
527 #include <sys/types.h>
529 void foo(const char *format, ...) {
534 va_start(ap, format);
535 len = vsnprintf(0, 0, format, ap);
537 if (len != 5) exit(1);
539 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
543 main() { foo("hello"); }
545 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
546 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
547 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
551 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
552 AC_TRY_RUN([#include <stdlib.h>
553 #include <sys/types.h>
554 #include <sys/stat.h>
558 char tpl[20]="/tmp/test.XXXXXX";
559 int fd = mkstemp(tpl);
560 if (fd == -1) exit(1);
562 if (fstat(fd, &st) != 0) exit(1);
563 if ((st.st_mode & 0777) != 0600) exit(1);
566 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
567 rsync_cv_HAVE_SECURE_MKSTEMP=no,
568 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
569 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
570 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
574 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
577 #include <sys/types.h>
578 #include <netinet/in.h>
579 #include <arpa/inet.h>
580 main() { struct in_addr ip; ip.s_addr = 0x12345678;
581 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
582 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
584 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
585 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
586 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
590 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
593 #include <sys/types.h>
594 #include <netinet/in.h>
595 #include <arpa/inet.h>
596 main() { struct in_addr ip;
597 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
598 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
599 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
600 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
604 # The following test was mostly taken from the tcl/tk plus patches
606 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
608 cat > conftest.$ac_ext <<EOF
609 int main() { return 0; }
611 ${CC-cc} -c -o conftest..o conftest.$ac_ext
612 if test -f conftest..o; then
613 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
615 rsync_cv_DASHC_WORKS_WITH_DASHO=no
619 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
622 CC_SHOBJ_FLAG='-o $@'
624 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
625 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'
630 AC_SUBST(OBJ_RESTORE)
631 AC_SUBST(CC_SHOBJ_FLAG)
634 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])