Debian Codegraph @

configure.ac

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT([rsync],[ ],[https://rsync.samba.org/bug-tracking.html])
4
5 AC_C_BIGENDIAN
6 AC_HEADER_DIRENT
7 AC_HEADER_SYS_WAIT
8 AC_CHECK_HEADERS(poll.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
9 unistd.h utime.h compat.h sys/param.h ctype.h sys/wait.h sys/stat.h \
10 sys/ioctl.h sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h grp.h \
11 sys/un.h sys/attr.h arpa/inet.h arpa/nameser.h locale.h sys/types.h \
12 netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h mcheck.h \
13 sys/acl.h acl/libacl.h attr/xattr.h sys/xattr.h sys/extattr.h dl.h \
14 popt.h popt/popt.h linux/falloc.h netinet/in_systm.h netgroup.h \
15 zlib.h xxhash.h openssl/md4.h openssl/md5.h zstd.h lz4.h sys/file.h \
16 sys/resource.h bsd/string.h)
17 AC_CHECK_HEADERS([netinet/ip.h], [], [], [[#include <netinet/in.h>]])
18 AC_HEADER_MAJOR_FIXED
19
20 AC_CONFIG_MACRO_DIR([m4])
21 AC_CONFIG_SRCDIR([byteorder.h])
22 AC_CONFIG_HEADERS([config.h])
23 AC_PREREQ([2.69])
24
25 PACKAGE_VERSION=`sed -n 's/.*RSYNC_VERSION.*"\(.*\)".*/\1/p' <$srcdir/version.h`
26
27 AC_MSG_NOTICE([Configuring rsync $PACKAGE_VERSION])
28
29 LDFLAGS=${LDFLAGS-""}
30
31 AC_CANONICAL_HOST
32
33 dnl define the directory for replacement function since AC_LIBOBJ does not
34 dnl officially support subdirs and fails with automake
35 AC_CONFIG_LIBOBJ_DIR([lib])
36
37 # We must decide this before testing the compiler.
38
39 # Please allow this to default to yes, so that your users have more
40 # chance of getting a useful stack trace if problems occur.
41
42 AC_MSG_CHECKING([whether to include debugging symbols])
43 AC_ARG_ENABLE(debug,
44 AS_HELP_STRING([--disable-debug],[disable to omit debugging symbols and features]))
45
46 if test x"$enable_debug" = x"no"; then
47 AC_MSG_RESULT(no)
48 ac_cv_prog_cc_g=no
49 else
50 AC_MSG_RESULT([yes])
51 dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
52 # leave ac_cv_prog_cc_g alone; AC_PROG_CC will try to include -g if it can
53 fi
54
55 dnl Checks for programs.
56 AC_PROG_CC
57 AC_PROG_CPP
58 AC_PROG_CXX
59 AC_PROG_AWK
60 AC_PROG_EGREP
61 AC_PROG_INSTALL
62 AC_PROG_MKDIR_P
63 AC_SUBST(SHELL)
64 AC_PATH_PROG([PERL], [perl])
65 AC_PATH_PROG([PYTHON3], [python3])
66
67 AC_DEFINE([_GNU_SOURCE], 1,
68 [Define _GNU_SOURCE so that we get all necessary prototypes])
69
70 if test x"$ac_cv_prog_cc_stdc" = x"no"; then
71 AC_MSG_WARN([rsync requires an ANSI C compiler and you do not seem to have one])
72 fi
73
74 no_lib=''
75 err_msg=''
76 nl='
77 '
78
79 AC_ARG_ENABLE(profile,
80 AS_HELP_STRING([--enable-profile],[enable to turn on CPU profiling]))
81 if test x"$enable_profile" = x"yes"; then
82 CFLAGS="$CFLAGS -pg"
83 fi
84
85 dnl Coverage build (gcov) for `make coverage`. NOTE: --enable-profile above is
86 dnl gprof (-pg) and is NOT coverage. -O0 keeps branch coverage meaningful;
87 dnl -fprofile-update=atomic keeps the shared .gcda counters correct while the
88 dnl suite runs many rsync processes in parallel.
89 AC_ARG_ENABLE(coverage,
90 AS_HELP_STRING([--enable-coverage],[build with gcov instrumentation for `make coverage`]))
91 if test x"$enable_coverage" = x"yes"; then
92 CFLAGS="$CFLAGS --coverage -fprofile-update=atomic -O0"
93 CXXFLAGS="$CXXFLAGS --coverage -fprofile-update=atomic -O0"
94 LDFLAGS="$LDFLAGS --coverage"
95 AC_DEFINE([GCOV_COVERAGE], 1,
96 [Flush gcov counters at exit_cleanup: rsync's children exit via _exit(), which bypasses the gcov atexit handler, so without this no .gcda is written for the receiver/generator/daemon-worker processes.])
97 fi
98
99 dnl openat2(RESOLVE_BENEATH) is used on Linux 5.6+ for the secure resolver.
100 dnl --disable-openat2 forces the portable per-component O_NOFOLLOW fallback to
101 dnl run as the primary resolver on ordinary Linux, so that tier is exercised
102 dnl (and coverage-counted) without needing a pre-5.6 kernel. Behaviour-neutral
103 dnl by default (the knob only REMOVES a tier when explicitly disabled).
104 AC_ARG_ENABLE(openat2,
105 AS_HELP_STRING([--disable-openat2],[do not use Linux openat2(RESOLVE_BENEATH); force the portable resolver (for exercising the fallback tier)]))
106
107 AC_MSG_CHECKING([if md2man can create manpages])
108 if test x"$ac_cv_path_PYTHON3" = x; then
109 AC_MSG_RESULT(no - python3 not found)
110 md2man_works=no
111 else
112 md2man_out=`"$srcdir/md2man" --test "$srcdir/rsync-ssl.1.md" 2>&1`
113 if test $? = 0; then
114 AC_MSG_RESULT(yes)
115 md2man_works=yes
116 else
117 AC_MSG_RESULT(no)
118 md2man_works=no
119 echo "$md2man_out"
120 fi
121 fi
122
123 AC_MSG_CHECKING([if we require man-page building])
124 AC_ARG_ENABLE([md2man],
125 AS_HELP_STRING([--disable-md2man],[disable to omit manpage creation]))
126 if test x"$enable_md2man" != x"no"; then
127 if test -f "$srcdir/rsync.1"; then
128 AC_MSG_RESULT(optional)
129 else
130 AC_MSG_RESULT(required)
131 if test x"$md2man_works" = x"no"; then
132 err_msg="$err_msg$nl- You need python3 and either the cmarkgfm OR commonmark python3 lib in order"
133 err_msg="$err_msg$nl to build manpages based on the git source (manpages are included in the"
134 err_msg="$err_msg$nl official release tar files)."
135 no_lib="$no_lib md2man"
136 fi
137 fi
138 MAKE_MAN=man
139 else
140 AC_MSG_RESULT(no)
141 fi
142
143 # Specifically, this turns on panic_action handling.
144 AC_ARG_ENABLE(maintainer-mode,
145 AS_HELP_STRING([--enable-maintainer-mode],[enable to turn on extra debug features]))
146 if test x"$enable_maintainer_mode" = x"yes"; then
147 CFLAGS="$CFLAGS -DMAINTAINER_MODE"
148 fi
149
150 # This is needed for our included version of popt. Kind of silly, but
151 # I don't want our version too far out of sync.
152 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
153
154 # If GCC, turn on warnings.
155 if test x"$GCC" = x"yes"; then
156 CFLAGS="$CFLAGS -Wall -W"
157 fi
158
159 AC_ARG_WITH(openssl-conf,
160 AS_HELP_STRING([--with-openssl-conf=PATH],[set default OPENSSL_CONF path for rsync]))
161 case "$with_openssl_conf" in
162 *[^-/a-zA-Z0-9.,=@+_]*) AC_MSG_ERROR([Invalid path given to --with-openssl-conf]) ;;
163 /*) CFLAGS="$CFLAGS -DSET_OPENSSL_CONF=$with_openssl_conf" ;;
164 no|'') ;;
165 yes) AC_MSG_ERROR([No path given to --with-openssl-conf]) ;;
166 *) AC_MSG_ERROR([Non absolute path given to --with-openssl-conf]) ;;
167 esac
168
169 AC_ARG_WITH(rrsync,
170 AS_HELP_STRING([--with-rrsync],[also install the rrsync script and its manpage]))
171 if test x"$with_rrsync" != x"yes"; then
172 with_rrsync=no
173 else
174 MAKE_RRSYNC='rrsync'
175 MAKE_RRSYNC_1='rrsync.1'
176 GEN_RRSYNC='rrsync.1 rrsync.1.html'
177 fi
178 AC_SUBST(with_rrsync)
179
180 AC_ARG_WITH(included-popt,
181 AS_HELP_STRING([--with-included-popt],[use bundled popt library, not from system]))
182
183 AC_ARG_WITH(included-zlib,
184 AS_HELP_STRING([--with-included-zlib],[use bundled zlib library, not from system]))
185
186 AC_ARG_WITH(secluded-args,
187 AS_HELP_STRING([--with-secluded-args],[make --secluded-args option the default]))
188 if test x"$with_secluded_args" = x"yes"; then
189 AC_DEFINE_UNQUOTED(RSYNC_USE_SECLUDED_ARGS, 1, [Define to 1 if --secluded-args should be the default])
190 fi
191
192 AC_ARG_WITH(rsync-path,
193 AS_HELP_STRING([--with-rsync-path=PATH],[set default --rsync-path to PATH (default: rsync)]),
194 [ RSYNC_PATH="$with_rsync_path" ],
195 [ RSYNC_PATH="rsync" ])
196
197 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
198
199 AC_ARG_WITH(rsyncd-conf,
200 AS_HELP_STRING([--with-rsyncd-conf=PATH],[set configuration file for rsync server to PATH (default: /etc/rsyncd.conf)]),
201 [ if test ! -z "$with_rsyncd_conf" ; then
202 case $with_rsyncd_conf in
203 yes|no)
204 RSYNCD_SYSCONF="/etc/rsyncd.conf"
205 ;;
206 /*)
207 RSYNCD_SYSCONF="$with_rsyncd_conf"
208 ;;
209 *)
210 AC_MSG_ERROR(You must specify an absolute path to --with-rsyncd-conf=PATH)
211 ;;
212 esac
213 else
214 RSYNCD_SYSCONF="/etc/rsyncd.conf"
215 fi ],
216 [ RSYNCD_SYSCONF="/etc/rsyncd.conf" ])
217
218 AC_DEFINE_UNQUOTED(RSYNCD_SYSCONF, "$RSYNCD_SYSCONF", [location of configuration file for rsync server])
219
220 AC_ARG_WITH(rsh,
221 AS_HELP_STRING([--with-rsh=CMD],[set remote shell command to CMD (default: ssh)]))
222
223 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
224 if test x$HAVE_REMSH = x1; then
225 AC_DEFINE(HAVE_REMSH, 1, [Define to 1 if remote shell is remsh, not rsh])
226 fi
227
228 if test x"$with_rsh" != x; then
229 RSYNC_RSH="$with_rsh"
230 else
231 RSYNC_RSH="ssh"
232 fi
233 AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
234
235 # Some programs on solaris are only found in /usr/xpg4/bin (or work better than others versions).
236 AC_PATH_PROG(SHELL_PATH, sh, /bin/sh, [/usr/xpg4/bin$PATH_SEPARATOR$PATH])
237 AC_PATH_PROG(FAKEROOT_PATH, fakeroot, /usr/bin/fakeroot, [/usr/xpg4/bin$PATH_SEPARATOR$PATH])
238
239 AC_ARG_WITH(nobody-user,
240 AS_HELP_STRING([--with-nobody-user=USER],[set the default unprivileged user (default nobody)]),
241 [ NOBODY_USER="$with_nobody_user" ],
242 [ NOBODY_USER="nobody" ])
243
244 AC_ARG_WITH(nobody-group,
245 AS_HELP_STRING([--with-nobody-group=GROUP],[set the default unprivileged group (default nobody or nogroup)]),
246 [ NOBODY_GROUP="$with_nobody_group" ])
247
248 if test x"$with_nobody_group" = x; then
249 AC_MSG_CHECKING([the group for user "nobody"])
250 if grep '^nobody:' /etc/group >/dev/null 2>&1; then
251 NOBODY_GROUP=nobody
252 elif grep '^nogroup:' /etc/group >/dev/null 2>&1; then
253 NOBODY_GROUP=nogroup
254 else
255 NOBODY_GROUP=nobody # test for others?
256 fi
257 AC_MSG_RESULT($NOBODY_GROUP)
258 fi
259
260 AC_DEFINE_UNQUOTED(NOBODY_USER, "$NOBODY_USER", [unprivileged user--e.g. nobody])
261 AC_DEFINE_UNQUOTED(NOBODY_GROUP, "$NOBODY_GROUP", [unprivileged group for unprivileged user])
262
263 # rolling-checksum SIMD optimizations
264 ROLL_SIMD=
265
266 AC_MSG_CHECKING([whether to enable rolling-checksum SIMD optimizations])
267 AC_ARG_ENABLE(roll-simd,
268 AS_HELP_STRING([--enable-roll-simd],[enable/disable to control rolling-checksum SIMD optimizations (requires c++)]))
269
270 # Clag is crashing with -g -O2, so we'll get rid of -g for now.
271 CXXFLAGS=`echo "$CXXFLAGS" | sed 's/-g //'`
272 m4_define(SIMD_X86_64_TEST, [[#include <stdio.h>
273 #if HAVE_STDLIB_H
274 #include <stdlib.h>
275 #endif
276 #include <immintrin.h>
277 __attribute__ ((target("default"))) int test_ssse3(int x) { return x; }
278 __attribute__ ((target("default"))) int test_sse2(int x) { return x; }
279 __attribute__ ((target("default"))) int test_avx2(int x) { return x; }
280 __attribute__ ((target("ssse3"))) int test_ssse3(int x) { return x; }
281 __attribute__ ((target("sse2"))) int test_sse2(int x) { return x; }
282 __attribute__ ((target("avx2"))) int test_avx2(int x) { return x; }
283 typedef long long __m128i_u __attribute__((__vector_size__(16), __may_alias__, __aligned__(1)));
284 typedef long long __m256i_u __attribute__((__vector_size__(32), __may_alias__, __aligned__(1)));
285 __attribute__ ((target("default"))) void more_testing(char* buf, int len) { }
286 __attribute__ ((target("ssse3"))) void more_testing(char* buf, int len)
287 {
288 int i;
289 for (i = 0; i < (len-32); i+=32) {
290 __m128i in8_1, in8_2;
291 in8_1 = _mm_lddqu_si128((__m128i_u*)&buf[i]);
292 in8_2 = _mm_lddqu_si128((__m128i_u*)&buf[i + 16]);
293 }
294 }
295 ]])
296
297 if test x"$enable_roll_simd" = x""; then
298 case "$host_os" in
299 *linux*) ;;
300 *) enable_roll_simd=no ;;
301 esac
302 fi
303
304 if test x"$enable_roll_simd" != x"no"; then
305 # For x86-64 SIMD, g++ >=5 or clang++ >=7 is required
306 if test x"$host_cpu" = x"x86_64" || test x"$host_cpu" = x"amd64"; then
307 AC_LANG(C++)
308 if test x"$host" = x"$build"; then
309 AC_RUN_IFELSE([AC_LANG_PROGRAM([SIMD_X86_64_TEST],[[if (test_ssse3(42) != 42 || test_sse2(42) != 42 || test_avx2(42) != 42) exit(1);]])],
310 [CXX_OK=yes],[CXX_OK=no])
311 else
312 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([SIMD_X86_64_TEST])],[CXX_OK=yes],[CXX_OK=no])
313 fi
314 AC_LANG(C)
315 if test x"$CXX_OK" = x"yes"; then
316 # AC_MSG_RESULT() is called below.
317 ROLL_SIMD="$host_cpu"
318 elif test x"$enable_roll_simd" = x"yes"; then
319 AC_MSG_RESULT(error)
320 AC_MSG_ERROR(The rolling-checksum SIMD compilation test failed.
321 Omit --enable-roll-simd to continue without it.)
322 fi
323 elif test x"$enable_roll_simd" = x"yes"; then
324 AC_MSG_RESULT(unavailable)
325 AC_MSG_ERROR(The rolling-checksum SIMD optimizations are currently x86_64|amd64 only.
326 Omit --enable-roll-simd to continue without it.)
327 fi
328 fi
329
330 if test x"$ROLL_SIMD" != x""; then
331 AC_MSG_RESULT([yes ($ROLL_SIMD)])
332 AC_DEFINE(USE_ROLL_SIMD, 1, [Define to 1 to enable rolling-checksum SIMD optimizations])
333 ROLL_SIMD='$(ROLL_SIMD_'"$ROLL_SIMD)"
334 # We only use c++ for its target attribute dispatching, disable unneeded bulky features
335 CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-rtti"
336 # Apple often has "g++" as a symlink for clang. Try to find out the truth.
337 CXX_VERSION=`$CXX --version 2>/dev/null | head -n 2`
338 case "$CXX_VERSION" in
339 *clang*) CXXFLAGS="$CXXFLAGS -fno-slp-vectorize" ;; # avoid a performance hit
340 esac
341 else
342 AC_MSG_RESULT(no)
343 fi
344
345 AC_SUBST(ROLL_SIMD)
346
347 AC_MSG_CHECKING([if assembler accepts noexecstack])
348 OLD_CFLAGS="$CFLAGS"
349 CFLAGS="$CFLAGS -Wa,--noexecstack"
350 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[return 0;]])],
351 [ NOEXECSTACK='-Wa,--noexecstack' ; AC_MSG_RESULT(yes) ],
352 [ NOEXECSTACK='' ; AC_MSG_RESULT(no) ])
353 CFLAGS="$OLD_CFLAGS"
354 AC_SUBST(NOEXECSTACK)
355
356 dnl We need both the SYS_openat2 syscall number and <linux/openat2.h> (for
357 dnl struct open_how / RESOLVE_BENEATH); some setups have one without the other.
358 AC_CACHE_CHECK([for openat2],rsync_cv_HAVE_OPENAT2,[
359 AC_COMPILE_IFELSE([
360 AC_LANG_PROGRAM([[
361 #include <sys/syscall.h>
362 #include <linux/openat2.h>
363 ]], [[
364 struct open_how how;
365 how.resolve = RESOLVE_BENEATH;
366 return SYS_openat2 + (int)how.resolve;
367 ]])
368 ],
369 [rsync_cv_HAVE_OPENAT2=yes], [rsync_cv_HAVE_OPENAT2=no])
370 ])
371 if test x"$enable_openat2" != x"no"; then
372 if test x"$rsync_cv_HAVE_OPENAT2" = x"yes"; then
373 AC_DEFINE([HAVE_OPENAT2], 1,
374 [Define to use Linux openat2(RESOLVE_BENEATH) in secure_relative_open where available.])
375 fi
376 fi
377
378 # arrgh. libc in some old debian version screwed up the largefile
379 # stuff, getting byte range locking wrong
380 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
381 AC_RUN_IFELSE([AC_LANG_SOURCE([[
382 #define _FILE_OFFSET_BITS 64
383 $ac_includes_default
384 #ifdef HAVE_FCNTL_H
385 # include <fcntl.h>
386 #elif defined HAVE_SYS_FCNTL_H
387 # include <sys/fcntl.h>
388 #endif
389 #ifdef HAVE_SYS_WAIT_H
390 #include <sys/wait.h>
391 #endif
392
393 int main(void)
394 {
395 struct flock lock;
396 int status;
397 char tpl[32] = "/tmp/locktest.XXXXXX";
398 int fd = mkstemp(tpl);
399 if (fd < 0) {
400 strcpy(tpl, "conftest.dat");
401 fd = open(tpl, O_CREAT|O_RDWR, 0600);
402 }
403
404 lock.l_type = F_WRLCK;
405 lock.l_whence = SEEK_SET;
406 lock.l_start = 0;
407 lock.l_len = 1;
408 lock.l_pid = 0;
409 fcntl(fd,F_SETLK,&lock);
410 if (fork() == 0) {
411 lock.l_start = 1;
412 _exit(fcntl(fd,F_SETLK,&lock) == 0);
413 }
414 wait(&status);
415 unlink(tpl);
416 return WEXITSTATUS(status);
417 }
418 ]])],[rsync_cv_HAVE_BROKEN_LARGEFILE=yes],[rsync_cv_HAVE_BROKEN_LARGEFILE=no],[rsync_cv_HAVE_BROKEN_LARGEFILE=cross])])
419 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
420 AC_SYS_LARGEFILE
421 fi
422
423 AC_MSG_CHECKING([whether to enable ipv6])
424 AC_ARG_ENABLE(ipv6,
425 AS_HELP_STRING([--disable-ipv6],[disable to omit ipv6 support]),
426 [ case "$enableval" in
427 no)
428 AC_MSG_RESULT(no)
429 ;;
430 *) AC_MSG_RESULT(yes)
431 AC_DEFINE(INET6, 1, [true if you have IPv6])
432 ;;
433 esac ],
434
435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
436 #include <sys/types.h>
437 #include <sys/socket.h>
438 #include <netinet/in.h>
439 ]], [[
440 struct sockaddr_in6 sa6;
441 (void)sa6;
442 (void)AF_INET6;
443 ]])],
444 [AC_MSG_RESULT(yes)
445 AC_DEFINE(INET6, 1, [true if you have IPv6])],
446 [AC_MSG_RESULT(no)]
447 ))
448
449 dnl Do you want to disable use of locale functions
450 AC_ARG_ENABLE([locale],
451 AS_HELP_STRING([--disable-locale],[disable to omit locale features]))
452 AH_TEMPLATE([CONFIG_LOCALE],
453 [Undefine if you do not want locale features. By default this is defined.])
454 if test x"$enable_locale" != x"no"; then
455 AC_DEFINE(CONFIG_LOCALE)
456 fi
457
458 AC_MSG_CHECKING([whether to call shutdown on all sockets])
459 case $host_os in
460 *cygwin* ) AC_MSG_RESULT(yes)
461 AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1,
462 [Define to 1 if sockets need to be shutdown])
463 ;;
464 * ) AC_MSG_RESULT(no);;
465 esac
466
467 # We default to using our zlib unless --with-included-zlib=no is given.
468 if test x"$with_included_zlib" != x"no"; then
469 with_included_zlib=yes
470 elif test x"$ac_cv_header_zlib_h" != x"yes"; then
471 with_included_zlib=yes
472 fi
473 if test x"$with_included_zlib" != x"yes"; then
474 AC_CHECK_LIB(z, deflateParams, , [with_included_zlib=yes])
475 fi
476
477 AC_MSG_CHECKING([whether to use included zlib])
478 if test x"$with_included_zlib" = x"yes"; then
479 AC_MSG_RESULT($srcdir/zlib)
480 BUILD_ZLIB='$(zlib_OBJS)'
481 CFLAGS="-I$srcdir/zlib $CFLAGS"
482 else
483 AC_DEFINE(EXTERNAL_ZLIB, 1, [Define to 1 if using external zlib])
484 AC_MSG_RESULT(no)
485 fi
486
487 AC_MSG_CHECKING([whether to enable use of openssl crypto library])
488 AC_ARG_ENABLE([openssl],
489 AS_HELP_STRING([--disable-openssl],[disable to omit openssl crypto library]))
490 AH_TEMPLATE([USE_OPENSSL],
491 [Undefine if you do not want to use openssl crypto library. By default this is defined.])
492 if test x"$enable_openssl" != x"no"; then
493 if test x"$ac_cv_header_openssl_md4_h" = x"yes" && test x"$ac_cv_header_openssl_md5_h" = x"yes"; then
494 AC_MSG_RESULT(yes)
495 AC_SEARCH_LIBS(EVP_MD_CTX_copy, crypto,
496 [AC_DEFINE(USE_OPENSSL)
497 enable_openssl=yes],
498 [err_msg="$err_msg$nl- Failed to find EVP_MD_CTX_copy function in openssl crypto lib.";
499 no_lib="$no_lib openssl"])
500 else
501 AC_MSG_RESULT(no)
502 err_msg="$err_msg$nl- Failed to find openssl/md4.h and openssl/md5.h for openssl crypto lib support."
503 no_lib="$no_lib openssl"
504 fi
505 if test x"$enable_md5_asm" != x"yes"; then
506 enable_md5_asm=no
507 fi
508 else
509 AC_MSG_RESULT(no)
510 fi
511
512 MD5_ASM=
513
514 AC_MSG_CHECKING([whether to enable MD5 ASM optimizations])
515 AC_ARG_ENABLE(md5-asm,
516 AS_HELP_STRING([--enable-md5-asm],[enable/disable to control MD5 ASM optimizations]))
517
518 if test x"$enable_md5_asm" = x""; then
519 case "$host_os" in
520 *linux*) ;;
521 *) enable_md5_asm=no ;;
522 esac
523 fi
524
525 if test x"$enable_md5_asm" != x"no"; then
526 if test x"$host_cpu" = x"x86_64" || test x"$host_cpu" = x"amd64"; then
527 MD5_ASM="$host_cpu"
528 elif test x"$enable_md5_asm" = x"yes"; then
529 AC_MSG_RESULT(unavailable)
530 AC_MSG_ERROR(The ASM optimizations are currently x86_64|amd64 only.
531 Omit --enable-md5-asm to continue without it.)
532 fi
533 fi
534
535 if test x"$MD5_ASM" != x""; then
536 AC_MSG_RESULT([yes ($MD5_ASM)])
537 AC_DEFINE(USE_MD5_ASM, 1, [Define to 1 to enable MD5 ASM optimizations])
538 MD5_ASM='$(MD5_ASM_'"$MD5_ASM)"
539 else
540 AC_MSG_RESULT(no)
541 fi
542
543 AC_SUBST(MD5_ASM)
544
545 ROLL_ASM=
546
547 AC_MSG_CHECKING([whether to enable rolling-checksum ASM optimizations])
548 AC_ARG_ENABLE(roll-asm,
549 AS_HELP_STRING([--enable-roll-asm],[enable/disable to control rolling-checksum ASM optimizations (requires --enable-roll-simd)]))
550
551 if test x"$ROLL_SIMD" = x""; then
552 enable_roll_asm=no
553 fi
554
555 if test x"$enable_roll_asm" = x"yes"; then
556 ROLL_ASM="$host_cpu"
557 AC_MSG_RESULT([yes ($ROLL_ASM)])
558 AC_DEFINE(USE_ROLL_ASM, 1, [Define to 1 to enable rolling-checksum ASM optimizations (requires --enable-roll-simd)])
559 ROLL_ASM='$(ROLL_ASM_'"$ROLL_ASM)"
560 else
561 AC_MSG_RESULT(no)
562 fi
563
564 AC_SUBST(ROLL_ASM)
565
566 AC_MSG_CHECKING([whether to enable xxhash checksum support])
567 AC_ARG_ENABLE([xxhash],
568 AS_HELP_STRING([--disable-xxhash],[disable to omit xxhash checksums]))
569 AH_TEMPLATE([SUPPORT_XXHASH],
570 [Undefine if you do not want xxhash checksums. By default this is defined.])
571 if test x"$enable_xxhash" != x"no"; then
572 if test x"$ac_cv_header_xxhash_h" = x"yes"; then
573 AC_MSG_RESULT(yes)
574 AC_SEARCH_LIBS(XXH64_createState, xxhash,
575 [AC_DEFINE(SUPPORT_XXHASH)],
576 [err_msg="$err_msg$nl- Failed to find XXH64_createState function in xxhash lib.";
577 no_lib="$no_lib xxhash"])
578 else
579 AC_MSG_RESULT(no)
580 err_msg="$err_msg$nl- Failed to find xxhash.h for xxhash checksum support.";
581 no_lib="$no_lib xxhash"
582 fi
583 else
584 AC_MSG_RESULT(no)
585 fi
586
587 AC_MSG_CHECKING([whether to enable zstd compression])
588 AC_ARG_ENABLE([zstd],
589 AS_HELP_STRING([--disable-zstd], [disable to omit zstd compression]))
590 AH_TEMPLATE([SUPPORT_ZSTD],
591 [Undefine if you do not want zstd compression. By default this is defined.])
592 if test x"$enable_zstd" != x"no"; then
593 if test x"$ac_cv_header_zstd_h" = x"yes"; then
594 AC_MSG_RESULT(yes)
595 AC_SEARCH_LIBS(ZSTD_minCLevel, zstd,
596 [AC_DEFINE(SUPPORT_ZSTD)],
597 [err_msg="$err_msg$nl- Failed to find ZSTD_minCLevel function in zstd lib.";
598 no_lib="$no_lib zstd"])
599 else
600 AC_MSG_RESULT(no)
601 err_msg="$err_msg$nl- Failed to find zstd.h for zstd compression support.";
602 no_lib="$no_lib zstd"
603 fi
604 else
605 AC_MSG_RESULT(no)
606 fi
607
608 AC_MSG_CHECKING([whether to enable LZ4 compression])
609 AC_ARG_ENABLE([lz4],
610 AS_HELP_STRING([--disable-lz4], [disable to omit LZ4 compression]))
611 AH_TEMPLATE([SUPPORT_LZ4],
612 [Undefine if you do not want LZ4 compression. By default this is defined.])
613 if test x"$enable_lz4" != x"no"; then
614 if test x"$ac_cv_header_lz4_h" = x"yes"; then
615 AC_MSG_RESULT(yes)
616 AC_SEARCH_LIBS(LZ4_compress_default, lz4,
617 [AC_DEFINE(SUPPORT_LZ4)],
618 [err_msg="$err_msg$nl- Failed to find LZ4_compress_default function in lz4 lib.";
619 no_lib="$no_lib lz4"])
620 else
621 AC_MSG_RESULT(no)
622 err_msg="$err_msg$nl- Failed to find lz4.h for lz4 compression support."
623 no_lib="$no_lib lz4"
624 fi
625 else
626 AC_MSG_RESULT(no)
627 fi
628
629 if test x"$no_lib" != x; then
630 echo ""
631 echo "Configure found the following issues:"
632 echo "$err_msg"
633 echo ""
634 echo "See the INSTALL file for hints on how to install the missing libraries and/or"
635 echo "how to generate (or fetch) manpages:"
636 echo " https://github.com/RsyncProject/rsync/blob/master/INSTALL.md"
637 echo ""
638 echo "To disable one or more features, the relevant configure options are:"
639 for lib in $no_lib; do
640 echo " --disable-$lib"
641 done
642 echo ""
643 AC_MSG_ERROR(Aborting configure run)
644 fi
645
646 AC_CACHE_CHECK([if makedev takes 3 args],rsync_cv_MAKEDEV_TAKES_3_ARGS,[
647 AC_RUN_IFELSE([AC_LANG_SOURCE([[
648 #ifdef HAVE_SYS_TYPES_H
649 #include <sys/types.h>
650 #endif
651 #ifdef MAJOR_IN_MKDEV
652 #include <sys/mkdev.h>
653 # if !defined makedev && (defined mkdev || defined _WIN32 || defined __WIN32__)
654 # define makedev mkdev
655 # endif
656 #elif defined MAJOR_IN_SYSMACROS
657 #include <sys/sysmacros.h>
658 #endif
659
660 int main(void)
661 {
662 dev_t dev = makedev(0, 5, 7);
663 if (major(dev) != 5 || minor(dev) != 7)
664 return 1;
665 return 0;
666 }
667 ]])],[rsync_cv_MAKEDEV_TAKES_3_ARGS=yes],[rsync_cv_MAKEDEV_TAKES_3_ARGS=no],[rsync_cv_MAKEDEV_TAKES_3_ARGS=no])])
668 if test x"$rsync_cv_MAKEDEV_TAKES_3_ARGS" = x"yes"; then
669 AC_DEFINE(MAKEDEV_TAKES_3_ARGS, 1, [Define to 1 if makedev() takes 3 args])
670 fi
671
672 AC_CHECK_SIZEOF(int)
673 AC_CHECK_SIZEOF(long)
674 AC_CHECK_SIZEOF(long long)
675 AC_CHECK_SIZEOF(short)
676 AC_CHECK_SIZEOF(int16_t)
677 AC_CHECK_SIZEOF(uint16_t)
678 AC_CHECK_SIZEOF(int32_t)
679 AC_CHECK_SIZEOF(uint32_t)
680 AC_CHECK_SIZEOF(int64_t)
681 AC_CHECK_SIZEOF(off_t)
682 AC_CHECK_SIZEOF(off64_t)
683 AC_CHECK_SIZEOF(time_t)
684 AC_CHECK_SIZEOF(char*)
685
686 AC_C_INLINE
687
688 AC_TYPE_LONG_DOUBLE_WIDER
689 ac_cv_c_long_double=$ac_cv_type_long_double_wider
690 if test $ac_cv_c_long_double = yes; then
691 AC_DEFINE([HAVE_LONG_DOUBLE],[1],[Define to 1 if the type `long double' works and has more range or precision than `double'.])
692 fi
693
694 AC_TYPE_UID_T
695 AC_CHECK_TYPES([mode_t,off_t,size_t,pid_t,id_t])
696 if test "$cross_compiling" = no; then
697 AC_TYPE_GETGROUPS
698 else
699 AC_DEFINE([GETGROUPS_T],[gid_t],[Define to the type of elements in the array set by `getgroups'. Usually this is either `int' or `gid_t'.])
700 fi
701 AC_CHECK_MEMBERS([struct stat.st_rdev,
702 struct stat.st_mtimensec,
703 struct stat.st_mtimespec.tv_nsec,
704 struct stat.st_mtim.tv_nsec],,,[
705 #ifdef HAVE_SYS_TYPES_H
706 #include <sys/types.h>
707 #endif
708 #ifdef HAVE_SYS_STAT_H
709 #include <sys/stat.h>
710 #endif
711 #ifdef HAVE_UNISTD_H
712 #include <unistd.h>
713 #endif])
714
715 TYPE_SOCKLEN_T
716
717 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
718 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[int i = errno]])],[rsync_cv_errno=yes],[rsync_cv_have_errno_decl=no])])
719 if test x"$rsync_cv_errno" = x"yes"; then
720 AC_DEFINE(HAVE_ERRNO_DECL, 1, [Define to 1 if errno is declared in errno.h])
721 fi
722
723 # The following test taken from the cvs sources
724 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
725 # These need checks to be before checks for any other functions that
726 # might be in the same libraries.
727 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
728 # libsocket.so which has a bad implementation of gethostbyname (it
729 # only looks in /etc/hosts), so we only look for -lsocket if we need
730 # it.
731 AC_CHECK_FUNCS(connect)
732 if test x"$ac_cv_func_connect" = x"no"; then
733 case "$LIBS" in
734 *-lnsl*) ;;
735 *) AC_CHECK_LIB(nsl_s, printf) ;;
736 esac
737 case "$LIBS" in
738 *-lnsl*) ;;
739 *) AC_CHECK_LIB(nsl, printf) ;;
740 esac
741 case "$LIBS" in
742 *-lsocket*) ;;
743 *) AC_CHECK_LIB(socket, connect) ;;
744 esac
745 case "$LIBS" in
746 *-linet*) ;;
747 *) AC_CHECK_LIB(inet, connect) ;;
748 esac
749 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
750 dnl has been cached.
751 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
752 test x"$ac_cv_lib_inet_connect" = x"yes"; then
753 # ac_cv_func_connect=yes
754 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
755 AC_DEFINE(HAVE_CONNECT, 1, [Define to 1 if you have the "connect" function])
756 fi
757 fi
758
759 AC_SEARCH_LIBS(inet_ntop, resolv)
760
761 # For OS X, Solaris, HP-UX, etc.: figure out if -liconv is needed. We'll
762 # accept either iconv_open or libiconv_open, since some include files map
763 # the former to the latter.
764 AC_SEARCH_LIBS(iconv_open, iconv)
765 AC_SEARCH_LIBS(libiconv_open, iconv)
766
767 AC_MSG_CHECKING([for iconv declaration])
768 AC_CACHE_VAL(am_cv_proto_iconv, [
769 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
770 #if HAVE_STDLIB_H
771 #include <stdlib.h>
772 #endif
773 #include <iconv.h>
774 extern
775 #ifdef __cplusplus
776 "C"
777 #endif
778 #if defined(__STDC__) || defined(__cplusplus)
779 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
780 #else
781 size_t iconv();
782 #endif
783 ]], [[]])],[am_cv_proto_iconv_arg1=""],[am_cv_proto_iconv_arg1="const"])
784 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);"])
785 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed 's/( /(/'`
786 AC_MSG_RESULT([$]{ac_t:-
787 }[$]am_cv_proto_iconv)
788 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
789 [Define as const if the declaration of iconv() needs const.])
790
791 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
792
793 AC_REPLACE_FUNCS([inet_ntop inet_pton])
794
795 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
796 AC_HAVE_TYPE([struct sockaddr_storage], [
797 #ifdef HAVE_SYS_TYPES_H
798 #include <sys/types.h>
799 #endif
800 #ifdef HAVE_SYS_SOCKET_H
801 #include <sys/socket.h>
802 #endif])
803
804 # Irix 6.5 has getaddrinfo but not the corresponding defines, so use
805 # builtin getaddrinfo if one of the defines don't exist
806 AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
807 rsync_cv_HAVE_GETADDR_DEFINES,[
808 AC_EGREP_CPP(yes, [
809 #ifdef HAVE_SYS_TYPES_H
810 #include <sys/types.h>
811 #endif
812 #ifdef HAVE_SYS_SOCKET_H
813 #include <sys/socket.h>
814 #endif
815 #ifdef HAVE_NETDB_H
816 #include <netdb.h>
817 #endif
818 #ifdef AI_PASSIVE
819 yes
820 #endif],
821 rsync_cv_HAVE_GETADDR_DEFINES=yes,
822 rsync_cv_HAVE_GETADDR_DEFINES=no)])
823 AS_IF([test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes" && test x"$ac_cv_type_struct_addrinfo" = x"yes"],[
824 # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
825 # something else so we must include <netdb.h> to get the
826 # redefinition.
827 AC_CHECK_FUNCS(getaddrinfo, ,
828 [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
829 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
830 #ifdef HAVE_SYS_TYPES_H
831 #include <sys/types.h>
832 #endif
833 #ifdef HAVE_SYS_SOCKET_H
834 #include <sys/socket.h>
835 #endif
836 #include <netdb.h>]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],[AC_MSG_RESULT([yes])
837 AC_DEFINE(HAVE_GETADDRINFO, 1,
838 [Define to 1 if you have the "getaddrinfo" function and required types.])],[AC_MSG_RESULT([no])
839 AC_LIBOBJ([getaddrinfo])])])
840 ],[AC_LIBOBJ([getaddrinfo])])
841
842 AC_CHECK_MEMBER([struct sockaddr.sa_len],
843 [ AC_DEFINE(HAVE_SOCKADDR_LEN, 1, [Do we have sockaddr.sa_len?]) ],
844 [],
845 [
846 #ifdef HAVE_SYS_TYPES_H
847 #include <sys/types.h>
848 #endif
849 #ifdef HAVE_SYS_SOCKET_H
850 #include <sys/socket.h>
851 #endif
852 ])
853
854 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
855 [ AC_DEFINE(HAVE_SOCKADDR_IN_LEN, 1, [Do we have sockaddr_in.sin_len?]) ],
856 [],
857 [
858 #ifdef HAVE_SYS_TYPES_H
859 #include <sys/types.h>
860 #endif
861 #ifdef HAVE_SYS_SOCKET_H
862 #include <sys/socket.h>
863 #endif
864 #include <netinet/in.h>
865 ])
866
867 AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
868 [ AC_DEFINE(HAVE_SOCKADDR_UN_LEN, 1, [Do we have sockaddr_un.sun_len?]) ],
869 [],
870 [
871 #ifdef HAVE_SYS_TYPES_H
872 #include <sys/types.h>
873 #endif
874 #ifdef HAVE_SYS_SOCKET_H
875 #include <sys/socket.h>
876 #endif
877 #include <netinet/in.h>
878 ])
879
880 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
881 [ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID, 1, [Do we have sockaddr_in6.sin6_scope_id?]) ],
882 [],
883 [
884 #ifdef HAVE_SYS_TYPES_H
885 #include <sys/types.h>
886 #endif
887 #ifdef HAVE_SYS_SOCKET_H
888 #include <sys/socket.h>
889 #endif
890 #include <netinet/in.h>
891 ])
892
893 AC_HAVE_TYPE([struct stat64], [#include <stdio.h>
894 #if HAVE_SYS_TYPES_H
895 # include <sys/types.h>
896 #endif
897 #if HAVE_SYS_STAT_H
898 # include <sys/stat.h>
899 #endif
900 #if STDC_HEADERS
901 # include <stdlib.h>
902 # include <stddef.h>
903 #else
904 # if HAVE_STDLIB_H
905 # include <stdlib.h>
906 # endif
907 #endif
908 ])
909
910 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
911 #
912 dnl rsync's I/O readiness loops use poll() rather than select() so that a
913 dnl file descriptor at or above FD_SETSIZE cannot overflow an fd_set (which
914 dnl is undefined behaviour and could hang the transfer). poll() is in
915 dnl POSIX.1-2001; fail early and clearly if this target lacks it.
916 dnl
917 dnl io.c and socket.c include <poll.h> unconditionally, so the HEADER has to
918 dnl be required too: a system that exposes poll() through some other header
919 dnl would otherwise pass configure and then fail to compile.
920 AC_CHECK_FUNCS([poll], , [AC_MSG_ERROR([rsync requires poll(); please report the platform to the rsync developers])])
921 if test x"$ac_cv_header_poll_h" != x"yes"; then
922 AC_MSG_ERROR([rsync requires <poll.h>; please report the platform to the rsync developers])
923 fi
924
925 AC_CHECK_FUNCS(strcasecmp)
926 if test x"$ac_cv_func_strcasecmp" = x"no"; then
927 AC_CHECK_LIB(resolv, strcasecmp)
928 fi
929
930 AC_CHECK_FUNCS(aclsort)
931 if test x"$ac_cv_func_aclsort" = x"no"; then
932 AC_CHECK_LIB(sec, aclsort)
933 fi
934
935 dnl At the moment we don't test for a broken memcmp(), because all we
936 dnl need to do is test for equality, not comparison, and it seems that
937 dnl every platform has a memcmp that can do at least that.
938 dnl AC_FUNC_MEMCMP
939
940 AC_FUNC_UTIME_NULL
941 AC_FUNC_ALLOCA
942 AC_CHECK_FUNCS(waitpid wait4 getcwd chown chmod lchmod mknod mkfifo fdopendir \
943 getrlimit setrlimit \
944 fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
945 chflags getattrlist mktime innetgr linkat mknodat mkfifoat \
946 memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
947 strlcat strlcpy stpcpy strtol mallinfo mallinfo2 getgroups setgroups geteuid getegid \
948 setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
949 seteuid strerror putenv iconv_open locale_charset nl_langinfo getxattr \
950 extattr_get_link sigaction sigprocmask setattrlist getgrouplist \
951 initgroups utimensat futimens posix_fallocate attropen setvbuf nanosleep usleep \
952 setenv unsetenv)
953
954 dnl dirfd() is a macro or static inline on several systems (the BSDs), so the
955 dnl default AC_CHECK_FUNCS link probe -- which declares `char dirfd(void);` and
956 dnl links against a bare symbol -- gives a false negative there. Probe it with a
957 dnl real compile+link that includes <dirent.h> and actually calls dirfd().
958 AC_CACHE_CHECK([for dirfd], rsync_cv_HAVE_DIRFD,
959 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <dirent.h>]],
960 [[DIR *d = opendir("."); return d ? dirfd(d) < -1 : 0;]])],
961 [rsync_cv_HAVE_DIRFD=yes], [rsync_cv_HAVE_DIRFD=no])])
962 if test x"$rsync_cv_HAVE_DIRFD" = x"yes"; then
963 AC_DEFINE([HAVE_DIRFD], 1, [Define to 1 if you have a working dirfd() (function or macro).])
964 fi
965
966 dnl cygwin iconv.h defines iconv_open as libiconv_open
967 if test x"$ac_cv_func_iconv_open" != x"yes"; then
968 AC_CHECK_FUNC(libiconv_open, [ac_cv_func_iconv_open=yes; AC_DEFINE(HAVE_ICONV_OPEN, 1)])
969 fi
970
971 dnl Preallocation stuff (also fallocate, posix_fallocate function tests above):
972
973 AC_CACHE_CHECK([for useable fallocate],rsync_cv_have_fallocate,[
974 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>
975 #ifdef HAVE_SYS_TYPES_H
976 #include <sys/types.h>
977 #endif]], [[fallocate(0, 0, 0, 0);]])],[rsync_cv_have_fallocate=yes],[rsync_cv_have_fallocate=no])])
978 if test x"$rsync_cv_have_fallocate" = x"yes"; then
979 AC_DEFINE(HAVE_FALLOCATE, 1, [Define to 1 if you have the fallocate function and it compiles and links without error])
980 fi
981
982 AC_MSG_CHECKING([for FALLOC_FL_PUNCH_HOLE])
983 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
984 #define _GNU_SOURCE 1
985 #include <linux/falloc.h>
986 #ifndef FALLOC_FL_PUNCH_HOLE
987 #error FALLOC_FL_PUNCH_HOLE is missing
988 #endif
989 ]])], [
990 AC_MSG_RESULT([yes])
991 AC_DEFINE([HAVE_FALLOC_FL_PUNCH_HOLE], [1], [Define if FALLOC_FL_PUNCH_HOLE is available.])
992 ], [
993 AC_MSG_RESULT([no])
994 ]
995 )
996
997 AC_MSG_CHECKING([for FALLOC_FL_ZERO_RANGE])
998 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
999 #define _GNU_SOURCE 1
1000 #include <linux/falloc.h>
1001 #ifndef FALLOC_FL_ZERO_RANGE
1002 #error FALLOC_FL_ZERO_RANGE is missing
1003 #endif
1004 ]])], [
1005 AC_MSG_RESULT([yes])
1006 AC_DEFINE([HAVE_FALLOC_FL_ZERO_RANGE], [1], [Define if FALLOC_FL_ZERO_RANGE is available.])
1007 ], [
1008 AC_MSG_RESULT([no])
1009 ]
1010 )
1011
1012 AC_CACHE_CHECK([for SYS_fallocate],rsync_cv_have_sys_fallocate,[
1013 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/syscall.h>
1014 #ifdef HAVE_UNISTD_H
1015 #include <unistd.h>
1016 #endif
1017 #ifdef HAVE_SYS_TYPES_H
1018 #include <sys/types.h>
1019 #endif]], [[syscall(SYS_fallocate, 0, 0, (loff_t)0, (loff_t)0);]])],[rsync_cv_have_sys_fallocate=yes],[rsync_cv_have_sys_fallocate=no])])
1020 if test x"$rsync_cv_have_sys_fallocate" = x"yes"; then
1021 AC_DEFINE(HAVE_SYS_FALLOCATE, 1, [Define to 1 if you have the SYS_fallocate syscall number])
1022 fi
1023
1024 if test x"$ac_cv_func_posix_fallocate" = x"yes"; then
1025 AC_MSG_CHECKING([whether posix_fallocate is efficient])
1026 case $host_os in
1027 *cygwin*)
1028 AC_MSG_RESULT(yes)
1029 AC_DEFINE(HAVE_EFFICIENT_POSIX_FALLOCATE, 1,
1030 [Define if posix_fallocate is efficient (Cygwin)])
1031 ;;
1032 *)
1033 AC_MSG_RESULT(no)
1034 ;;
1035 esac
1036 fi
1037
1038 dnl End of preallocation stuff
1039
1040 AC_CHECK_FUNCS(getpgrp tcgetpgrp)
1041 if test $ac_cv_func_getpgrp = yes; then
1042 AC_FUNC_GETPGRP
1043 fi
1044
1045 AC_ARG_ENABLE(iconv-open,
1046 AS_HELP_STRING([--disable-iconv-open],[disable to avoid all use of iconv_open()]),
1047 [], [enable_iconv_open=$ac_cv_func_iconv_open])
1048
1049 if test x"$enable_iconv_open" != x"no"; then
1050 AC_DEFINE(USE_ICONV_OPEN, 1, [Define to 1 if you want rsync to make use of iconv_open()])
1051 fi
1052
1053 AC_ARG_ENABLE(iconv,
1054 AS_HELP_STRING([--disable-iconv],[disable to omit the --iconv option]),
1055 [], [enable_iconv=$enable_iconv_open])
1056 AH_TEMPLATE([ICONV_OPTION],
1057 [Define if you want the --iconv option. Specifying a value will set the
1058 default iconv setting (a NULL means no --iconv processing by default).])
1059 if test x"$enable_iconv" != x"no"; then
1060 if test x"$enable_iconv" = x"yes"; then
1061 AC_DEFINE(ICONV_OPTION, NULL)
1062 else
1063 AC_DEFINE_UNQUOTED(ICONV_OPTION, "$enable_iconv")
1064 fi
1065 AC_DEFINE(UTF8_CHARSET, "UTF-8", [String to pass to iconv() for the UTF-8 charset.])
1066 fi
1067
1068 AC_CACHE_CHECK([whether chown() modifies symlinks],rsync_cv_chown_modifies_symlink,[
1069 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1070 #if HAVE_UNISTD_H
1071 # include <unistd.h>
1072 #endif
1073 #include <stdlib.h>
1074 #include <errno.h>
1075 int main(void) {
1076 char const *dangling_symlink = "conftest.dangle";
1077 unlink(dangling_symlink);
1078 if (symlink("conftest.no-such", dangling_symlink) < 0) abort();
1079 if (chown(dangling_symlink, getuid(), getgid()) < 0 && errno == ENOENT) return 1;
1080 return 0;
1081 }]])],[rsync_cv_chown_modifies_symlink=yes],[rsync_cv_chown_modifies_symlink=no],[rsync_cv_chown_modifies_symlink=no])])
1082 if test $rsync_cv_chown_modifies_symlink = yes; then
1083 AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1, [Define to 1 if chown modifies symlinks.])
1084 fi
1085
1086 AC_CACHE_CHECK([whether link() can hard-link symlinks],rsync_cv_can_hardlink_symlink,[
1087 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1088 #ifdef HAVE_FCNTL_H
1089 # include <fcntl.h>
1090 #elif defined HAVE_SYS_FCNTL_H
1091 # include <sys/fcntl.h>
1092 #endif
1093 #if HAVE_UNISTD_H
1094 # include <unistd.h>
1095 #endif
1096 #include <stdlib.h>
1097 #include <errno.h>
1098 #define FILENAME "conftest.dangle"
1099 int main(void) {
1100 unlink(FILENAME);
1101 if (symlink("conftest.no-such", FILENAME) < 0) abort();
1102 unlink(FILENAME "2");
1103 #ifdef HAVE_LINKAT
1104 if (linkat(AT_FDCWD, FILENAME, AT_FDCWD, FILENAME "2", 0) < 0) return 1;
1105 #else
1106 if (link(FILENAME, FILENAME "2") < 0) return 1;
1107 #endif
1108 return 0;
1109 }]])],[rsync_cv_can_hardlink_symlink=yes],[rsync_cv_can_hardlink_symlink=no],[rsync_cv_can_hardlink_symlink=no])])
1110 if test $rsync_cv_can_hardlink_symlink = yes; then
1111 AC_DEFINE(CAN_HARDLINK_SYMLINK, 1, [Define to 1 if link() can hard-link symlinks.])
1112 fi
1113
1114 AC_CACHE_CHECK([whether link() can hard-link special files],rsync_cv_can_hardlink_special,[
1115 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1116 #if HAVE_UNISTD_H
1117 # include <unistd.h>
1118 #endif
1119 #ifdef HAVE_SYS_STAT_H
1120 #include <sys/stat.h>
1121 #endif
1122 #include <stdlib.h>
1123 #include <errno.h>
1124 #define FILENAME "conftest.fifi"
1125 int main(void) {
1126 unlink(FILENAME);
1127 if (mkfifo(FILENAME, 0777) < 0) abort();
1128 unlink(FILENAME "2");
1129 if (link(FILENAME, FILENAME "2") < 0) return 1;
1130 return 0;
1131 }]])],[rsync_cv_can_hardlink_special=yes],[rsync_cv_can_hardlink_special=no],[rsync_cv_can_hardlink_special=no])])
1132 if test $rsync_cv_can_hardlink_special = yes; then
1133 AC_DEFINE(CAN_HARDLINK_SPECIAL, 1, [Define to 1 if link() can hard-link special files.])
1134 fi
1135
1136 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
1137 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1138 #ifdef HAVE_SYS_TYPES_H
1139 #include <sys/types.h>
1140 #endif
1141 #ifdef HAVE_SYS_SOCKET_H
1142 #include <sys/socket.h>
1143 #endif
1144
1145 int main(void) {
1146 int fd[2];
1147 return (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1;
1148 }]])],[rsync_cv_HAVE_SOCKETPAIR=yes],[rsync_cv_HAVE_SOCKETPAIR=no],[rsync_cv_HAVE_SOCKETPAIR=cross])])
1149 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
1150 AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define to 1 if you have the "socketpair" function])
1151 fi
1152
1153 AC_REPLACE_FUNCS([getpass])
1154
1155 if test x"$with_included_popt" != x"yes"; then
1156 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
1157 fi
1158 if test x"$ac_cv_header_popt_popt_h" = x"yes"; then
1159 # If the system has /usr/include/popt/popt.h, we enable the
1160 # included popt because an attempt to "#include <popt/popt.h>"
1161 # would use our included header file anyway (due to -I.), and
1162 # might conflict with the system popt.
1163 with_included_popt=yes
1164 elif test x"$ac_cv_header_popt_h" != x"yes"; then
1165 with_included_popt=yes
1166 fi
1167
1168 AC_MSG_CHECKING([whether to use included libpopt])
1169 if test x"$with_included_popt" = x"yes"; then
1170 AC_MSG_RESULT($srcdir/popt)
1171 BUILD_POPT='$(popt_OBJS)'
1172 CFLAGS="-I$srcdir/popt $CFLAGS"
1173 AC_DEFINE(POPT_SYSCONFDIR, "/etc", [sysconfig dir for popt])
1174 AC_DEFINE(PACKAGE, "rsync", [package name for rsync])
1175 if test x"$ALLOCA" != x
1176 then
1177 # this can be removed when/if we add an included alloca.c;
1178 # see autoconf documentation on AC_FUNC_ALLOCA
1179 AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
1180 fi
1181 else
1182 AC_MSG_RESULT(no)
1183 fi
1184
1185 AC_CACHE_CHECK([for unsigned char],rsync_cv_SIGNED_CHAR_OK,[
1186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char *s = (signed char *)""]])],[rsync_cv_SIGNED_CHAR_OK=yes],[rsync_cv_SIGNED_CHAR_OK=no])])
1187 if test x"$rsync_cv_SIGNED_CHAR_OK" = x"yes"; then
1188 AC_DEFINE(SIGNED_CHAR_OK, 1, [Define to 1 if "signed char" is a valid type])
1189 fi
1190
1191 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
1192 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1193 #ifdef HAVE_SYS_TYPES_H
1194 #include <sys/types.h>
1195 #endif
1196 #include <dirent.h>
1197 int main(void) { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1198 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1199 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])])
1200 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1201 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [Define to 1 if readdir() is broken])
1202 fi
1203
1204 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_STRUCT_UTIMBUF,[
1205 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1206 #ifdef HAVE_SYS_TYPES_H
1207 #include <sys/types.h>
1208 #endif
1209 #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])])
1210 if test x"$rsync_cv_HAVE_STRUCT_UTIMBUF" = x"yes"; then
1211 AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1, [Define to 1 if you have the "struct utimbuf" type])
1212 fi
1213
1214 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
1215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>
1216 #ifdef HAVE_UNISTD_H
1217 #include <unistd.h>
1218 #endif]], [[struct timeval tv; return gettimeofday(&tv, NULL);]])],[rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes],[rsync_cv_HAVE_GETTIMEOFDAY_TZ=no])])
1219 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" != x"no"; then
1220 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [Define to 1 if gettimeofday() takes a time-zone arg])
1221 fi
1222
1223 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
1224 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1225 #ifdef HAVE_SYS_TYPES_H
1226 #include <sys/types.h>
1227 #endif
1228 #include <stdarg.h>
1229 #include <stdio.h>
1230 #if HAVE_STDLIB_H
1231 #include <stdlib.h>
1232 #endif
1233 #include <string.h>
1234 void foo(const char *format, ...) {
1235 va_list ap;
1236 int len;
1237 static char buf[] = "12345678901234567890";
1238
1239 va_start(ap, format);
1240 len = vsnprintf(0, 0, format, ap);
1241 va_end(ap);
1242 if (len != 5) exit(1);
1243
1244 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1245 }
1246 int main(void) { foo("hello"); return 0; }
1247 ]])],[rsync_cv_HAVE_C99_VSNPRINTF=yes],[rsync_cv_HAVE_C99_VSNPRINTF=no],[rsync_cv_HAVE_C99_VSNPRINTF=cross])])
1248 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1249 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [Define to 1 if vsprintf has a C99-compatible return value])
1250 fi
1251
1252
1253 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
1254 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
1255 #ifdef HAVE_SYS_TYPES_H
1256 #include <sys/types.h>
1257 #endif
1258 #include <sys/stat.h>
1259 #ifdef HAVE_UNISTD_H
1260 #include <unistd.h>
1261 #endif
1262 int main(void) {
1263 struct stat st;
1264 char tpl[20]="/tmp/test.XXXXXX";
1265 int fd = mkstemp(tpl);
1266 if (fd == -1) return 1;
1267 unlink(tpl);
1268 if (fstat(fd, &st) != 0) return 1;
1269 if ((st.st_mode & 0777) != 0600) return 1;
1270 return 0;
1271 }]])],[rsync_cv_HAVE_SECURE_MKSTEMP=yes],[rsync_cv_HAVE_SECURE_MKSTEMP=no],[rsync_cv_HAVE_SECURE_MKSTEMP=cross])])
1272 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1273 case $host_os in
1274 hpux*)
1275 dnl HP-UX has a broken mkstemp() implementation they refuse to fix,
1276 dnl so we noisily skip using it. See HP change request JAGaf34426
1277 dnl for details. (sbonds)
1278 AC_MSG_WARN(Skipping broken HP-UX mkstemp() -- using mktemp() instead)
1279 ;;
1280 *)
1281 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [Define to 1 if mkstemp() is available and works right])
1282 ;;
1283 esac
1284 fi
1285
1286
1287 # Whether mknod()/mknodat() can create a FIFO or a unix-domain socket is a
1288 # property of the target filesystem, not a build-time constant -- e.g. mknod
1289 # makes sockets on Linux but not the BSDs/macOS/Solaris, and a single transfer
1290 # can write to filesystems with different capabilities. So rsync no longer
1291 # probes this at configure time (a run-test that also misfired when cross-
1292 # compiling); do_mknod*() just try mknod[at]() and, on failure, fall back to
1293 # mkfifo[at]()/socket+bind() per call. We only need the libc symbols, checked
1294 # above via AC_CHECK_FUNCS (mknod mknodat mkfifo mkfifoat) -- all link tests.
1295
1296 #
1297 # The following test was mostly taken from the tcl/tk plus patches
1298 #
1299 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
1300 rm -rf conftest*
1301 cat > conftest.$ac_ext <<EOF
1302 int main(void) { return 0; }
1303 EOF
1304 ${CC-cc} -c -o conftest..o conftest.$ac_ext
1305 if test -f conftest..o; then
1306 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
1307 else
1308 rsync_cv_DASHC_WORKS_WITH_DASHO=no
1309 fi
1310 rm -rf conftest*
1311 ])
1312 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
1313 OBJ_SAVE="#"
1314 OBJ_RESTORE="#"
1315 CC_SHOBJ_FLAG='-o $@'
1316 else
1317 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
1318 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'
1319 CC_SHOBJ_FLAG=""
1320 fi
1321
1322 AC_SUBST(OBJ_SAVE)
1323 AC_SUBST(OBJ_RESTORE)
1324 AC_SUBST(CC_SHOBJ_FLAG)
1325 AC_SUBST(BUILD_POPT)
1326 AC_SUBST(BUILD_ZLIB)
1327 AC_SUBST(MAKE_RRSYNC)
1328 AC_SUBST(MAKE_RRSYNC_1)
1329 AC_SUBST(GEN_RRSYNC)
1330 AC_SUBST(MAKE_MAN)
1331
1332 AC_CHECK_FUNCS(_acl __acl _facl __facl)
1333 #################################################
1334 # check for ACL support
1335
1336 AC_MSG_CHECKING([whether to support ACLs])
1337 AC_ARG_ENABLE(acl-support,
1338 AS_HELP_STRING([--disable-acl-support],[disable to omit ACL support]))
1339
1340 if test x"$enable_acl_support" = x"no"; then
1341 AC_MSG_RESULT(no)
1342 else
1343 case "$host_os" in
1344 *sysv5*)
1345 AC_MSG_RESULT(Using UnixWare ACLs)
1346 AC_DEFINE(HAVE_UNIXWARE_ACLS, 1, [true if you have UnixWare ACLs])
1347 AC_DEFINE(SUPPORT_ACLS, 1, [Define to 1 to add support for ACLs])
1348 ;;
1349 solaris*)
1350 AC_MSG_RESULT(Using solaris ACLs)
1351 AC_DEFINE(HAVE_SOLARIS_ACLS, 1, [true if you have solaris ACLs])
1352 AC_DEFINE(SUPPORT_ACLS, 1)
1353 ;;
1354 *irix*)
1355 AC_MSG_RESULT(Using IRIX ACLs)
1356 AC_DEFINE(HAVE_IRIX_ACLS, 1, [true if you have IRIX ACLs])
1357 AC_DEFINE(SUPPORT_ACLS, 1)
1358 ;;
1359 *aix*)
1360 AC_MSG_RESULT(Using AIX ACLs)
1361 AC_DEFINE(HAVE_AIX_ACLS, 1, [true if you have AIX ACLs])
1362 AC_DEFINE(SUPPORT_ACLS, 1)
1363 ;;
1364 *osf*)
1365 AC_MSG_RESULT(Using Tru64 ACLs)
1366 AC_DEFINE(HAVE_TRU64_ACLS, 1, [true if you have Tru64 ACLs])
1367 AC_DEFINE(SUPPORT_ACLS, 1)
1368 LIBS="$LIBS -lpacl"
1369 ;;
1370 darwin*)
1371 AC_MSG_RESULT(Using OS X ACLs)
1372 AC_DEFINE(HAVE_OSX_ACLS, 1, [true if you have Mac OS X ACLs])
1373 AC_DEFINE(SUPPORT_ACLS, 1)
1374 ;;
1375 *hpux*|*nsk*)
1376 AC_MSG_RESULT(Using HPUX ACLs)
1377 AC_DEFINE(HAVE_HPUX_ACLS, 1, [true if you have HPUX ACLs])
1378 AC_DEFINE(SUPPORT_ACLS, 1)
1379 ;;
1380 *)
1381 AC_MSG_RESULT(running tests:)
1382 AC_CHECK_LIB(acl,acl_get_file)
1383 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
1384 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1385 #ifdef HAVE_SYS_TYPES_H
1386 #include <sys/types.h>
1387 #endif
1388 #ifdef HAVE_SYS_ACL_H
1389 #include <sys/acl.h>
1390 #endif]], [[ 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])])
1391 AC_MSG_CHECKING(ACL test results)
1392 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
1393 AC_MSG_RESULT(Using posix ACLs)
1394 AC_DEFINE(HAVE_POSIX_ACLS, 1, [true if you have posix ACLs])
1395 AC_DEFINE(SUPPORT_ACLS, 1)
1396 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
1397 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1398 #ifdef HAVE_SYS_TYPES_H
1399 #include <sys/types.h>
1400 #endif
1401 #ifdef HAVE_SYS_ACL_H
1402 #include <sys/acl.h>
1403 #endif]], [[ 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])])
1404 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
1405 AC_DEFINE(HAVE_ACL_GET_PERM_NP, 1, [true if you have acl_get_perm_np])
1406 fi
1407 else
1408 if test x"$enable_acl_support" = x"yes"; then
1409 AC_MSG_ERROR(Failed to find ACL support)
1410 else
1411 AC_MSG_RESULT(No ACL support found)
1412 fi
1413 fi
1414 ;;
1415 esac
1416 fi
1417
1418 #################################################
1419 # check for extended attribute support
1420 AC_MSG_CHECKING(whether to support extended attributes)
1421 AC_ARG_ENABLE(xattr-support,
1422 AS_HELP_STRING([--disable-xattr-support],[disable to omit extended attributes]),
1423 [], [case "$ac_cv_func_getxattr$ac_cv_func_extattr_get_link$ac_cv_func_attropen" in
1424 *yes*) enable_xattr_support=maybe ;;
1425 *) enable_xattr_support=no ;;
1426 esac])
1427 AH_TEMPLATE([SUPPORT_XATTRS],
1428 [Define to 1 to add support for extended attributes])
1429 if test x"$enable_xattr_support" = x"no"; then
1430 AC_MSG_RESULT(no)
1431 else
1432 case "$host_os" in
1433 *linux*|*netbsd*|*cygwin*)
1434 AC_MSG_RESULT(Using Linux xattrs)
1435 AC_DEFINE(HAVE_LINUX_XATTRS, 1, [True if you have Linux xattrs (or equivalent)])
1436 AC_DEFINE(SUPPORT_XATTRS, 1)
1437 AC_DEFINE(NO_SYMLINK_USER_XATTRS, 1, [True if symlinks do not support user xattrs])
1438 AC_SEARCH_LIBS(getxattr,attr)
1439 ;;
1440 darwin*)
1441 AC_MSG_RESULT(Using OS X xattrs)
1442 AC_DEFINE(HAVE_OSX_XATTRS, 1, [True if you have Mac OS X xattrs])
1443 AC_DEFINE(SUPPORT_XATTRS, 1)
1444 AC_DEFINE(NO_DEVICE_XATTRS, 1, [True if device files do not support xattrs])
1445 AC_DEFINE(NO_SPECIAL_XATTRS, 1, [True if special files do not support xattrs])
1446 ;;
1447 freebsd*)
1448 AC_MSG_RESULT(Using FreeBSD extattrs)
1449 AC_DEFINE(HAVE_FREEBSD_XATTRS, 1, [True if you have FreeBSD xattrs])
1450 AC_DEFINE(SUPPORT_XATTRS, 1)
1451 ;;
1452 solaris*)
1453 AC_MSG_RESULT(Using Solaris xattrs)
1454 AC_DEFINE(HAVE_SOLARIS_XATTRS, 1, [True if you have Solaris xattrs])
1455 AC_DEFINE(SUPPORT_XATTRS, 1)
1456 AC_DEFINE(NO_SYMLINK_XATTRS, 1, [True if symlinks do not support xattrs])
1457 ;;
1458 *)
1459 if test x"$enable_xattr_support" = x"yes"; then
1460 AC_MSG_ERROR(Failed to find extended attribute support)
1461 else
1462 AC_MSG_RESULT(No extended attribute support found)
1463 fi
1464 ;;
1465 esac
1466 fi
1467
1468 #################################################
1469 # On Linux, POSIX ACLs are stored as the "system.posix_acl_{access,default}"
1470 # xattrs, so we can get/set them through a held O_NOFOLLOW fd (fsetxattr) or a
1471 # dirfd+leaf (setxattrat, AT_SYMLINK_NOFOLLOW) instead of the path-based libacl
1472 # acl_*_file() calls -- making the operation safe against a parent-symlink race.
1473 # This needs POSIX ACLs and the f/at xattr syscalls, which on Linux are
1474 # available whenever <sys/xattr.h> (or <attr/xattr.h>) is -- independent of the
1475 # -X feature (--disable-xattr-support), so we gate on the header, not
1476 # enable_xattr_support.
1477 AH_TEMPLATE([SUPPORT_ACL_FD],
1478 [Define to 1 to do POSIX ACL ops via fd/at xattr syscalls (lib/acl.c)])
1479 AH_TEMPLATE([HAVE_XATTRAT_SYSCALLS],
1480 [Define to 1 if the setxattrat/getxattrat/removexattrat syscalls are available])
1481 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes" \
1482 && { test x"$ac_cv_header_sys_xattr_h" = x"yes" || test x"$ac_cv_header_attr_xattr_h" = x"yes"; }; then
1483 case "$host_os" in
1484 *linux*)
1485 AC_DEFINE(SUPPORT_ACL_FD, 1)
1486 AC_CACHE_CHECK([for SYS_setxattrat],rsync_cv_have_sys_setxattrat,[
1487 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/syscall.h>
1488 #include <stdint.h>
1489 #ifdef HAVE_UNISTD_H
1490 #include <unistd.h>
1491 #endif
1492 struct xattr_args { uint64_t value; uint32_t size; uint32_t flags; };]],
1493 [[struct xattr_args a; a.value = 0; a.size = 0; a.flags = 0;
1494 syscall(SYS_setxattrat, 0, ".", 0, "n", &a, sizeof a);
1495 syscall(SYS_getxattrat, 0, ".", 0, "n", &a, sizeof a);
1496 syscall(SYS_removexattrat, 0, ".", 0, "n");]])],[rsync_cv_have_sys_setxattrat=yes],[rsync_cv_have_sys_setxattrat=no])])
1497 if test x"$rsync_cv_have_sys_setxattrat" = x"yes"; then
1498 AC_DEFINE(HAVE_XATTRAT_SYSCALLS, 1)
1499 fi
1500 ;;
1501 esac
1502 fi
1503
1504 #################################################
1505 # Detect a patched libacl providing the race-safe
1506 # *_at ACL entry points (acl_get_file_at/acl_set_file_at/acl_delete_def_file_at,
1507 # ACL_1.3, unreleased upstream). When present we route the race-safe ACL get/
1508 # set/delete through them on Linux -- race-safe on every kernel (6.13+ uses
1509 # *xattrat; older uses libacl's /proc/self/fd compat). A stock -lacl lacks these
1510 # symbols, so this stays undefined and the build falls back to lib/acl.c;
1511 # detection must therefore run against the patched lib (CPPFLAGS/LDFLAGS).
1512 AH_TEMPLATE([HAVE_LIBACL_AT],
1513 [Define to 1 if libacl provides acl_get_file_at/acl_set_file_at/acl_delete_def_file_at])
1514 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
1515 case "$host_os" in
1516 *linux*)
1517 AC_CHECK_LIB(acl, acl_get_file_at, [rsync_have_libacl_at=yes], [rsync_have_libacl_at=no])
1518 if test x"$rsync_have_libacl_at" = x"yes"; then
1519 AC_CHECK_FUNCS([acl_set_file_at acl_delete_def_file_at], [], [rsync_have_libacl_at=no])
1520 fi
1521 if test x"$rsync_have_libacl_at" = x"yes"; then
1522 AC_DEFINE(HAVE_LIBACL_AT, 1)
1523 fi
1524 ;;
1525 esac
1526 fi
1527
1528 if test x"$enable_acl_support" = x"no" || test x"$enable_xattr_support" = x"no" || test x"$enable_iconv" = x"no"; then
1529 AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
1530 OLD_CFLAGS="$CFLAGS"
1531 CFLAGS="$CFLAGS -Wno-unused-parameter"
1532 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[printf("hello\n");]])],[rsync_warn_flag=yes],[rsync_warn_flag=no])
1533 AC_MSG_RESULT([$rsync_warn_flag])
1534 if test x"$rsync_warn_flag" = x"no"; then
1535 CFLAGS="$OLD_CFLAGS"
1536 fi
1537 fi
1538
1539 case "$CC" in
1540 ' checker'*|checker*)
1541 AC_DEFINE(FORCE_FD_ZERO_MEMSET, 1, [Used to make "checker" understand that FD_ZERO() clears memory.])
1542 ;;
1543 esac
1544
1545 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
1546 AC_OUTPUT
1547
1548 AC_MSG_RESULT()
1549 AC_MSG_RESULT([ rsync $PACKAGE_VERSION configuration successful])
1550 AC_MSG_RESULT()