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 # compile with optimisation and without debugging by default, unless
19 # --debug is given. We must decide this before testing the compiler.
21 AC_MSG_CHECKING([whether to include debugging symbols])
23 AC_HELP_STRING([--enable-debug],
24 [including debugging symbols and features (default yes)]),
27 if test x"$enable_debug" = x"no"
33 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
34 AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
35 dnl CFLAGS=${CFLAGS-"-g"}
38 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
40 AC_ARG_WITH(included-popt,
41 [ --with-included-popt use bundled popt library, not from system])
43 AC_ARG_WITH(rsync-path,
44 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
45 [ RSYNC_PATH="$with_rsync_path" ],
46 [ RSYNC_PATH="rsync" ])
47 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
49 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
50 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
53 # arrgh. libc in the current debian stable screws up the largefile
54 # stuff, getting byte range locking wrong
55 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
57 #define _FILE_OFFSET_BITS 64
60 #include <sys/types.h>
67 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
68 lock.l_type = F_WRLCK;
69 lock.l_whence = SEEK_SET;
74 fcntl(fd,F_SETLK,&lock);
77 exit(fcntl(fd,F_SETLK,&lock) == 0);
80 unlink("conftest.dat");
81 exit(WEXITSTATUS(status));
84 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
85 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
91 AC_DEFINE(ss_family, __ss_family, [KAME hack])
92 AC_DEFINE(ss_len, __ss_len, [KAME hack])
95 AC_MSG_CHECKING([whether IPv6 is explicitly enabled])
97 [ --enable-ipv6 Enable ipv6 (with ipv4) support
98 --disable-ipv6 Disable ipv6 support],
99 [ case "$enableval" in
106 AC_DEFINE(ENABLE_IPV6)
112 dnl not specified; let's try
113 AC_MSG_CHECKING([whether IPv6 works anyhow])
115 #include <sys/types.h>
116 #include <sys/socket.h>
121 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
129 AC_DEFINE(ENABLE_IPV6)
138 if test "$ipv6" = "yes"; then
139 AC_MSG_CHECKING([ipv6 stack type])
140 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
143 # http://www.kame.net/
145 #include <netinet/in.h>
146 #ifdef IPV6_INRIA_VERSION
150 CFLAGS="-DINET6 $CFLAGS"])
153 # http://www.kame.net/
155 #include <netinet/in.h>
160 CFLAGS="-DINET6 $CFLAGS"])
163 # http://www.v6.linux.or.jp/
165 #include <features.h>
166 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
170 CFLAGS="-DINET6 $CFLAGS"])
173 # http://www.v6.linux.or.jp/
174 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
177 ipv6libdir=/usr/inet6/lib
179 CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
184 #include <sys/param.h>
185 #ifdef _TOSHIBA_INET6
190 ipv6libdir=/usr/local/v6/lib;
191 CFLAGS="-DINET6 $CFLAGS"])
195 #include </usr/local/v6/include/sys/v6config.h>
201 ipv6libdir=/usr/local/v6/lib;
202 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
206 #include <sys/param.h>
207 #ifdef _ZETA_MINAMI_INET6
212 ipv6libdir=/usr/local/v6/lib;
213 CFLAGS="-DINET6 $CFLAGS"])
216 if test "$ipv6type" != "unknown"; then
220 AC_MSG_RESULT($ipv6type)
223 if test "$ipv6" = "yes" -a -f /usr/local/v6/lib/libinet6.a; then
224 ac_inet6_LDFLAGS="inet6"
225 ipv6libdir=/usr/local/v6/lib
226 LDFLAGS="$LDFLAGS -L/usr/local/v6/lib"
227 AC_CHECK_LIB(inet6, getaddrinfo, , ipv6lib="$ac_inet6_LDFLAGS")
230 if test "$ipv6" = "yes" -a -f /usr/lib/libinet6.a; then
231 ac_inet6_LDFLAGS="inet6"
232 AC_CHECK_LIB(inet6, getaddrinfo, , ipv6lib="$ac_inet6_LDFLAGS")
235 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
236 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
237 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
238 echo "You have $ipv6lib library, using it"
240 if test "$ipv6trylibc" = "yes"; then
241 echo "You do not have $ipv6lib library, using libc"
243 echo 'Fatal: no $ipv6lib library found. cannot continue.'
244 echo "You need to fetch lib$ipv6lib.a from appropriate"
245 echo 'ipv6 kit and compile beforehand.'
252 AC_MSG_CHECKING(getaddrinfo bug)
254 #include <sys/types.h>
257 #include <sys/socket.h>
258 #include <netinet/in.h>
262 int passive, gaierr, inet4 = 0, inet6 = 0;
263 struct addrinfo hints, *ai, *aitop;
264 char straddr[INET6_ADDRSTRLEN], strport[16];
266 for (passive = 0; passive <= 1; passive++) {
267 memset(&hints, 0, sizeof(hints));
268 hints.ai_family = AF_UNSPEC;
269 hints.ai_flags = passive ? AI_PASSIVE : 0;
270 hints.ai_socktype = SOCK_STREAM;
271 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
272 (void)gai_strerror(gaierr);
275 for (ai = aitop; ai; ai = ai->ai_next) {
276 if (ai->ai_addr == NULL ||
277 ai->ai_addrlen == 0 ||
278 getnameinfo(ai->ai_addr, ai->ai_addrlen,
279 straddr, sizeof(straddr), strport, sizeof(strport),
280 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
283 switch (ai->ai_family) {
285 if (strcmp(strport, "54321") != 0) {
289 if (strcmp(straddr, "0.0.0.0") != 0) {
293 if (strcmp(straddr, "127.0.0.1") != 0) {
300 if (strcmp(strport, "54321") != 0) {
304 if (strcmp(straddr, "::") != 0) {
308 if (strcmp(straddr, "::1") != 0) {
318 /* another family support? */
324 if (!(inet4 == 0 || inet4 == 2))
326 if (!(inet6 == 0 || inet6 == 2))
342 buggygetaddrinfo=yes,
344 buggygetaddrinfo=yes)
346 if test "$buggygetaddrinfo" = "yes"; then
347 if test "$ipv6" = "yes" -a "$ipv6type" != "linux"; then
348 echo 'Fatal: You must get working getaddrinfo() function.'
349 echo ' or you can specify "--disable-ipv6"'.
351 elif test "$ipv6type" = "linux"; then
352 echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
353 echo ' Better upgreade your system library to newest version'
354 echo ' of GNU C library (aka glibc).'
357 AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
359 AC_CHECK_MEMBER([struct sockaddr.sa_len],
360 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
363 #include <sys/types.h>
364 #include <sys/socket.h>
371 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
372 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
373 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
374 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
377 AC_CHECK_SIZEOF(long)
378 AC_CHECK_SIZEOF(short)
389 AC_CHECK_MEMBERS([struct stat.st_rdev])
391 AC_CHECK_TYPE([ino_t], [unsigned])
394 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
395 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
396 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
397 if test x"$rsync_cv_errno" = x"yes"; then
398 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
401 # The following test taken from the cvs sources
402 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
403 # These need checks to be before checks for any other functions that
404 # might be in the same libraries.
405 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
406 # libsocket.so which has a bad implementation of gethostbyname (it
407 # only looks in /etc/hosts), so we only look for -lsocket if we need
409 AC_CHECK_FUNCS(connect)
410 if test x"$ac_cv_func_connect" = x"no"; then
413 *) AC_CHECK_LIB(nsl_s, printf) ;;
417 *) AC_CHECK_LIB(nsl, printf) ;;
421 *) AC_CHECK_LIB(socket, connect) ;;
425 *) AC_CHECK_LIB(inet, connect) ;;
427 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
429 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
430 test x"$ac_cv_lib_inet_connect" = x"yes"; then
431 # ac_cv_func_connect=yes
432 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
433 AC_DEFINE(HAVE_CONNECT, 1, [ ])
438 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
440 AC_CHECK_FUNCS(strcasecmp)
441 if test x"$ac_cv_func_strcasecmp" = x"no"; then
442 AC_CHECK_LIB(resolv, strcasecmp)
447 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
448 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
449 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
450 AC_CHECK_FUNCS(strlcat strlcpy mtrace)
452 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
453 AC_TRY_RUN([#include <sys/types.h>
454 #include <sys/socket.h>
457 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
459 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
460 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
461 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
464 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
465 AC_TRY_RUN([#include <fnmatch.h>
466 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
467 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
468 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
469 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
470 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
473 if test x"$with_included_popt" != x"yes"
475 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
478 AC_MSG_CHECKING([whether to use included libpopt])
479 if test x"$with_included_popt" = x"yes"
481 AC_MSG_RESULT($srcdir/popt)
482 BUILD_POPT='$(popt_OBJS)'
483 CFLAGS="$CFLAGS -I$srcdir/popt"
488 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
489 AC_TRY_RUN([#include <stdio.h>
490 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
491 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
492 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
493 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
496 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
497 AC_TRY_RUN([#include <stdio.h>
498 #include <sys/stat.h>
499 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
500 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
501 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
502 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
505 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
506 AC_TRY_RUN([#include <stdio.h>
507 #include <sys/types.h>
508 #include <sys/stat.h>
509 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
510 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
511 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
512 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
515 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
516 AC_TRY_RUN([#include <stdio.h>
517 main() { char c; c=250; exit((c > 0)?0:1); }],
518 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
519 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
520 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
523 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
524 AC_TRY_RUN([#include <sys/types.h>
526 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
527 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
528 di->d_name[0] == 0) exit(0); exit(1);} ],
529 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
530 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
531 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
534 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
535 AC_TRY_COMPILE([#include <sys/types.h>
537 [struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
538 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
539 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
540 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
543 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
545 #include <sys/time.h>
547 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
548 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
549 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
550 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
553 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
555 #include <sys/types.h>
557 void foo(const char *format, ...) {
562 va_start(ap, format);
563 len = vsnprintf(0, 0, format, ap);
565 if (len != 5) exit(1);
567 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
571 main() { foo("hello"); }
573 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
574 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
575 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
579 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
580 AC_TRY_RUN([#include <stdlib.h>
581 #include <sys/types.h>
582 #include <sys/stat.h>
586 char tpl[20]="/tmp/test.XXXXXX";
587 int fd = mkstemp(tpl);
588 if (fd == -1) exit(1);
590 if (fstat(fd, &st) != 0) exit(1);
591 if ((st.st_mode & 0777) != 0600) exit(1);
594 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
595 rsync_cv_HAVE_SECURE_MKSTEMP=no,
596 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
597 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
598 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
602 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
605 #include <sys/types.h>
606 #include <netinet/in.h>
607 #include <arpa/inet.h>
608 main() { struct in_addr ip; ip.s_addr = 0x12345678;
609 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
610 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
612 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
613 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
614 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
618 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
621 #include <sys/types.h>
622 #include <netinet/in.h>
623 #include <arpa/inet.h>
624 main() { struct in_addr ip;
625 if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
626 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
627 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
628 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
632 # The following test was mostly taken from the tcl/tk plus patches
634 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
636 cat > conftest.$ac_ext <<EOF
637 int main() { return 0; }
639 ${CC-cc} -c -o conftest..o conftest.$ac_ext
640 if test -f conftest..o; then
641 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
643 rsync_cv_DASHC_WORKS_WITH_DASHO=no
647 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
650 CC_SHOBJ_FLAG='-o $@'
652 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
653 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'
658 AC_SUBST(OBJ_RESTORE)
659 AC_SUBST(CC_SHOBJ_FLAG)
662 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])