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.1-dev
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 if test "$xac_cv_prog_cc_stdc" = xno
27 AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
30 # compile with optimisation and without debugging by default, unless
31 # --debug is given. We must decide this before testing the compiler.
33 # Please allow this to default to yes, so that your users have more
34 # chance of getting a useful stack trace if problems occur.
36 AC_MSG_CHECKING([whether to include debugging symbols])
38 AC_HELP_STRING([--enable-debug],
39 [including debugging symbols and features (default yes)]),
42 if test x"$enable_debug" = x"no"
48 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
49 dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
50 dnl CFLAGS=${CFLAGS-"-g"}
53 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
55 # If GCC, turn on warnings.
56 if test "x$GCC" = "xyes"
58 CFLAGS="$CFLAGS -Wall"
61 AC_ARG_WITH(included-popt,
62 [ --with-included-popt use bundled popt library, not from system])
64 AC_ARG_WITH(rsync-path,
65 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
66 [ RSYNC_PATH="$with_rsync_path" ],
67 [ RSYNC_PATH="rsync" ])
68 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
70 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
71 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
74 # arrgh. libc in the current debian stable screws up the largefile
75 # stuff, getting byte range locking wrong
76 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
78 #define _FILE_OFFSET_BITS 64
81 #include <sys/types.h>
88 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
89 lock.l_type = F_WRLCK;
90 lock.l_whence = SEEK_SET;
95 fcntl(fd,F_SETLK,&lock);
98 exit(fcntl(fd,F_SETLK,&lock) == 0);
101 unlink("conftest.dat");
102 exit(WEXITSTATUS(status));
105 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
106 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
115 AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
117 if test "x$enable_ipv6" != xno
119 AC_MSG_CHECKING([ipv6 stack type])
120 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
123 # http://www.kame.net/
125 #include <netinet/in.h>
126 #ifdef IPV6_INRIA_VERSION
130 AC_DEFINE(INET6, 1, [true if you have IPv6])
134 # http://www.kame.net/
136 #include <netinet/in.h>
141 AC_DEFINE(INET6, 1, [true if you have IPv6])])
144 # http://www.v6.linux.or.jp/
146 #include <features.h>
147 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
151 AC_DEFINE(INET6, 1, [true if you have IPv6])])
154 # http://www.v6.linux.or.jp/
155 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
158 ipv6libdir=/usr/inet6/lib
160 AC_DEFINE(INET6, 1, [true if you have IPv6])
161 CFLAGS="-I/usr/inet6/include $CFLAGS"
166 #include <sys/param.h>
167 #ifdef _TOSHIBA_INET6
172 ipv6libdir=/usr/local/v6/lib;
173 AC_DEFINE(INET6, 1, [true if you have IPv6])])
177 #include </usr/local/v6/include/sys/v6config.h>
183 ipv6libdir=/usr/local/v6/lib;
184 AC_DEFINE(INET6, 1, [true if you have IPv6])])
188 #include <sys/param.h>
189 #ifdef _ZETA_MINAMI_INET6
194 ipv6libdir=/usr/local/v6/lib;
195 AC_DEFINE(INET6, 1, [true if you have IPv6])])
198 if test "$ipv6type" != "unknown"; then
202 AC_MSG_RESULT($ipv6type)
204 AC_SEARCH_LIBS(getaddrinfo, inet6)
211 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
212 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
213 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
214 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
215 AC_CHECK_HEADERS(netdb.h)
216 AC_CHECK_HEADERS(malloc.h)
219 AC_CHECK_SIZEOF(long)
220 AC_CHECK_SIZEOF(short)
231 AC_CHECK_MEMBERS([struct stat.st_rdev])
233 AC_CHECK_TYPE([ino_t], [unsigned])
236 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
237 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
238 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
239 if test x"$rsync_cv_errno" = x"yes"; then
240 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
243 # The following test taken from the cvs sources
244 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
245 # These need checks to be before checks for any other functions that
246 # might be in the same libraries.
247 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
248 # libsocket.so which has a bad implementation of gethostbyname (it
249 # only looks in /etc/hosts), so we only look for -lsocket if we need
251 AC_CHECK_FUNCS(connect)
252 if test x"$ac_cv_func_connect" = x"no"; then
255 *) AC_CHECK_LIB(nsl_s, printf) ;;
259 *) AC_CHECK_LIB(nsl, printf) ;;
263 *) AC_CHECK_LIB(socket, connect) ;;
267 *) AC_CHECK_LIB(inet, connect) ;;
269 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
271 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
272 test x"$ac_cv_lib_inet_connect" = x"yes"; then
273 # ac_cv_func_connect=yes
274 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
275 AC_DEFINE(HAVE_CONNECT, 1, [ ])
279 AC_CHECK_LIB(resolv, inet_ntop)
281 AC_MSG_NOTICE([Looking in libraries: $LIBS])
283 AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop))
284 AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
286 AC_CHECK_FUNCS(getaddrinfo, , AC_LIBOBJ(lib/getaddrinfo))
287 AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
289 AC_CHECK_MEMBER([struct sockaddr.sa_len],
290 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
293 #include <sys/types.h>
294 #include <sys/socket.h>
297 AC_MSG_CHECKING(struct sockaddr_storage)
298 AC_TRY_COMPILE([#include <sys/types.h>
299 #include <sys/socket.h>],
300 [struct sockaddr_storage x;],
302 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
303 [Define if you have strct sockaddr_storage.] ),
306 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
308 AC_CHECK_FUNCS(strcasecmp)
309 if test x"$ac_cv_func_strcasecmp" = x"no"; then
310 AC_CHECK_LIB(resolv, strcasecmp)
313 dnl At the moment we don't test for a broken memcmp(), because all we
314 dnl need to do is test for equality, not comparison, and it seems that
315 dnl every platform has a memcmp that can do at least that.
319 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
320 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
321 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
322 AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo)
324 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
326 #include <sys/types.h>
327 #include <sys/socket.h>
331 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
333 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
334 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
335 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
338 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
339 AC_TRY_RUN([#include <fnmatch.h>
340 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
341 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
342 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
343 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
344 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
347 if test x"$with_included_popt" != x"yes"
349 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
352 AC_MSG_CHECKING([whether to use included libpopt])
353 if test x"$with_included_popt" = x"yes"
355 AC_MSG_RESULT($srcdir/popt)
356 BUILD_POPT='$(popt_OBJS)'
357 CFLAGS="$CFLAGS -I$srcdir/popt"
362 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
363 AC_TRY_RUN([#include <stdio.h>
364 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
365 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
366 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
367 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
370 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
371 AC_TRY_RUN([#include <stdio.h>
372 #include <sys/stat.h>
373 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
374 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
375 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
376 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
379 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
380 AC_TRY_RUN([#include <stdio.h>
381 #include <sys/types.h>
382 #include <sys/stat.h>
383 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
384 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
385 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
386 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
389 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
390 AC_TRY_RUN([#include <stdio.h>
391 main() { char c; c=250; exit((c > 0)?0:1); }],
392 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
393 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
394 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
397 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
398 AC_TRY_RUN([#include <sys/types.h>
400 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
401 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
402 di->d_name[0] == 0) exit(0); exit(1);} ],
403 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
404 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
405 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
408 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
409 AC_TRY_COMPILE([#include <sys/types.h>
411 [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
412 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
413 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
414 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
417 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
419 #include <sys/time.h>
421 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
422 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
423 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
424 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
427 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
429 #include <sys/types.h>
431 void foo(const char *format, ...) {
436 va_start(ap, format);
437 len = vsnprintf(0, 0, format, ap);
439 if (len != 5) exit(1);
441 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
445 main() { foo("hello"); }
447 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
448 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
449 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
453 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
454 AC_TRY_RUN([#include <stdlib.h>
455 #include <sys/types.h>
456 #include <sys/stat.h>
460 char tpl[20]="/tmp/test.XXXXXX";
461 int fd = mkstemp(tpl);
462 if (fd == -1) exit(1);
464 if (fstat(fd, &st) != 0) exit(1);
465 if ((st.st_mode & 0777) != 0600) exit(1);
468 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
469 rsync_cv_HAVE_SECURE_MKSTEMP=no,
470 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
471 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
472 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
476 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
479 #include <sys/types.h>
480 #include <netinet/in.h>
481 #include <arpa/inet.h>
482 main() { struct in_addr ip; ip.s_addr = 0x12345678;
483 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
484 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
486 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
487 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
488 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
492 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
495 #include <sys/types.h>
496 #include <netinet/in.h>
497 #include <arpa/inet.h>
498 main() { struct in_addr ip;
499 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
500 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
501 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
502 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
506 # The following test was mostly taken from the tcl/tk plus patches
508 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
510 cat > conftest.$ac_ext <<EOF
511 int main() { return 0; }
513 ${CC-cc} -c -o conftest..o conftest.$ac_ext
514 if test -f conftest..o; then
515 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
517 rsync_cv_DASHC_WORKS_WITH_DASHO=no
521 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
524 CC_SHOBJ_FLAG='-o $@'
526 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
527 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'
532 AC_SUBST(OBJ_RESTORE)
533 AC_SUBST(CC_SHOBJ_FLAG)
536 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])