Debian Codegraph @

configure.ac

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