1 dnl Process this file with autoconf to produce a configure script.
4 AC_CONFIG_SRCDIR([byteorder.h])
5 AC_CONFIG_HEADER(config.h)
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 "$xac_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 # This is needed for our included version of popt. Kind of silly, but
69 # I don't want our version too far out of sync.
70 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
72 # If GCC, turn on warnings.
73 if test "x$GCC" = "xyes"
75 CFLAGS="$CFLAGS -Wall -W"
78 AC_ARG_WITH(included-popt,
79 [ --with-included-popt use bundled popt library, not from system])
81 AC_ARG_WITH(rsync-path,
82 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
83 [ RSYNC_PATH="$with_rsync_path" ],
84 [ RSYNC_PATH="rsync" ])
86 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
89 AC_HELP_STRING([--with-rsh=CMD], [set rsh command to CMD (default: \"remsh\" or \"rsh\")]))
91 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
92 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [remote shell is remsh not rsh])
94 if test x"$with_rsh" != x
97 elif test x"$HAVE_REMSH" = x1
104 AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
106 # arrgh. libc in the current debian stable screws up the largefile
107 # stuff, getting byte range locking wrong
108 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
110 #define _FILE_OFFSET_BITS 64
113 #include <sys/types.h>
114 #include <sys/wait.h>
120 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
121 lock.l_type = F_WRLCK;
122 lock.l_whence = SEEK_SET;
127 fcntl(fd,F_SETLK,&lock);
130 exit(fcntl(fd,F_SETLK,&lock) == 0);
133 unlink("conftest.dat");
134 exit(WEXITSTATUS(status));
137 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
138 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
147 AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
149 if test "x$enable_ipv6" != xno
151 AC_MSG_CHECKING([ipv6 stack type])
152 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
155 # http://www.kame.net/
157 #include <netinet/in.h>
158 #ifdef IPV6_INRIA_VERSION
162 AC_DEFINE(INET6, 1, [true if you have IPv6])
166 # http://www.kame.net/
168 #include <netinet/in.h>
173 AC_DEFINE(INET6, 1, [true if you have IPv6])])
176 # http://www.v6.linux.or.jp/
178 #include <features.h>
179 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
183 AC_DEFINE(INET6, 1, [true if you have IPv6])])
186 # http://www.v6.linux.or.jp/
187 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
190 ipv6libdir=/usr/inet6/lib
192 AC_DEFINE(INET6, 1, [true if you have IPv6])
193 CFLAGS="-I/usr/inet6/include $CFLAGS"
198 #include <sys/param.h>
199 #ifdef _TOSHIBA_INET6
204 ipv6libdir=/usr/local/v6/lib;
205 AC_DEFINE(INET6, 1, [true if you have IPv6])])
209 #include </usr/local/v6/include/sys/v6config.h>
215 ipv6libdir=/usr/local/v6/lib;
216 AC_DEFINE(INET6, 1, [true if you have IPv6])])
220 #include <sys/param.h>
221 #ifdef _ZETA_MINAMI_INET6
226 ipv6libdir=/usr/local/v6/lib;
227 AC_DEFINE(INET6, 1, [true if you have IPv6])])
230 if test "$ipv6type" != "unknown"; then
234 AC_MSG_RESULT($ipv6type)
236 AC_SEARCH_LIBS(getaddrinfo, inet6)
243 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
244 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
245 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
246 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
247 AC_CHECK_HEADERS(netdb.h)
248 AC_CHECK_HEADERS(malloc.h)
251 AC_CHECK_SIZEOF(long)
252 AC_CHECK_SIZEOF(short)
263 AC_CHECK_MEMBERS([struct stat.st_rdev])
265 AC_CHECK_TYPE([ino_t], [unsigned])
268 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
269 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
270 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
271 if test x"$rsync_cv_errno" = x"yes"; then
272 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
275 # The following test taken from the cvs sources
276 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
277 # These need checks to be before checks for any other functions that
278 # might be in the same libraries.
279 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
280 # libsocket.so which has a bad implementation of gethostbyname (it
281 # only looks in /etc/hosts), so we only look for -lsocket if we need
283 AC_CHECK_FUNCS(connect)
284 if test x"$ac_cv_func_connect" = x"no"; then
287 *) AC_CHECK_LIB(nsl_s, printf) ;;
291 *) AC_CHECK_LIB(nsl, printf) ;;
295 *) AC_CHECK_LIB(socket, connect) ;;
299 *) AC_CHECK_LIB(inet, connect) ;;
301 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
303 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
304 test x"$ac_cv_lib_inet_connect" = x"yes"; then
305 # ac_cv_func_connect=yes
306 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
307 AC_DEFINE(HAVE_CONNECT, 1, [ ])
311 AC_CHECK_LIB(resolv, inet_ntop)
313 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
315 AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop))
316 AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
318 AC_CHECK_FUNCS(getaddrinfo, , AC_LIBOBJ(lib/getaddrinfo))
319 AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
321 AC_CHECK_MEMBER([struct sockaddr.sa_len],
322 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
325 #include <sys/types.h>
326 #include <sys/socket.h>
329 AC_MSG_CHECKING(struct sockaddr_storage)
330 AC_TRY_COMPILE([#include <sys/types.h>
331 #include <sys/socket.h>],
332 [struct sockaddr_storage x;],
334 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
335 [Define if you have strct sockaddr_storage.] ),
338 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
340 AC_CHECK_FUNCS(strcasecmp)
341 if test x"$ac_cv_func_strcasecmp" = x"no"; then
342 AC_CHECK_LIB(resolv, strcasecmp)
345 dnl At the moment we don't test for a broken memcmp(), because all we
346 dnl need to do is test for equality, not comparison, and it seems that
347 dnl every platform has a memcmp that can do at least that.
351 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
352 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
353 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
354 AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo setgroups)
356 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
358 #include <sys/types.h>
359 #include <sys/socket.h>
363 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
365 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
366 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
367 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
370 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
371 AC_TRY_RUN([#include <fnmatch.h>
372 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
373 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
374 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
375 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
376 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
379 if test x"$with_included_popt" != x"yes"
381 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
384 AC_MSG_CHECKING([whether to use included libpopt])
385 if test x"$with_included_popt" = x"yes"
387 AC_MSG_RESULT($srcdir/popt)
388 BUILD_POPT='$(popt_OBJS)'
389 CFLAGS="$CFLAGS -I$srcdir/popt"
394 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
395 AC_TRY_RUN([#include <stdio.h>
396 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
397 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
398 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
399 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
402 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
403 AC_TRY_RUN([#include <stdio.h>
404 #include <sys/stat.h>
405 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
406 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
407 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
408 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
411 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
412 AC_TRY_RUN([#include <stdio.h>
413 #include <sys/types.h>
414 #include <sys/stat.h>
415 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
416 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
417 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
418 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
421 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
422 AC_TRY_RUN([#include <stdio.h>
423 main() { char c; c=250; exit((c > 0)?0:1); }],
424 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
425 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
426 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
429 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
430 AC_TRY_RUN([#include <sys/types.h>
432 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
433 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
434 di->d_name[0] == 0) exit(0); exit(1);} ],
435 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
436 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
437 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
440 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
441 AC_TRY_COMPILE([#include <sys/types.h>
443 [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
444 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
445 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
446 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
449 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
451 #include <sys/time.h>
453 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
454 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
455 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
456 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
459 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
461 #include <sys/types.h>
463 void foo(const char *format, ...) {
468 va_start(ap, format);
469 len = vsnprintf(0, 0, format, ap);
471 if (len != 5) exit(1);
473 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
477 main() { foo("hello"); }
479 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
480 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
481 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
485 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
486 AC_TRY_RUN([#include <stdlib.h>
487 #include <sys/types.h>
488 #include <sys/stat.h>
492 char tpl[20]="/tmp/test.XXXXXX";
493 int fd = mkstemp(tpl);
494 if (fd == -1) exit(1);
496 if (fstat(fd, &st) != 0) exit(1);
497 if ((st.st_mode & 0777) != 0600) exit(1);
500 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
501 rsync_cv_HAVE_SECURE_MKSTEMP=no,
502 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
503 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
504 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
508 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
511 #include <sys/types.h>
512 #include <netinet/in.h>
513 #include <arpa/inet.h>
514 main() { struct in_addr ip; ip.s_addr = 0x12345678;
515 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
516 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
518 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
519 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
520 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
524 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
527 #include <sys/types.h>
528 #include <netinet/in.h>
529 #include <arpa/inet.h>
530 main() { struct in_addr ip;
531 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
532 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
533 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
534 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
538 # The following test was mostly taken from the tcl/tk plus patches
540 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
542 cat > conftest.$ac_ext <<EOF
543 int main() { return 0; }
545 ${CC-cc} -c -o conftest..o conftest.$ac_ext
546 if test -f conftest..o; then
547 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
549 rsync_cv_DASHC_WORKS_WITH_DASHO=no
553 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
556 CC_SHOBJ_FLAG='-o $@'
558 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
559 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'
564 AC_SUBST(OBJ_RESTORE)
565 AC_SUBST(CC_SHOBJ_FLAG)
568 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
572 AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])