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