Promoting xxhash support.
[rsync.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT([rsync],[3.2.0dev],[http://rsync.samba.org/bugzilla.html])
4
5 AC_CONFIG_MACRO_DIR([m4])
6 AC_CONFIG_SRCDIR([byteorder.h])
7 AC_CONFIG_HEADER(config.h)
8 AC_PREREQ([2.69])
9
10 AC_SUBST(RSYNC_VERSION, $PACKAGE_VERSION)
11 AC_MSG_NOTICE([Configuring rsync $PACKAGE_VERSION])
12
13 AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$PACKAGE_VERSION"], [rsync release version])
14
15 LDFLAGS=${LDFLAGS-""}
16
17 AC_CANONICAL_HOST
18
19 dnl define the directory for replacement function since AC_LIBOBJ does not
20 dnl officially support subdirs and fails with automake
21 AC_CONFIG_LIBOBJ_DIR([lib])
22
23 # We must decide this before testing the compiler.
24
25 # Please allow this to default to yes, so that your users have more
26 # chance of getting a useful stack trace if problems occur.
27
28 AC_MSG_CHECKING([whether to include debugging symbols])
29 AC_ARG_ENABLE(debug,
30         AS_HELP_STRING([--disable-debug],[disable debugging symbols and features]))
31
32 if test x"$enable_debug" = x"no"; then
33     AC_MSG_RESULT(no)
34     ac_cv_prog_cc_g=no
35 else
36     AC_MSG_RESULT([yes])
37     dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
38     # leave ac_cv_prog_cc_g alone; AC_PROG_CC will try to include -g if it can
39 fi
40
41 dnl Checks for programs.
42 AC_PROG_CC
43 AC_PROG_CPP
44 AC_PROG_CXX
45 AC_PROG_EGREP
46 AC_PROG_INSTALL
47 AC_PROG_MKDIR_P
48 AC_PROG_CC_STDC
49 AC_SUBST(SHELL)
50 AC_PATH_PROG([PERL], [perl])
51
52 AC_DEFINE([_GNU_SOURCE], 1,
53           [Define _GNU_SOURCE so that we get all necessary prototypes])
54
55 if test x"$ac_cv_prog_cc_stdc" = x"no"; then
56         AC_MSG_WARN([rsync requires an ANSI C compiler and you do not seem to have one])
57 fi
58
59 AC_ARG_ENABLE(profile,
60         AS_HELP_STRING([--enable-profile],[turn on CPU profiling]))
61 if test x"$enable_profile" = x"yes"; then
62         CFLAGS="$CFLAGS -pg"
63 fi
64
65
66 # Specifically, this turns on panic_action handling.
67 AC_ARG_ENABLE(maintainer-mode,
68         AS_HELP_STRING([--enable-maintainer-mode],[turn on extra debug features]))
69 if test x"$enable_maintainer_mode" = x"yes"; then
70         CFLAGS="$CFLAGS -DMAINTAINER_MODE"
71 fi
72
73
74 # This is needed for our included version of popt.  Kind of silly, but
75 # I don't want our version too far out of sync.
76 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
77
78 # If GCC, turn on warnings.
79 if test x"$GCC" = x"yes"; then
80         CFLAGS="$CFLAGS -Wall -W"
81 fi
82
83 AC_ARG_WITH(included-popt,
84         AS_HELP_STRING([--with-included-popt],[use bundled popt library, not from system]))
85
86 AC_ARG_WITH(included-zlib,
87         AS_HELP_STRING([--with-included-zlib],[use bundled zlib library, not from system]))
88
89 AC_ARG_WITH(protected-args,
90         AS_HELP_STRING([--with-protected-args],[make --protected-args option the default]))
91 if test x"$with_protected_args" = x"yes"; then
92         AC_DEFINE_UNQUOTED(RSYNC_USE_PROTECTED_ARGS, 1, [Define to 1 if --protected-args should be the default])
93 fi
94
95 AC_ARG_WITH(rsync-path,
96         AS_HELP_STRING([--with-rsync-path=PATH],[set default --rsync-path to PATH (default: rsync)]),
97         [ RSYNC_PATH="$with_rsync_path" ],
98         [ RSYNC_PATH="rsync" ])
99
100 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
101
102 AC_ARG_WITH(rsyncd-conf,
103         AS_HELP_STRING([--with-rsyncd-conf=PATH],[set configuration file for rsync server to PATH (default: /etc/rsyncd.conf)]),
104         [ if test ! -z "$with_rsyncd_conf" ; then
105                 case $with_rsyncd_conf in
106                         yes|no)
107                                 RSYNCD_SYSCONF="/etc/rsyncd.conf"
108                                 ;;
109                         /*)
110                                 RSYNCD_SYSCONF="$with_rsyncd_conf"
111                                 ;;
112                         *)
113                                 AC_MSG_ERROR(You must specify an absolute path to --with-rsyncd-conf=PATH)
114                                 ;;
115                 esac
116         else
117                 RSYNCD_SYSCONF="/etc/rsyncd.conf"
118         fi ],
119         [ RSYNCD_SYSCONF="/etc/rsyncd.conf" ])
120
121 AC_DEFINE_UNQUOTED(RSYNCD_SYSCONF, "$RSYNCD_SYSCONF", [location of configuration file for rsync server])
122
123 AC_ARG_WITH(rsh,
124         AS_HELP_STRING([--with-rsh=CMD],[set remote shell command to CMD (default: ssh)]))
125
126 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
127 if test x$HAVE_REMSH = x1; then
128         AC_DEFINE(HAVE_REMSH, 1, [Define to 1 if remote shell is remsh, not rsh])
129 fi
130
131 if test x"$with_rsh" != x; then
132         RSYNC_RSH="$with_rsh"
133 else
134         RSYNC_RSH="ssh"
135 fi
136 AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
137
138 AC_CHECK_PROG(HAVE_YODL2MAN, yodl2man, 1, 0)
139 if test x$HAVE_YODL2MAN = x1; then
140     MAKE_MAN=man
141 else
142     MAKE_MAN=man-copy
143 fi
144
145 # Some programs on solaris are only found in /usr/xpg4/bin (or work better than others versions).
146 AC_PATH_PROG(SHELL_PATH, sh, /bin/sh, [/usr/xpg4/bin$PATH_SEPARATOR$PATH])
147 AC_PATH_PROG(FAKEROOT_PATH, fakeroot, /usr/bin/fakeroot, [/usr/xpg4/bin$PATH_SEPARATOR$PATH])
148
149 AC_ARG_WITH(nobody-group,
150     AS_HELP_STRING([--with-nobody-group=GROUP],[set the default unprivileged group (default nobody or nogroup)]),
151     [ NOBODY_GROUP="$with_nobody_group" ])
152
153 if test x"$with_nobody_group" = x; then
154     AC_MSG_CHECKING([the group for user "nobody"])
155     if grep '^nobody:' /etc/group >/dev/null 2>&1; then
156         NOBODY_GROUP=nobody
157     elif grep '^nogroup:' /etc/group >/dev/null 2>&1; then
158         NOBODY_GROUP=nogroup
159     else
160         NOBODY_GROUP=nobody # test for others?
161     fi
162     AC_MSG_RESULT($NOBODY_GROUP)
163 fi
164
165 AC_DEFINE_UNQUOTED(NOBODY_USER, "nobody", [unprivileged user--e.g. nobody])
166 AC_DEFINE_UNQUOTED(NOBODY_GROUP, "$NOBODY_GROUP", [unprivileged group for unprivileged user])
167
168 # SIMD optimizations
169 SIMD=
170
171 AC_MSG_CHECKING([whether to enable SIMD optimizations])
172 AC_ARG_ENABLE(simd,
173     AS_HELP_STRING([--enable-simd],[enable SIMD optimizations]))
174
175 if test x"$enable_simd" = x"yes"; then
176     # For x86-64 SIMD, g++ is also required
177     if test x"$build_cpu" = x"x86_64" && test x"$CXX" = x"g++"; then
178         SIMD="$SIMD x86_64"
179     fi
180 fi
181
182 if test x"$SIMD" != x""; then
183     SIMD=`echo "$SIMD" | sed -e 's/^ *//'`
184     AC_MSG_RESULT([yes ($SIMD)])
185         AC_DEFINE(HAVE_SIMD, 1, [Define to 1 to enable SIMD optimizations])
186     SIMD=`echo "$SIMD" | sed -e 's/[[^ ]]\+/$(SIMD_&)/g'`
187 else
188     AC_MSG_RESULT(no)
189 fi
190
191 AC_SUBST(SIMD)
192
193 # We only use g++ for its target attribute dispatching, disable unneeded bulky features
194 if test x"$CXXOBJ" != x""; then
195     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-rtti"
196 fi
197
198 # arrgh. libc in some old debian version screwed up the largefile
199 # stuff, getting byte range locking wrong
200 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
201 AC_RUN_IFELSE([AC_LANG_SOURCE([[
202 #define _FILE_OFFSET_BITS 64
203 #include <stdio.h>
204 #include <fcntl.h>
205 #include <sys/types.h>
206 #include <sys/wait.h>
207 #if HAVE_UNISTD_H
208 #include <unistd.h>
209 #endif
210
211 int main(void)
212 {
213         struct flock lock;
214         int status;
215         char tpl[32] = "/tmp/locktest.XXXXXX";
216         int fd = mkstemp(tpl);
217         if (fd < 0) {
218                 strcpy(tpl, "conftest.dat");
219                 fd = open(tpl, O_CREAT|O_RDWR, 0600);
220         }
221
222         lock.l_type = F_WRLCK;
223         lock.l_whence = SEEK_SET;
224         lock.l_start = 0;
225         lock.l_len = 1;
226         lock.l_pid = 0;
227         fcntl(fd,F_SETLK,&lock);
228         if (fork() == 0) {
229                 lock.l_start = 1;
230                 _exit(fcntl(fd,F_SETLK,&lock) == 0);
231         }
232         wait(&status);
233         unlink(tpl);
234         return WEXITSTATUS(status);
235 }
236 ]])],[rsync_cv_HAVE_BROKEN_LARGEFILE=yes],[rsync_cv_HAVE_BROKEN_LARGEFILE=no],[rsync_cv_HAVE_BROKEN_LARGEFILE=cross])])
237 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
238    AC_SYS_LARGEFILE
239 fi
240
241 ipv6type=unknown
242 ipv6lib=none
243 ipv6trylibc=yes
244
245 AC_ARG_ENABLE(ipv6,
246         AS_HELP_STRING([--disable-ipv6],[do not even try to use IPv6]))
247 if test x"$enable_ipv6" != x"no"; then
248         AC_MSG_CHECKING([ipv6 stack type])
249         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta cygwin; do
250                 case $i in
251                 inria)
252                         # http://www.kame.net/
253                         AC_EGREP_CPP(yes, [
254 #include <netinet/in.h>
255 #ifdef IPV6_INRIA_VERSION
256 yes
257 #endif],
258                                 [ipv6type=$i;
259                                 AC_DEFINE(INET6, 1, [true if you have IPv6])
260                                 ])
261                         ;;
262                 kame)
263                         # http://www.kame.net/
264                         AC_EGREP_CPP(yes, [
265 #include <netinet/in.h>
266 #ifdef __KAME__
267 yes
268 #endif],
269                                 [ipv6type=$i;
270                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
271                         ;;
272                 linux-glibc)
273                         # http://www.v6.linux.or.jp/
274                         AC_EGREP_CPP(yes, [
275 #include <features.h>
276 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
277 yes
278 #endif],
279                                 [ipv6type=$i;
280 AC_DEFINE(INET6, 1, [true if you have IPv6])])
281                         ;;
282                 linux-inet6)
283                         # http://www.v6.linux.or.jp/
284                         if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
285                                 ipv6type=$i
286                                 ipv6lib=inet6
287                                 ipv6libdir=/usr/inet6/lib
288                                 ipv6trylibc=yes;
289                                 AC_DEFINE(INET6, 1, [true if you have IPv6])
290                                 CFLAGS="-I/usr/inet6/include $CFLAGS"
291                         fi
292                         ;;
293                 solaris)
294                         # http://www.sun.com
295                         AC_EGREP_CPP(yes, [
296 #include <netinet/ip6.h>
297 #ifdef __sun
298 yes
299 #endif],
300                                 [ipv6type=$i;
301                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
302                         ;;
303                 toshiba)
304                         AC_EGREP_CPP(yes, [
305 #include <sys/param.h>
306 #ifdef _TOSHIBA_INET6
307 yes
308 #endif],
309                                 [ipv6type=$i;
310                                 ipv6lib=inet6;
311                                 ipv6libdir=/usr/local/v6/lib;
312                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
313                         ;;
314                 v6d)
315                         AC_EGREP_CPP(yes, [
316 #include </usr/local/v6/include/sys/v6config.h>
317 #ifdef __V6D__
318 yes
319 #endif],
320                                 [ipv6type=$i;
321                                 ipv6lib=v6;
322                                 ipv6libdir=/usr/local/v6/lib;
323                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
324                         ;;
325                 zeta)
326                         AC_EGREP_CPP(yes, [
327 #include <sys/param.h>
328 #ifdef _ZETA_MINAMI_INET6
329 yes
330 #endif],
331                                 [ipv6type=$i;
332                                 ipv6lib=inet6;
333                                 ipv6libdir=/usr/local/v6/lib;
334                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
335                         ;;
336                 cygwin)
337                         AC_EGREP_CPP(yes, [
338 #include <netinet/in.h>
339 #ifdef _CYGWIN_IN6_H
340 yes
341 #endif],
342                                 [ipv6type=$i;
343                                 AC_DEFINE(INET6, 1, [true if you have IPv6])])
344                         ;;
345                 esac
346                 if test "$ipv6type" != "unknown"; then
347                         break
348                 fi
349         done
350         AC_MSG_RESULT($ipv6type)
351
352         AC_SEARCH_LIBS(getaddrinfo, inet6)
353 fi
354
355 dnl Do you want to disable use of locale functions
356 AC_ARG_ENABLE([locale],
357         AS_HELP_STRING([--disable-locale],[disable locale features]))
358 AH_TEMPLATE([CONFIG_LOCALE],
359 [Undefine if you do not want locale features.  By default this is defined.])
360 if test x"$enable_locale" != x"no"; then
361         AC_DEFINE(CONFIG_LOCALE)
362 fi
363
364 AC_MSG_CHECKING([whether to call shutdown on all sockets])
365 case $host_os in
366         *cygwin* ) AC_MSG_RESULT(yes)
367                    AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1,
368                             [Define to 1 if sockets need to be shutdown])
369                    ;;
370                * ) AC_MSG_RESULT(no);;
371 esac
372
373 AC_C_BIGENDIAN
374 AC_HEADER_DIRENT
375 AC_HEADER_TIME
376 AC_HEADER_SYS_WAIT
377 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
378     unistd.h utime.h grp.h compat.h sys/param.h ctype.h sys/wait.h \
379     sys/ioctl.h sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h \
380     sys/un.h sys/attr.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
381     netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h \
382     sys/acl.h acl/libacl.h attr/xattr.h sys/xattr.h sys/extattr.h \
383     popt.h popt/popt.h linux/falloc.h netinet/in_systm.h netinet/ip.h \
384     zlib.h xxhash.h)
385 AC_HEADER_MAJOR_FIXED
386
387 dnl Do you want to disable use of xxhash checksums
388 AC_ARG_ENABLE([xxhash],
389         AS_HELP_STRING([--disable-xxhash],[disable xxhash checksums]))
390 AH_TEMPLATE([SUPPORT_XXHASH],
391 [Undefine if you do not want xxhash checksums.  By default this is defined.])
392 if test x"$enable_xxhash" != x"no"; then
393     if test x"$ac_cv_header_xxhash_h" = x"yes"; then
394         AC_SEARCH_LIBS(XXH64_createState, xxhash)
395         AC_DEFINE(SUPPORT_XXHASH)
396     fi
397 fi
398
399 AC_CACHE_CHECK([if makedev takes 3 args],rsync_cv_MAKEDEV_TAKES_3_ARGS,[
400 AC_RUN_IFELSE([AC_LANG_SOURCE([[
401 #include <sys/types.h>
402 #ifdef MAJOR_IN_MKDEV
403 #include <sys/mkdev.h>
404 # if !defined makedev && (defined mkdev || defined _WIN32 || defined __WIN32__)
405 #  define makedev mkdev
406 # endif
407 #elif defined MAJOR_IN_SYSMACROS
408 #include <sys/sysmacros.h>
409 #endif
410
411 int main(void)
412 {
413         dev_t dev = makedev(0, 5, 7);
414         if (major(dev) != 5 || minor(dev) != 7)
415                 return 1;
416         return 0;
417 }
418 ]])],[rsync_cv_MAKEDEV_TAKES_3_ARGS=yes],[rsync_cv_MAKEDEV_TAKES_3_ARGS=no],[rsync_cv_MAKEDEV_TAKES_3_ARGS=no])])
419 if test x"$rsync_cv_MAKEDEV_TAKES_3_ARGS" = x"yes"; then
420    AC_DEFINE(MAKEDEV_TAKES_3_ARGS, 1, [Define to 1 if makedev() takes 3 args])
421 fi
422
423 AC_CHECK_SIZEOF(int)
424 AC_CHECK_SIZEOF(long)
425 AC_CHECK_SIZEOF(long long)
426 AC_CHECK_SIZEOF(short)
427 AC_CHECK_SIZEOF(int16_t)
428 AC_CHECK_SIZEOF(uint16_t)
429 AC_CHECK_SIZEOF(int32_t)
430 AC_CHECK_SIZEOF(uint32_t)
431 AC_CHECK_SIZEOF(int64_t)
432 AC_CHECK_SIZEOF(off_t)
433 AC_CHECK_SIZEOF(off64_t)
434 AC_CHECK_SIZEOF(time_t)
435 AC_CHECK_SIZEOF(char*)
436
437 AC_C_INLINE
438
439 AC_TYPE_LONG_DOUBLE_WIDER
440 ac_cv_c_long_double=$ac_cv_type_long_double_wider
441 if test $ac_cv_c_long_double = yes; then
442   AC_DEFINE([HAVE_LONG_DOUBLE],[1],[Define to 1 if the type `long double' works and has more range or precision than `double'.])
443 fi
444
445 AC_TYPE_UID_T
446 AC_CHECK_TYPES([mode_t,off_t,size_t,pid_t,id_t])
447 AC_TYPE_GETGROUPS
448 AC_CHECK_MEMBERS([struct stat.st_rdev,
449                   struct stat.st_mtimensec,
450                   struct stat.st_mtimespec.tv_nsec,
451                   struct stat.st_mtim.tv_nsec],,,[
452 #ifdef HAVE_SYS_TYPES_H
453 #include <sys/types.h>
454 #endif
455 #ifdef HAVE_SYS_STAT_H
456 #include <sys/stat.h>
457 #endif
458 #ifdef HAVE_UNISTD_H
459 #include <unistd.h>
460 #endif])
461
462 TYPE_SOCKLEN_T
463
464 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
465     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[int i = errno]])],[rsync_cv_errno=yes],[rsync_cv_have_errno_decl=no])])
466 if test x"$rsync_cv_errno" = x"yes"; then
467    AC_DEFINE(HAVE_ERRNO_DECL, 1, [Define to 1 if errno is declared in errno.h])
468 fi
469
470 # The following test taken from the cvs sources
471 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
472 # These need checks to be before checks for any other functions that
473 #    might be in the same libraries.
474 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
475 # libsocket.so which has a bad implementation of gethostbyname (it
476 # only looks in /etc/hosts), so we only look for -lsocket if we need
477 # it.
478 AC_CHECK_FUNCS(connect)
479 if test x"$ac_cv_func_connect" = x"no"; then
480     case "$LIBS" in
481     *-lnsl*) ;;
482     *) AC_CHECK_LIB(nsl_s, printf) ;;
483     esac
484     case "$LIBS" in
485     *-lnsl*) ;;
486     *) AC_CHECK_LIB(nsl, printf) ;;
487     esac
488     case "$LIBS" in
489     *-lsocket*) ;;
490     *) AC_CHECK_LIB(socket, connect) ;;
491     esac
492     case "$LIBS" in
493     *-linet*) ;;
494     *) AC_CHECK_LIB(inet, connect) ;;
495     esac
496     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
497     dnl has been cached.
498     if test x"$ac_cv_lib_socket_connect" = x"yes" ||
499        test x"$ac_cv_lib_inet_connect" = x"yes"; then
500         # ac_cv_func_connect=yes
501         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
502         AC_DEFINE(HAVE_CONNECT, 1, [Define to 1 if you have the "connect" function])
503     fi
504 fi
505
506 AC_SEARCH_LIBS(inet_ntop, resolv)
507
508 # For OS X, Solaris, HP-UX, etc.: figure out if -liconv is needed.  We'll
509 # accept either iconv_open or libiconv_open, since some include files map
510 # the former to the latter.
511 AC_SEARCH_LIBS(iconv_open, iconv)
512 AC_SEARCH_LIBS(libiconv_open, iconv)
513
514 AC_MSG_CHECKING([for iconv declaration])
515 AC_CACHE_VAL(am_cv_proto_iconv, [
516     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
517 #include <stdlib.h>
518 #include <iconv.h>
519 extern
520 #ifdef __cplusplus
521 "C"
522 #endif
523 #if defined(__STDC__) || defined(__cplusplus)
524 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
525 #else
526 size_t iconv();
527 #endif
528 ]], [[]])],[am_cv_proto_iconv_arg1=""],[am_cv_proto_iconv_arg1="const"])
529       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
530     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
531 AC_MSG_RESULT([$]{ac_t:-
532          }[$]am_cv_proto_iconv)
533 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
534                    [Define as const if the declaration of iconv() needs const.])
535
536 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
537
538 AC_REPLACE_FUNCS([inet_ntop inet_pton])
539
540 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
541 AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/types.h>
542 #include <sys/socket.h>])
543
544 # Irix 6.5 has getaddrinfo but not the corresponding defines, so use
545 #   builtin getaddrinfo if one of the defines don't exist
546 AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
547                rsync_cv_HAVE_GETADDR_DEFINES,[
548                         AC_EGREP_CPP(yes, [
549                         #include <sys/types.h>
550                         #include <sys/socket.h>
551                         #include <netdb.h>
552                         #ifdef AI_PASSIVE
553                         yes
554                         #endif],
555                         rsync_cv_HAVE_GETADDR_DEFINES=yes,
556                         rsync_cv_HAVE_GETADDR_DEFINES=no)])
557 AS_IF([test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes" -a x"$ac_cv_type_struct_addrinfo" = x"yes"],[
558         # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
559         # something else so we must include <netdb.h> to get the
560         # redefinition.
561         AC_CHECK_FUNCS(getaddrinfo, ,
562                 [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
563                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
564                 #include <sys/socket.h>
565                 #include <netdb.h>]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],[AC_MSG_RESULT([yes])
566                         AC_DEFINE(HAVE_GETADDRINFO, 1,
567                                 [Define to 1 if you have the "getaddrinfo" function and required types.])],[AC_MSG_RESULT([no])
568                         AC_LIBOBJ([getaddrinfo])])])
569     ],[AC_LIBOBJ([getaddrinfo])])
570
571 AC_CHECK_MEMBER([struct sockaddr.sa_len],
572                 [ AC_DEFINE(HAVE_SOCKADDR_LEN, 1, [Do we have sockaddr.sa_len?]) ],
573                 [],
574                 [
575 #include <sys/types.h>
576 #include <sys/socket.h>
577 ])
578
579 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
580                 [ AC_DEFINE(HAVE_SOCKADDR_IN_LEN, 1, [Do we have sockaddr_in.sin_len?]) ],
581                 [],
582                 [
583 #include <sys/types.h>
584 #include <sys/socket.h>
585 #include <netinet/in.h>
586 ])
587
588 AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
589                 [ AC_DEFINE(HAVE_SOCKADDR_UN_LEN, 1, [Do we have sockaddr_un.sun_len?]) ],
590                 [],
591                 [
592 #include <sys/types.h>
593 #include <sys/socket.h>
594 #include <netinet/in.h>
595 ])
596
597 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
598                 [ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID, 1, [Do we have sockaddr_in6.sin6_scope_id?]) ],
599                 [],
600                 [
601 #include <sys/types.h>
602 #include <sys/socket.h>
603 #include <netinet/in.h>
604 ])
605
606 AC_HAVE_TYPE([struct stat64], [#include <stdio.h>
607 #if HAVE_SYS_TYPES_H
608 # include <sys/types.h>
609 #endif
610 #if HAVE_SYS_STAT_H
611 # include <sys/stat.h>
612 #endif
613 #if STDC_HEADERS
614 # include <stdlib.h>
615 # include <stddef.h>
616 #else
617 # if HAVE_STDLIB_H
618 #  include <stdlib.h>
619 # endif
620 #endif
621 ])
622
623 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
624 #
625 AC_CHECK_FUNCS(strcasecmp)
626 if test x"$ac_cv_func_strcasecmp" = x"no"; then
627     AC_CHECK_LIB(resolv, strcasecmp)
628 fi
629
630 AC_CHECK_FUNCS(aclsort)
631 if test x"$ac_cv_func_aclsort" = x"no"; then
632     AC_CHECK_LIB(sec, aclsort)
633 fi
634
635 dnl At the moment we don't test for a broken memcmp(), because all we
636 dnl need to do is test for equality, not comparison, and it seems that
637 dnl every platform has a memcmp that can do at least that.
638 dnl AC_FUNC_MEMCMP
639
640 AC_FUNC_UTIME_NULL
641 AC_FUNC_ALLOCA
642 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
643     fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
644     chflags getattrlist \
645     memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
646     strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
647     setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
648     seteuid strerror putenv iconv_open locale_charset nl_langinfo getxattr \
649     extattr_get_link sigaction sigprocmask setattrlist getgrouplist \
650     initgroups utimensat posix_fallocate attropen setvbuf nanosleep usleep)
651
652 dnl cygwin iconv.h defines iconv_open as libiconv_open
653 if test x"$ac_cv_func_iconv_open" != x"yes"; then
654     AC_CHECK_FUNC(libiconv_open, [ac_cv_func_iconv_open=yes; AC_DEFINE(HAVE_ICONV_OPEN, 1)])
655 fi
656
657 dnl Preallocation stuff (also fallocate, posix_fallocate function tests above):
658
659 AC_CACHE_CHECK([for useable fallocate],rsync_cv_have_fallocate,[
660 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>
661 #include <sys/types.h>]], [[fallocate(0, 0, 0, 0);]])],[rsync_cv_have_fallocate=yes],[rsync_cv_have_fallocate=no])])
662 if test x"$rsync_cv_have_fallocate" = x"yes"; then
663     AC_DEFINE(HAVE_FALLOCATE, 1, [Define to 1 if you have the fallocate function and it compiles and links without error])
664 fi
665
666 AC_MSG_CHECKING([for FALLOC_FL_PUNCH_HOLE])
667 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
668         #define _GNU_SOURCE 1
669         #include <linux/falloc.h>
670         #ifndef FALLOC_FL_PUNCH_HOLE
671         #error FALLOC_FL_PUNCH_HOLE is missing
672         #endif
673     ]])], [
674         AC_MSG_RESULT([yes])
675         AC_DEFINE([HAVE_FALLOC_FL_PUNCH_HOLE], [1], [Define if FALLOC_FL_PUNCH_HOLE is available.])
676     ], [
677         AC_MSG_RESULT([no])
678     ]
679 )
680
681 AC_MSG_CHECKING([for FALLOC_FL_ZERO_RANGE])
682 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
683         #define _GNU_SOURCE 1
684         #include <linux/falloc.h>
685         #ifndef FALLOC_FL_ZERO_RANGE
686         #error FALLOC_FL_ZERO_RANGE is missing
687         #endif
688     ]])], [
689         AC_MSG_RESULT([yes])
690         AC_DEFINE([HAVE_FALLOC_FL_ZERO_RANGE], [1], [Define if FALLOC_FL_ZERO_RANGE is available.])
691     ], [
692         AC_MSG_RESULT([no])
693     ]
694 )
695
696 AC_CACHE_CHECK([for SYS_fallocate],rsync_cv_have_sys_fallocate,[
697 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/syscall.h>
698 #include <unistd.h>
699 #include <sys/types.h>]], [[syscall(SYS_fallocate, 0, 0, (loff_t)0, (loff_t)0);]])],[rsync_cv_have_sys_fallocate=yes],[rsync_cv_have_sys_fallocate=no])])
700 if test x"$rsync_cv_have_sys_fallocate" = x"yes"; then
701     AC_DEFINE(HAVE_SYS_FALLOCATE, 1, [Define to 1 if you have the SYS_fallocate syscall number])
702 fi
703
704 if test x"$ac_cv_func_posix_fallocate" = x"yes"; then
705     AC_MSG_CHECKING([whether posix_fallocate is efficient])
706     case $host_os in
707     *cygwin*)
708         AC_MSG_RESULT(yes)
709         AC_DEFINE(HAVE_EFFICIENT_POSIX_FALLOCATE, 1,
710                   [Define if posix_fallocate is efficient (Cygwin)])
711         ;;
712     *)
713         AC_MSG_RESULT(no)
714         ;;
715     esac
716 fi
717
718 dnl End of preallocation stuff
719
720 AC_CHECK_FUNCS(getpgrp tcgetpgrp)
721 if test $ac_cv_func_getpgrp = yes; then
722     AC_FUNC_GETPGRP
723 fi
724
725 AC_ARG_ENABLE(iconv-open,
726     AS_HELP_STRING([--disable-iconv-open],[disable all use of iconv_open() function]),
727     [], [enable_iconv_open=$ac_cv_func_iconv_open])
728
729 if test x"$enable_iconv_open" != x"no"; then
730     AC_DEFINE(USE_ICONV_OPEN, 1, [Define to 1 if you want rsync to make use of iconv_open()])
731 fi
732
733 AC_ARG_ENABLE(iconv,
734     AS_HELP_STRING([--disable-iconv],[disable rsync's --iconv option]),
735     [], [enable_iconv=$enable_iconv_open])
736 AH_TEMPLATE([ICONV_OPTION],
737 [Define if you want the --iconv option.  Specifing a value will set the
738 default iconv setting (a NULL means no --iconv processing by default).])
739 if test x"$enable_iconv" != x"no"; then
740         if test x"$enable_iconv" = x"yes"; then
741                 AC_DEFINE(ICONV_OPTION, NULL)
742         else
743                 AC_DEFINE_UNQUOTED(ICONV_OPTION, "$enable_iconv")
744         fi
745         AC_DEFINE(UTF8_CHARSET, "UTF-8", [String to pass to iconv() for the UTF-8 charset.])
746 fi
747
748 AC_CACHE_CHECK([whether chown() modifies symlinks],rsync_cv_chown_modifies_symlink,[
749   AC_RUN_IFELSE([AC_LANG_SOURCE([[
750 #if HAVE_UNISTD_H
751 # include <unistd.h>
752 #endif
753 #include <stdlib.h>
754 #include <errno.h>
755 int main(void) {
756         char const *dangling_symlink = "conftest.dangle";
757         unlink(dangling_symlink);
758         if (symlink("conftest.no-such", dangling_symlink) < 0) abort();
759         if (chown(dangling_symlink, getuid(), getgid()) < 0 && errno == ENOENT) return 1;
760         return 0;
761     }]])],[rsync_cv_chown_modifies_symlink=yes],[rsync_cv_chown_modifies_symlink=no],[rsync_cv_chown_modifies_symlink=no])])
762 if test $rsync_cv_chown_modifies_symlink = yes; then
763   AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1, [Define to 1 if chown modifies symlinks.])
764 fi
765
766 AC_CACHE_CHECK([whether link() can hard-link symlinks],rsync_cv_can_hardlink_symlink,[
767   AC_RUN_IFELSE([AC_LANG_SOURCE([[
768 #if HAVE_UNISTD_H
769 # include <unistd.h>
770 #endif
771 #include <stdlib.h>
772 #include <errno.h>
773 #define FILENAME "conftest.dangle"
774 int main(void) {
775         unlink(FILENAME);
776         if (symlink("conftest.no-such", FILENAME) < 0) abort();
777         unlink(FILENAME "2");
778         if (link(FILENAME, FILENAME "2") < 0) return 1;
779         return 0;
780     }]])],[rsync_cv_can_hardlink_symlink=yes],[rsync_cv_can_hardlink_symlink=no],[rsync_cv_can_hardlink_symlink=no])])
781 if test $rsync_cv_can_hardlink_symlink = yes; then
782   AC_DEFINE(CAN_HARDLINK_SYMLINK, 1, [Define to 1 if link() can hard-link symlinks.])
783 fi
784
785 AC_CACHE_CHECK([whether link() can hard-link special files],rsync_cv_can_hardlink_special,[
786   AC_RUN_IFELSE([AC_LANG_SOURCE([[
787 #if HAVE_UNISTD_H
788 # include <unistd.h>
789 #endif
790 #ifdef HAVE_SYS_STAT_H
791 #include <sys/stat.h>
792 #endif
793 #include <stdlib.h>
794 #include <errno.h>
795 #define FILENAME "conftest.fifi"
796 int main(void) {
797         unlink(FILENAME);
798         if (mkfifo(FILENAME, 0777) < 0) abort();
799         unlink(FILENAME "2");
800         if (link(FILENAME, FILENAME "2") < 0) return 1;
801         return 0;
802     }]])],[rsync_cv_can_hardlink_special=yes],[rsync_cv_can_hardlink_special=no],[rsync_cv_can_hardlink_special=no])])
803 if test $rsync_cv_can_hardlink_special = yes; then
804     AC_DEFINE(CAN_HARDLINK_SPECIAL, 1, [Define to 1 if link() can hard-link special files.])
805 fi
806
807 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
808 AC_RUN_IFELSE([AC_LANG_SOURCE([[
809 #include <sys/types.h>
810 #include <sys/socket.h>
811
812 int main(void) {
813        int fd[2];
814        return (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1;
815 }]])],[rsync_cv_HAVE_SOCKETPAIR=yes],[rsync_cv_HAVE_SOCKETPAIR=no],[rsync_cv_HAVE_SOCKETPAIR=cross])])
816 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
817     AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define to 1 if you have the "socketpair" function])
818 fi
819
820 AC_REPLACE_FUNCS([getpass])
821
822 if test x"$with_included_popt" != x"yes"; then
823     AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
824 fi
825 if test x"$ac_cv_header_popt_popt_h" = x"yes"; then
826     # If the system has /usr/include/popt/popt.h, we enable the
827     # included popt because an attempt to "#include <popt/popt.h>"
828     # would use our included header file anyway (due to -I.), and
829     # might conflict with the system popt.
830     with_included_popt=yes
831 elif test x"$ac_cv_header_popt_h" != x"yes"; then
832     with_included_popt=yes
833 fi
834
835 AC_MSG_CHECKING([whether to use included libpopt])
836 if test x"$with_included_popt" = x"yes"; then
837     AC_MSG_RESULT($srcdir/popt)
838     BUILD_POPT='$(popt_OBJS)'
839     CFLAGS="-I$srcdir/popt $CFLAGS"
840     if test x"$ALLOCA" != x
841     then
842         # this can be removed when/if we add an included alloca.c;
843         #  see autoconf documentation on AC_FUNC_ALLOCA
844         AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
845     fi
846 else
847     AC_MSG_RESULT(no)
848 fi
849
850 # We default to using our zlib unless --with-included-zlib=no is given.
851 if test x"$with_included_zlib" != x"no"; then
852     with_included_zlib=yes
853 elif test x"$ac_cv_header_zlib_h" != x"yes"; then
854     with_included_zlib=yes
855 fi
856 if test x"$with_included_zlib" != x"yes"; then
857     AC_CHECK_LIB(z, deflateParams, , [with_included_zlib=yes])
858 fi
859
860 AC_MSG_CHECKING([whether to use included zlib])
861 if test x"$with_included_zlib" = x"yes"; then
862     AC_MSG_RESULT($srcdir/zlib)
863     BUILD_ZLIB='$(zlib_OBJS)'
864     CFLAGS="-I$srcdir/zlib $CFLAGS"
865 else
866     AC_DEFINE(EXTERNAL_ZLIB, 1, [Define to 1 if using external zlib])
867     AC_MSG_RESULT(no)
868 fi
869
870 AC_CACHE_CHECK([for unsigned char],rsync_cv_SIGNED_CHAR_OK,[
871 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char *s = ""]])],[rsync_cv_SIGNED_CHAR_OK=yes],[rsync_cv_SIGNED_CHAR_OK=no])])
872 if test x"$rsync_cv_SIGNED_CHAR_OK" = x"yes"; then
873     AC_DEFINE(SIGNED_CHAR_OK, 1, [Define to 1 if "signed char" is a valid type])
874 fi
875
876 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
877 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
878 #include <dirent.h>
879 int main(void) { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
880 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
881 di->d_name[0] == 0) return 0; return 1;} ]])],[rsync_cv_HAVE_BROKEN_READDIR=yes],[rsync_cv_HAVE_BROKEN_READDIR=no],[rsync_cv_HAVE_BROKEN_READDIR=cross])])
882 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
883     AC_DEFINE(HAVE_BROKEN_READDIR, 1, [Define to 1 if readdir() is broken])
884 fi
885
886 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_STRUCT_UTIMBUF,[
887 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
888 #include <utime.h>]], [[struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);]])],[rsync_cv_HAVE_STRUCT_UTIMBUF=yes],[rsync_cv_HAVE_STRUCT_UTIMBUF=no])])
889 if test x"$rsync_cv_HAVE_STRUCT_UTIMBUF" = x"yes"; then
890     AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1, [Define to 1 if you have the "struct utimbuf" type])
891 fi
892
893 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
894 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>
895 #include <unistd.h>]], [[struct timeval tv; return gettimeofday(&tv, NULL);]])],[rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes],[rsync_cv_HAVE_GETTIMEOFDAY_TZ=no])])
896 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" != x"no"; then
897     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [Define to 1 if gettimeofday() takes a time-zone arg])
898 fi
899
900 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
901 AC_RUN_IFELSE([AC_LANG_SOURCE([[
902 #include <sys/types.h>
903 #include <stdarg.h>
904 #include <stdio.h>
905 #include <stdlib.h>
906 #include <string.h>
907 void foo(const char *format, ...) {
908        va_list ap;
909        int len;
910        char buf[5];
911
912        va_start(ap, format);
913        len = vsnprintf(0, 0, format, ap);
914        va_end(ap);
915        if (len != 5) exit(1);
916
917        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
918 }
919 int main(void) { foo("hello"); return 0; }
920 ]])],[rsync_cv_HAVE_C99_VSNPRINTF=yes],[rsync_cv_HAVE_C99_VSNPRINTF=no],[rsync_cv_HAVE_C99_VSNPRINTF=cross])])
921 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
922     AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [Define to 1 if vsprintf has a C99-compatible return value])
923 fi
924
925
926 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
927 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
928 #include <sys/types.h>
929 #include <sys/stat.h>
930 #include <unistd.h>
931 int main(void) {
932   struct stat st;
933   char tpl[20]="/tmp/test.XXXXXX";
934   int fd = mkstemp(tpl);
935   if (fd == -1) return 1;
936   unlink(tpl);
937   if (fstat(fd, &st) != 0) return 1;
938   if ((st.st_mode & 0777) != 0600) return 1;
939   return 0;
940 }]])],[rsync_cv_HAVE_SECURE_MKSTEMP=yes],[rsync_cv_HAVE_SECURE_MKSTEMP=no],[rsync_cv_HAVE_SECURE_MKSTEMP=cross])])
941 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
942     case $host_os in
943     hpux*)
944         dnl HP-UX has a broken mkstemp() implementation they refuse to fix,
945         dnl so we noisily skip using it.  See HP change request JAGaf34426
946         dnl for details. (sbonds)
947         AC_MSG_WARN(Skipping broken HP-UX mkstemp() -- using mktemp() instead)
948         ;;
949     *)
950         AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [Define to 1 if mkstemp() is available and works right])
951         ;;
952     esac
953 fi
954
955
956 AC_CACHE_CHECK([if mknod creates FIFOs],rsync_cv_MKNOD_CREATES_FIFOS,[
957 AC_RUN_IFELSE([AC_LANG_SOURCE([[
958 #include <stdio.h>
959 #include <sys/stat.h>
960 #include <errno.h>
961 #if HAVE_UNISTD_H
962 # include <unistd.h>
963 #endif
964 int main(void) { int rc, ec; char *fn = "fifo-test";
965 unlink(fn); rc = mknod(fn,S_IFIFO,0600); ec = errno; unlink(fn);
966 if (rc) {printf("(%d %d) ",rc,ec); return ec;}
967 return 0;}]])],[rsync_cv_MKNOD_CREATES_FIFOS=yes],[rsync_cv_MKNOD_CREATES_FIFOS=no],[rsync_cv_MKNOD_CREATES_FIFOS=cross])])
968 if test x"$rsync_cv_MKNOD_CREATES_FIFOS" = x"yes"; then
969     AC_DEFINE(MKNOD_CREATES_FIFOS, 1, [Define to 1 if mknod() can create FIFOs.])
970 fi
971
972 AC_CACHE_CHECK([if mknod creates sockets],rsync_cv_MKNOD_CREATES_SOCKETS,[
973 AC_RUN_IFELSE([AC_LANG_SOURCE([[
974 #include <stdio.h>
975 #include <sys/stat.h>
976 #include <errno.h>
977 #if HAVE_UNISTD_H
978 # include <unistd.h>
979 #endif
980 int main(void) { int rc, ec; char *fn = "sock-test";
981 unlink(fn); rc = mknod(fn,S_IFSOCK,0600); ec = errno; unlink(fn);
982 if (rc) {printf("(%d %d) ",rc,ec); return ec;}
983 return 0;}]])],[rsync_cv_MKNOD_CREATES_SOCKETS=yes],[rsync_cv_MKNOD_CREATES_SOCKETS=no],[rsync_cv_MKNOD_CREATES_SOCKETS=cross])])
984 if test x"$rsync_cv_MKNOD_CREATES_SOCKETS" = x"yes"; then
985     AC_DEFINE(MKNOD_CREATES_SOCKETS, 1, [Define to 1 if mknod() can create sockets.])
986 fi
987
988 #
989 # The following test was mostly taken from the tcl/tk plus patches
990 #
991 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
992 rm -rf conftest*
993 cat > conftest.$ac_ext <<EOF
994 int main(void) { return 0; }
995 EOF
996 ${CC-cc} -c -o conftest..o conftest.$ac_ext
997 if test -f conftest..o; then
998     rsync_cv_DASHC_WORKS_WITH_DASHO=yes
999 else
1000     rsync_cv_DASHC_WORKS_WITH_DASHO=no
1001 fi
1002 rm -rf conftest*
1003 ])
1004 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
1005     OBJ_SAVE="#"
1006     OBJ_RESTORE="#"
1007     CC_SHOBJ_FLAG='-o $@'
1008 else
1009     OBJ_SAVE='  @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
1010     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'
1011     CC_SHOBJ_FLAG=""
1012 fi
1013
1014 AC_SUBST(OBJ_SAVE)
1015 AC_SUBST(OBJ_RESTORE)
1016 AC_SUBST(CC_SHOBJ_FLAG)
1017 AC_SUBST(BUILD_POPT)
1018 AC_SUBST(BUILD_ZLIB)
1019 AC_SUBST(MAKE_MAN)
1020
1021 AC_CHECK_FUNCS(_acl __acl _facl __facl)
1022 #################################################
1023 # check for ACL support
1024
1025 AC_MSG_CHECKING([whether to support ACLs])
1026 AC_ARG_ENABLE(acl-support,
1027         AS_HELP_STRING([--disable-acl-support],[disable ACL support]))
1028
1029 if test x"$enable_acl_support" = x"no"; then
1030     AC_MSG_RESULT(no)
1031 else
1032     case "$host_os" in
1033     *sysv5*)
1034         AC_MSG_RESULT(Using UnixWare ACLs)
1035         AC_DEFINE(HAVE_UNIXWARE_ACLS, 1, [true if you have UnixWare ACLs])
1036         AC_DEFINE(SUPPORT_ACLS, 1, [Define to 1 to add support for ACLs])
1037         ;;
1038     solaris*)
1039         AC_MSG_RESULT(Using solaris ACLs)
1040         AC_DEFINE(HAVE_SOLARIS_ACLS, 1, [true if you have solaris ACLs])
1041         AC_DEFINE(SUPPORT_ACLS, 1)
1042         ;;
1043     *hpux*)
1044         AC_MSG_RESULT(Using HPUX ACLs)
1045         AC_DEFINE(HAVE_HPUX_ACLS, 1, [true if you have HPUX ACLs])
1046         AC_DEFINE(SUPPORT_ACLS, 1)
1047         ;;
1048     *irix*)
1049         AC_MSG_RESULT(Using IRIX ACLs)
1050         AC_DEFINE(HAVE_IRIX_ACLS, 1, [true if you have IRIX ACLs])
1051         AC_DEFINE(SUPPORT_ACLS, 1)
1052         ;;
1053     *aix*)
1054         AC_MSG_RESULT(Using AIX ACLs)
1055         AC_DEFINE(HAVE_AIX_ACLS, 1, [true if you have AIX ACLs])
1056         AC_DEFINE(SUPPORT_ACLS, 1)
1057         ;;
1058     *osf*)
1059         AC_MSG_RESULT(Using Tru64 ACLs)
1060         AC_DEFINE(HAVE_TRU64_ACLS, 1, [true if you have Tru64 ACLs])
1061         AC_DEFINE(SUPPORT_ACLS, 1)
1062         LIBS="$LIBS -lpacl"
1063         ;;
1064     darwin*)
1065         AC_MSG_RESULT(Using OS X ACLs)
1066         AC_DEFINE(HAVE_OSX_ACLS, 1, [true if you have Mac OS X ACLs])
1067         AC_DEFINE(SUPPORT_ACLS, 1)
1068         ;;
1069     *)
1070         AC_MSG_RESULT(running tests:)
1071         AC_CHECK_LIB(acl,acl_get_file)
1072         AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
1073             AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1074 #include <sys/acl.h>]], [[ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);]])],[samba_cv_HAVE_POSIX_ACLS=yes],[samba_cv_HAVE_POSIX_ACLS=no])])
1075         AC_MSG_CHECKING(ACL test results)
1076         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
1077             AC_MSG_RESULT(Using posix ACLs)
1078             AC_DEFINE(HAVE_POSIX_ACLS, 1, [true if you have posix ACLs])
1079             AC_DEFINE(SUPPORT_ACLS, 1)
1080             AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
1081                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1082 #include <sys/acl.h>]], [[ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);]])],[samba_cv_HAVE_ACL_GET_PERM_NP=yes],[samba_cv_HAVE_ACL_GET_PERM_NP=no])])
1083             if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
1084                 AC_DEFINE(HAVE_ACL_GET_PERM_NP, 1, [true if you have acl_get_perm_np])
1085             fi
1086         else
1087             if test x"$enable_acl_support" = x"yes"; then
1088                 AC_MSG_ERROR(Failed to find ACL support)
1089             else
1090                 AC_MSG_RESULT(No ACL support found)
1091             fi
1092         fi
1093         ;;
1094     esac
1095 fi
1096
1097 #################################################
1098 # check for extended attribute support
1099 AC_MSG_CHECKING(whether to support extended attributes)
1100 AC_ARG_ENABLE(xattr-support,
1101     AS_HELP_STRING([--disable-xattr-support],[disable extended attributes]),
1102     [], [case "$ac_cv_func_getxattr$ac_cv_func_extattr_get_link$ac_cv_func_attropen" in
1103         *yes*) enable_xattr_support=maybe ;;
1104         *) enable_xattr_support=no ;;
1105         esac])
1106 AH_TEMPLATE([SUPPORT_XATTRS],
1107 [Define to 1 to add support for extended attributes])
1108 if test x"$enable_xattr_support" = x"no"; then
1109     AC_MSG_RESULT(no)
1110 else
1111     case "$host_os" in
1112     *linux*|*netbsd*)
1113         AC_MSG_RESULT(Using Linux xattrs)
1114         AC_DEFINE(HAVE_LINUX_XATTRS, 1, [True if you have Linux xattrs (or equivalent)])
1115         AC_DEFINE(SUPPORT_XATTRS, 1)
1116         AC_DEFINE(NO_SYMLINK_USER_XATTRS, 1, [True if symlinks do not support user xattrs])
1117         AC_CHECK_LIB(attr,getxattr)
1118         ;;
1119     darwin*)
1120         AC_MSG_RESULT(Using OS X xattrs)
1121         AC_DEFINE(HAVE_OSX_XATTRS, 1, [True if you have Mac OS X xattrs])
1122         AC_DEFINE(SUPPORT_XATTRS, 1)
1123         AC_DEFINE(NO_DEVICE_XATTRS, 1, [True if device files do not support xattrs])
1124         AC_DEFINE(NO_SPECIAL_XATTRS, 1, [True if special files do not support xattrs])
1125         ;;
1126     freebsd*)
1127         AC_MSG_RESULT(Using FreeBSD extattrs)
1128         AC_DEFINE(HAVE_FREEBSD_XATTRS, 1, [True if you have FreeBSD xattrs])
1129         AC_DEFINE(SUPPORT_XATTRS, 1)
1130         ;;
1131     solaris*)
1132         AC_MSG_RESULT(Using Solaris xattrs)
1133         AC_DEFINE(HAVE_SOLARIS_XATTRS, 1, [True if you have Solaris xattrs])
1134         AC_DEFINE(SUPPORT_XATTRS, 1)
1135         AC_DEFINE(NO_SYMLINK_XATTRS, 1, [True if symlinks do not support xattrs])
1136         ;;
1137     *)
1138         if test x"$enable_xattr_support" = x"yes"; then
1139             AC_MSG_ERROR(Failed to find extended attribute support)
1140         else
1141             AC_MSG_RESULT(No extended attribute support found)
1142         fi
1143         ;;
1144     esac
1145 fi
1146
1147 if test x"$enable_acl_support" = x"no" -o x"$enable_xattr_support" = x"no" -o x"$enable_iconv" = x"no"; then
1148     AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
1149     OLD_CFLAGS="$CFLAGS"
1150     CFLAGS="$CFLAGS -Wno-unused-parameter"
1151     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[printf("hello\n");]])],[rsync_warn_flag=yes],[rsync_warn_flag=no])
1152     AC_MSG_RESULT([$rsync_warn_flag])
1153     if test x"$rsync_warn_flag" = x"no"; then
1154         CFLAGS="$OLD_CFLAGS"
1155     fi
1156 fi
1157
1158 case "$CC" in
1159 ' checker'*|checker*)
1160     AC_DEFINE(FORCE_FD_ZERO_MEMSET, 1, [Used to make "checker" understand that FD_ZERO() clears memory.])
1161     ;;
1162 esac
1163
1164 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
1165 AC_OUTPUT
1166
1167 AC_MSG_RESULT()
1168 AC_MSG_RESULT([    rsync ${RSYNC_VERSION} configuration successful])
1169 AC_MSG_RESULT()
1170 if test x$HAVE_YODL2MAN != x1; then
1171     AC_MSG_RESULT([    Note that yodl2man was not found, so pre-existing manpage files will be])
1172     AC_MSG_RESULT([    used w/o change (if available) -- no .yo file changes will be used.])
1173     AC_MSG_RESULT()
1174 fi