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" ])
85 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
87 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
88 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
91 # arrgh. libc in the current debian stable screws up the largefile
92 # stuff, getting byte range locking wrong
93 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
95 #define _FILE_OFFSET_BITS 64
98 #include <sys/types.h>
105 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
106 lock.l_type = F_WRLCK;
107 lock.l_whence = SEEK_SET;
112 fcntl(fd,F_SETLK,&lock);
115 exit(fcntl(fd,F_SETLK,&lock) == 0);
118 unlink("conftest.dat");
119 exit(WEXITSTATUS(status));
122 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
123 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
132 AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
134 if test "x$enable_ipv6" != xno
136 AC_MSG_CHECKING([ipv6 stack type])
137 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
140 # http://www.kame.net/
142 #include <netinet/in.h>
143 #ifdef IPV6_INRIA_VERSION
147 AC_DEFINE(INET6, 1, [true if you have IPv6])
151 # http://www.kame.net/
153 #include <netinet/in.h>
158 AC_DEFINE(INET6, 1, [true if you have IPv6])])
161 # http://www.v6.linux.or.jp/
163 #include <features.h>
164 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
168 AC_DEFINE(INET6, 1, [true if you have IPv6])])
171 # http://www.v6.linux.or.jp/
172 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
175 ipv6libdir=/usr/inet6/lib
177 AC_DEFINE(INET6, 1, [true if you have IPv6])
178 CFLAGS="-I/usr/inet6/include $CFLAGS"
183 #include <sys/param.h>
184 #ifdef _TOSHIBA_INET6
189 ipv6libdir=/usr/local/v6/lib;
190 AC_DEFINE(INET6, 1, [true if you have IPv6])])
194 #include </usr/local/v6/include/sys/v6config.h>
200 ipv6libdir=/usr/local/v6/lib;
201 AC_DEFINE(INET6, 1, [true if you have IPv6])])
205 #include <sys/param.h>
206 #ifdef _ZETA_MINAMI_INET6
211 ipv6libdir=/usr/local/v6/lib;
212 AC_DEFINE(INET6, 1, [true if you have IPv6])])
215 if test "$ipv6type" != "unknown"; then
219 AC_MSG_RESULT($ipv6type)
221 AC_SEARCH_LIBS(getaddrinfo, inet6)
228 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
229 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
230 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
231 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
232 AC_CHECK_HEADERS(netdb.h)
233 AC_CHECK_HEADERS(malloc.h)
236 AC_CHECK_SIZEOF(long)
237 AC_CHECK_SIZEOF(short)
248 AC_CHECK_MEMBERS([struct stat.st_rdev])
250 AC_CHECK_TYPE([ino_t], [unsigned])
253 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
254 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
255 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
256 if test x"$rsync_cv_errno" = x"yes"; then
257 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
260 # The following test taken from the cvs sources
261 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
262 # These need checks to be before checks for any other functions that
263 # might be in the same libraries.
264 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
265 # libsocket.so which has a bad implementation of gethostbyname (it
266 # only looks in /etc/hosts), so we only look for -lsocket if we need
268 AC_CHECK_FUNCS(connect)
269 if test x"$ac_cv_func_connect" = x"no"; then
272 *) AC_CHECK_LIB(nsl_s, printf) ;;
276 *) AC_CHECK_LIB(nsl, printf) ;;
280 *) AC_CHECK_LIB(socket, connect) ;;
284 *) AC_CHECK_LIB(inet, connect) ;;
286 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
288 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
289 test x"$ac_cv_lib_inet_connect" = x"yes"; then
290 # ac_cv_func_connect=yes
291 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
292 AC_DEFINE(HAVE_CONNECT, 1, [ ])
296 AC_CHECK_LIB(resolv, inet_ntop)
298 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
300 AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop))
301 AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
303 AC_CHECK_FUNCS(getaddrinfo, , AC_LIBOBJ(lib/getaddrinfo))
304 AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
306 AC_CHECK_MEMBER([struct sockaddr.sa_len],
307 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
310 #include <sys/types.h>
311 #include <sys/socket.h>
314 AC_MSG_CHECKING(struct sockaddr_storage)
315 AC_TRY_COMPILE([#include <sys/types.h>
316 #include <sys/socket.h>],
317 [struct sockaddr_storage x;],
319 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
320 [Define if you have strct sockaddr_storage.] ),
323 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
325 AC_CHECK_FUNCS(strcasecmp)
326 if test x"$ac_cv_func_strcasecmp" = x"no"; then
327 AC_CHECK_LIB(resolv, strcasecmp)
330 dnl At the moment we don't test for a broken memcmp(), because all we
331 dnl need to do is test for equality, not comparison, and it seems that
332 dnl every platform has a memcmp that can do at least that.
336 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
337 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
338 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
339 AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo)
341 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
343 #include <sys/types.h>
344 #include <sys/socket.h>
348 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
350 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
351 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
352 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
355 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
356 AC_TRY_RUN([#include <fnmatch.h>
357 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
358 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
359 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
360 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
361 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
364 if test x"$with_included_popt" != x"yes"
366 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
369 AC_MSG_CHECKING([whether to use included libpopt])
370 if test x"$with_included_popt" = x"yes"
372 AC_MSG_RESULT($srcdir/popt)
373 BUILD_POPT='$(popt_OBJS)'
374 CFLAGS="$CFLAGS -I$srcdir/popt"
379 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
380 AC_TRY_RUN([#include <stdio.h>
381 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
382 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
383 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
384 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
387 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
388 AC_TRY_RUN([#include <stdio.h>
389 #include <sys/stat.h>
390 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
391 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
392 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
393 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
396 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
397 AC_TRY_RUN([#include <stdio.h>
398 #include <sys/types.h>
399 #include <sys/stat.h>
400 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
401 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
402 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
403 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
406 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
407 AC_TRY_RUN([#include <stdio.h>
408 main() { char c; c=250; exit((c > 0)?0:1); }],
409 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
410 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
411 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
414 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
415 AC_TRY_RUN([#include <sys/types.h>
417 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
418 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
419 di->d_name[0] == 0) exit(0); exit(1);} ],
420 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
421 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
422 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
425 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
426 AC_TRY_COMPILE([#include <sys/types.h>
428 [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
429 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
430 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
431 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
434 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
436 #include <sys/time.h>
438 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
439 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
440 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
441 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
444 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
446 #include <sys/types.h>
448 void foo(const char *format, ...) {
453 va_start(ap, format);
454 len = vsnprintf(0, 0, format, ap);
456 if (len != 5) exit(1);
458 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
462 main() { foo("hello"); }
464 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
465 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
466 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
470 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
471 AC_TRY_RUN([#include <stdlib.h>
472 #include <sys/types.h>
473 #include <sys/stat.h>
477 char tpl[20]="/tmp/test.XXXXXX";
478 int fd = mkstemp(tpl);
479 if (fd == -1) exit(1);
481 if (fstat(fd, &st) != 0) exit(1);
482 if ((st.st_mode & 0777) != 0600) exit(1);
485 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
486 rsync_cv_HAVE_SECURE_MKSTEMP=no,
487 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
488 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
489 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
493 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
496 #include <sys/types.h>
497 #include <netinet/in.h>
498 #include <arpa/inet.h>
499 main() { struct in_addr ip; ip.s_addr = 0x12345678;
500 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
501 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
503 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
504 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
505 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
509 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
512 #include <sys/types.h>
513 #include <netinet/in.h>
514 #include <arpa/inet.h>
515 main() { struct in_addr ip;
516 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
517 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
518 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
519 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
523 # The following test was mostly taken from the tcl/tk plus patches
525 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
527 cat > conftest.$ac_ext <<EOF
528 int main() { return 0; }
530 ${CC-cc} -c -o conftest..o conftest.$ac_ext
531 if test -f conftest..o; then
532 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
534 rsync_cv_DASHC_WORKS_WITH_DASHO=no
538 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
541 CC_SHOBJ_FLAG='-o $@'
543 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
544 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'
549 AC_SUBST(OBJ_RESTORE)
550 AC_SUBST(CC_SHOBJ_FLAG)
553 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
557 AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])