Check to see if we need to include the iconv library.
[rsync/rsync.git] / configure.in
CommitLineData
c627d613 1dnl Process this file with autoconf to produce a configure script.
06963d0f 2
bf5c2bf6
MP
3AC_INIT()
4AC_CONFIG_SRCDIR([byteorder.h])
c627d613 5AC_CONFIG_HEADER(config.h)
e32db5c9 6AC_PREREQ(2.59)
c627d613 7
f11ece28 8RSYNC_VERSION=2.6.7cvs
68b2cc55
MP
9AC_SUBST(RSYNC_VERSION)
10AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
11
12AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
13
6a48ca56 14LDFLAGS=${LDFLAGS-""}
50abd20b 15
bf5c2bf6
MP
16AC_CANONICAL_TARGET([])
17
18dnl Checks for programs.
19AC_PROG_CC
20AC_PROG_CPP
bbfb1d01 21AC_PROG_EGREP
bf5c2bf6 22AC_PROG_INSTALL
68b2cc55 23AC_PROG_CC_STDC
bf5c2bf6 24AC_SUBST(SHELL)
8de330a3 25
70ed474b
MP
26AC_DEFINE([_GNU_SOURCE], 1,
27 [Define _GNU_SOURCE so that we get all necessary prototypes])
28
79f48760 29if test x"$ac_cv_prog_cc_stdc" = x"no"; then
68b2cc55
MP
30 AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
31fi
a358449a 32
03b1cddc 33# We must decide this before testing the compiler.
2d1ebe9c 34
47759343
MP
35# Please allow this to default to yes, so that your users have more
36# chance of getting a useful stack trace if problems occur.
37
bf5c2bf6 38AC_MSG_CHECKING([whether to include debugging symbols])
2d1ebe9c 39AC_ARG_ENABLE(debug,
79f48760
WD
40 AC_HELP_STRING([--disable-debug],
41 [turn off debugging symbols and features]))
2d1ebe9c 42
79f48760 43if test x"$enable_debug" = x"no"; then
2d1ebe9c
MP
44 AC_MSG_RESULT(no)
45 CFLAGS=${CFLAGS-"-O"}
bf5c2bf6
MP
46else
47 AC_MSG_RESULT([yes])
48 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
23bf32f7 49 dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
bf5c2bf6 50 dnl CFLAGS=${CFLAGS-"-g"}
2d1ebe9c
MP
51fi
52
da7b6397 53
da7b6397 54AC_ARG_ENABLE(profile,
c83a2c8e 55 AC_HELP_STRING([--enable-profile],
79f48760
WD
56 [turn on CPU profiling]))
57if test x"$enable_profile" = x"yes"; then
da7b6397
MP
58 CFLAGS="$CFLAGS -pg"
59fi
60
61
c0531332
MP
62# Specifically, this turns on panic_action handling.
63AC_ARG_ENABLE(maintainer-mode,
c83a2c8e 64 AC_HELP_STRING([--enable-maintainer-mode],
79f48760
WD
65 [turn on extra debug features]))
66if test x"$enable_maintainer_mode" = x"yes"; then
c0531332
MP
67 CFLAGS="$CFLAGS -DMAINTAINER_MODE"
68fi
69
70
da7b6397
MP
71# This is needed for our included version of popt. Kind of silly, but
72# I don't want our version too far out of sync.
1ac15cd8
MP
73CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
74
47759343 75# If GCC, turn on warnings.
79f48760 76if test x"$GCC" = x"yes"; then
99f106d1 77 CFLAGS="$CFLAGS -Wall -W"
47759343
MP
78fi
79
2d1ebe9c 80AC_ARG_WITH(included-popt,
d64c2b22 81 AC_HELP_STRING([--with-included-popt], [use bundled popt library, not from system]))
2d1ebe9c 82
41bd28fe 83AC_ARG_WITH(rsync-path,
d64c2b22 84 AC_HELP_STRING([--with-rsync-path=PATH], [set default --rsync-path to PATH (default: rsync)]),
8642efd0 85 [ RSYNC_PATH="$with_rsync_path" ],
41bd28fe 86 [ RSYNC_PATH="rsync" ])
81c652d5
MP
87
88AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
89
cd3fe9fb
WD
90AC_ARG_WITH(rsyncd-conf,
91 AC_HELP_STRING([--with-rsyncd-conf=PATH], [set configuration file for rsync server to PATH (default: /etc/rsyncd.conf)]),
92 [ if test ! -z "$with_rsyncd_conf" ; then
93 case $with_rsyncd_conf in
94 yes|no)
95 RSYNCD_SYSCONF="/etc/rsyncd.conf"
96 ;;
97 /*)
98 RSYNCD_SYSCONF="$with_rsyncd_conf"
99 ;;
100 *)
101 AC_MSG_ERROR(You must specify an absolute path to --with-rsyncd-conf=PATH)
102 ;;
103 esac
104 else
105 RSYNCD_SYSCONF="/etc/rsyncd.conf"
106 fi ],
107 [ RSYNCD_SYSCONF="/etc/rsyncd.conf" ])
108
109AC_DEFINE_UNQUOTED(RSYNCD_SYSCONF, "$RSYNCD_SYSCONF", [location of configuration file for rsync server])
110
81c652d5 111AC_ARG_WITH(rsh,
f40f2fc8 112 AC_HELP_STRING([--with-rsh=CMD], [set remote shell command to CMD (default: ssh)]))
41bd28fe 113
7b8356d0 114AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
89ec535a
WD
115if test x$HAVE_REMSH = x1; then
116 AC_DEFINE(HAVE_REMSH, 1, [Define to 1 if remote shell is remsh, not rsh])
117fi
81c652d5 118
79f48760 119if test x"$with_rsh" != x; then
81c652d5 120 RSYNC_RSH="$with_rsh"
81c652d5 121else
f40f2fc8 122 RSYNC_RSH="ssh"
81c652d5 123fi
81c652d5 124AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
f0af1e5e 125
58418cb0
WD
126AC_MSG_CHECKING([the group for user "nobody"])
127if grep '^nobody:' /etc/group >/dev/null 2>&1; then
128 NOBODY_GROUP=nobody
129elif grep '^nogroup:' /etc/group >/dev/null 2>&1; then
130 NOBODY_GROUP=nogroup
131else
132 NOBODY_GROUP=nobody # test for others?
133fi
134AC_MSG_RESULT($NOBODY_GROUP)
135AC_DEFINE_UNQUOTED(NOBODY_USER, "nobody", [unprivileged user--e.g. nobody])
136AC_DEFINE_UNQUOTED(NOBODY_GROUP, "$NOBODY_GROUP", [unprivileged group for unprivileged user])
137
03e23e07 138# arrgh. libc in some old debian version screwed up the largefile
f0af1e5e
AT
139# stuff, getting byte range locking wrong
140AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
141AC_TRY_RUN([
142#define _FILE_OFFSET_BITS 64
143#include <stdio.h>
144#include <fcntl.h>
145#include <sys/types.h>
146#include <sys/wait.h>
147
2ef2e822 148int main(void)
f0af1e5e
AT
149{
150 struct flock lock;
9eac94a4
WD
151 int status;
152 char tpl[32] = "/tmp/locktest.XXXXXX";
153 int fd = mkstemp(tpl);
154 if (fd < 0) {
155 strcpy(tpl, "conftest.dat");
156 fd = open(tpl, O_CREAT|O_RDWR, 0600);
157 }
158
f0af1e5e
AT
159 lock.l_type = F_WRLCK;
160 lock.l_whence = SEEK_SET;
161 lock.l_start = 0;
162 lock.l_len = 1;
163 lock.l_pid = 0;
f0af1e5e
AT
164 fcntl(fd,F_SETLK,&lock);
165 if (fork() == 0) {
9eac94a4
WD
166 lock.l_start = 1;
167 _exit(fcntl(fd,F_SETLK,&lock) == 0);
168 }
169 wait(&status);
170 unlink(tpl);
f0af1e5e
AT
171 exit(WEXITSTATUS(status));
172}
173],
174rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
175if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
176 AC_SYS_LARGEFILE
177fi
178
06963d0f
MP
179ipv6type=unknown
180ipv6lib=none
22cd0063 181ipv6trylibc=yes
06963d0f 182
2ef2e822 183AC_ARG_ENABLE(ipv6,
79f48760
WD
184 AC_HELP_STRING([--disable-ipv6],
185 [don't even try to use IPv6]))
186if test x"$enable_ipv6" != x"no"; then
06963d0f
MP
187 AC_MSG_CHECKING([ipv6 stack type])
188 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
189 case $i in
190 inria)
191 # http://www.kame.net/
192 AC_EGREP_CPP(yes, [
193#include <netinet/in.h>
194#ifdef IPV6_INRIA_VERSION
195yes
196#endif],
197 [ipv6type=$i;
a358449a
MP
198 AC_DEFINE(INET6, 1, [true if you have IPv6])
199 ])
06963d0f
MP
200 ;;
201 kame)
202 # http://www.kame.net/
203 AC_EGREP_CPP(yes, [
204#include <netinet/in.h>
205#ifdef __KAME__
206yes
207#endif],
2ef2e822 208 [ipv6type=$i;
a358449a 209 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
210 ;;
211 linux-glibc)
212 # http://www.v6.linux.or.jp/
213 AC_EGREP_CPP(yes, [
214#include <features.h>
215#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
216yes
217#endif],
218 [ipv6type=$i;
a358449a 219AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
220 ;;
221 linux-inet6)
222 # http://www.v6.linux.or.jp/
223 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
224 ipv6type=$i
225 ipv6lib=inet6
226 ipv6libdir=/usr/inet6/lib
227 ipv6trylibc=yes;
a358449a
MP
228 AC_DEFINE(INET6, 1, [true if you have IPv6])
229 CFLAGS="-I/usr/inet6/include $CFLAGS"
06963d0f
MP
230 fi
231 ;;
232 toshiba)
233 AC_EGREP_CPP(yes, [
234#include <sys/param.h>
235#ifdef _TOSHIBA_INET6
236yes
237#endif],
238 [ipv6type=$i;
239 ipv6lib=inet6;
240 ipv6libdir=/usr/local/v6/lib;
a358449a 241 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
242 ;;
243 v6d)
244 AC_EGREP_CPP(yes, [
245#include </usr/local/v6/include/sys/v6config.h>
246#ifdef __V6D__
247yes
248#endif],
249 [ipv6type=$i;
250 ipv6lib=v6;
251 ipv6libdir=/usr/local/v6/lib;
a358449a 252 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
253 ;;
254 zeta)
255 AC_EGREP_CPP(yes, [
256#include <sys/param.h>
257#ifdef _ZETA_MINAMI_INET6
258yes
259#endif],
260 [ipv6type=$i;
261 ipv6lib=inet6;
262 ipv6libdir=/usr/local/v6/lib;
a358449a 263 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
264 ;;
265 esac
266 if test "$ipv6type" != "unknown"; then
267 break
268 fi
269 done
270 AC_MSG_RESULT($ipv6type)
06963d0f 271
17d5a07e
MP
272 AC_SEARCH_LIBS(getaddrinfo, inet6)
273fi
06963d0f 274
79f48760
WD
275dnl Do you want to disable use of locale functions
276AC_ARG_ENABLE([locale],
277 AC_HELP_STRING([--disable-locale],
278 [turn off locale features]))
279AH_TEMPLATE([CONFIG_LOCALE],
280[Undefine if you don't want locale features. By default this is defined.])
281if test x"$enable_locale" != x"no"; then
282 AC_DEFINE(CONFIG_LOCALE)
283fi
284
9f639210
DD
285AC_MSG_CHECKING([whether to call shutdown on all sockets])
286case $host_os in
287 *cygwin* ) AC_MSG_RESULT(yes)
2ef2e822 288 AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1,
0d2aa5d9 289 [Define to 1 if sockets need to be shutdown])
8ed16deb
DD
290 ;;
291 * ) AC_MSG_RESULT(no);;
292esac
293
cd957c70 294AC_C_BIGENDIAN
c627d613 295AC_HEADER_DIRENT
c627d613
AT
296AC_HEADER_TIME
297AC_HEADER_SYS_WAIT
1cb6f3bf
WD
298AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
299 unistd.h utime.h grp.h compat.h sys/param.h ctype.h sys/wait.h \
300 sys/ioctl.h sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h \
f5c7f4ab 301 sys/un.h glob.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
03e23e07 302 netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h)
3c3791e8 303AC_HEADER_MAJOR
c627d613
AT
304
305AC_CHECK_SIZEOF(int)
306AC_CHECK_SIZEOF(long)
e32db5c9 307AC_CHECK_SIZEOF(long long)
c627d613 308AC_CHECK_SIZEOF(short)
e32db5c9
WD
309AC_CHECK_SIZEOF(off_t)
310AC_CHECK_SIZEOF(off64_t)
c627d613
AT
311
312AC_C_INLINE
a6c15e9a 313AC_C_LONG_DOUBLE
c627d613
AT
314
315AC_TYPE_SIGNAL
316AC_TYPE_UID_T
317AC_TYPE_MODE_T
318AC_TYPE_OFF_T
319AC_TYPE_SIZE_T
320AC_TYPE_PID_T
9422bb3f 321AC_TYPE_GETGROUPS
bf5c2bf6
MP
322AC_CHECK_MEMBERS([struct stat.st_rdev])
323
7ca6e856 324TYPE_SOCKLEN_T
c627d613 325
7b3d4257 326AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
7597e1a9 327 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
7b3d4257
AT
328 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
329if test x"$rsync_cv_errno" = x"yes"; then
0d2aa5d9 330 AC_DEFINE(HAVE_ERRNO_DECL, 1, [Define to 1 if errno is declared in errno.h])
7597e1a9 331fi
c627d613 332
a784e10d
DD
333# The following test taken from the cvs sources
334# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
335# These need checks to be before checks for any other functions that
336# might be in the same libraries.
337# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
338# libsocket.so which has a bad implementation of gethostbyname (it
339# only looks in /etc/hosts), so we only look for -lsocket if we need
340# it.
341AC_CHECK_FUNCS(connect)
342if test x"$ac_cv_func_connect" = x"no"; then
343 case "$LIBS" in
344 *-lnsl*) ;;
345 *) AC_CHECK_LIB(nsl_s, printf) ;;
346 esac
347 case "$LIBS" in
348 *-lnsl*) ;;
349 *) AC_CHECK_LIB(nsl, printf) ;;
350 esac
351 case "$LIBS" in
352 *-lsocket*) ;;
353 *) AC_CHECK_LIB(socket, connect) ;;
354 esac
355 case "$LIBS" in
356 *-linet*) ;;
357 *) AC_CHECK_LIB(inet, connect) ;;
358 esac
359 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
360 dnl has been cached.
2ef2e822 361 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
a784e10d
DD
362 test x"$ac_cv_lib_inet_connect" = x"yes"; then
363 # ac_cv_func_connect=yes
364 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
0d2aa5d9 365 AC_DEFINE(HAVE_CONNECT, 1, [Define to 1 if you have the "connect" function])
a784e10d
DD
366 fi
367fi
368
10a1d6b4 369AC_SEARCH_LIBS(inet_ntop, resolv)
bd4576fe 370AC_SEARCH_LIBS(iconv_open, iconv)
8f694072 371
99f106d1 372dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
e94989fe 373
2ef2e822
WD
374AC_CHECK_FUNCS(inet_ntop, , [AC_LIBOBJ(lib/inet_ntop)])
375AC_CHECK_FUNCS(inet_pton, , [AC_LIBOBJ(lib/inet_pton)])
356bbb83 376
824f1c79
DD
377# Irix 6.5 has getaddrinfo but not the corresponding defines, so use
378# builtin getaddrinfo if one of the defines don't exist
184dede9
DD
379AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
380 rsync_cv_HAVE_GETADDR_DEFINES,[
381 AC_EGREP_CPP(yes, [
382 #include <sys/types.h>
383 #include <sys/socket.h>
384 #include <netdb.h>
385 #ifdef AI_PASSIVE
386 yes
2ef2e822 387 #endif],
184dede9
DD
388 rsync_cv_HAVE_GETADDR_DEFINES=yes,
389 rsync_cv_HAVE_GETADDR_DEFINES=no)])
390if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
824f1c79
DD
391 # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
392 # something else so we must include <netdb.h> to get the
393 # redefinition.
394 AC_CHECK_FUNCS(getaddrinfo, ,
395 [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
396 AC_TRY_LINK([#include <sys/types.h>
397 #include <sys/socket.h>
398 #include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
399 [AC_MSG_RESULT([yes])
400 AC_DEFINE(HAVE_GETADDRINFO, 1,
0d2aa5d9 401 [Define to 1 if you have the "getaddrinfo" function.])],
824f1c79
DD
402 [AC_MSG_RESULT([no])
403 AC_LIBOBJ(lib/getaddrinfo)])])
2ef2e822 404 AC_CHECK_FUNCS(getnameinfo, , [AC_LIBOBJ(lib/getnameinfo)])
184dede9 405else
d2cc0323 406 AC_LIBOBJ(lib/getaddrinfo)
184dede9
DD
407 AC_LIBOBJ(lib/getnameinfo)
408fi
824f1c79 409
2ef2e822 410AC_CHECK_MEMBER([struct sockaddr.sa_len],
b4b90120 411 [ AC_DEFINE(HAVE_SOCKADDR_LEN, 1, [Do we have sockaddr.sa_len?]) ],
0042f818
WD
412 [],
413 [
414#include <sys/types.h>
415#include <sys/socket.h>
416])
417
b4b90120
WD
418AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
419 [ AC_DEFINE(HAVE_SOCKADDR_IN_LEN, 1, [Do we have sockaddr_in.sin_len?]) ],
356bbb83
MP
420 [],
421 [
422#include <sys/types.h>
423#include <sys/socket.h>
b4b90120 424#include <netinet/in.h>
356bbb83
MP
425])
426
e49d7200
WD
427AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
428 [ AC_DEFINE(HAVE_SOCKADDR_UN_LEN, 1, [Do we have sockaddr_un.sun_len?]) ],
429 [],
430 [
431#include <sys/types.h>
432#include <sys/socket.h>
433#include <netinet/in.h>
434])
435
2d6dbe29
MP
436AC_MSG_CHECKING(struct sockaddr_storage)
437AC_TRY_COMPILE([#include <sys/types.h>
438#include <sys/socket.h>],
439[struct sockaddr_storage x;],
440 AC_MSG_RESULT(yes)
2ef2e822 441 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
0d2aa5d9 442 [Define to 1 if you have struct sockaddr_storage.] ),
2d6dbe29
MP
443 AC_MSG_RESULT(no))
444
bc2b4963 445AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
a1d8f29a 446 [ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID, 1, [Do we have sockaddr_in6.sin6_scope_id?]) ],
bc2b4963
DD
447 [],
448 [
449#include <sys/types.h>
450#include <sys/socket.h>
451#include <netinet/in.h>
452])
453
c83a2c8e
WD
454AC_MSG_CHECKING(struct stat64)
455AC_TRY_COMPILE([#include <stdio.h>
456#if HAVE_SYS_TYPES_H
457# include <sys/types.h>
458#endif
459#if HAVE_SYS_STAT_H
460# include <sys/stat.h>
461#endif
462#if STDC_HEADERS
463# include <stdlib.h>
464# include <stddef.h>
465#else
466# if HAVE_STDLIB_H
467# include <stdlib.h>
468# endif
469#endif
470],[struct stat64 st;],
471 AC_MSG_RESULT(yes)
472 AC_DEFINE(HAVE_STRUCT_STAT64,1,[Define to 1 if you have struct stat64.]),
473 AC_MSG_RESULT(no))
474
a784e10d
DD
475# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
476#
477AC_CHECK_FUNCS(strcasecmp)
478if test x"$ac_cv_func_strcasecmp" = x"no"; then
479 AC_CHECK_LIB(resolv, strcasecmp)
480fi
481
87fcb639
MP
482dnl At the moment we don't test for a broken memcmp(), because all we
483dnl need to do is test for equality, not comparison, and it seems that
2ef2e822 484dnl every platform has a memcmp that can do at least that.
87fcb639
MP
485dnl AC_FUNC_MEMCMP
486
c627d613 487AC_FUNC_UTIME_NULL
7fc08908 488AC_FUNC_ALLOCA
8ce65463
WD
489AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
490 fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
f18d87b6 491 memmove lchown vsnprintf snprintf vasprintf asprintf setsid glob strpbrk \
84e1a698 492 strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
8ce65463 493 setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
12c8cd02 494 strerror putenv iconv_open locale_charset nl_langinfo \
d81894fc 495 sigaction sigprocmask)
24c857f1 496
21524e30
WD
497AC_CHECK_FUNCS(getpgrp tcgetpgrp)
498if test $ac_cv_func_getpgrp = yes; then
499 AC_FUNC_GETPGRP
500fi
501
502# Determine whether chown follows symlinks (it should).
503AC_CACHE_CHECK([whether chown() dereferences symlinks],rsync_cv_chown_follows_symlink,[
504 AC_TRY_RUN([
505#if HAVE_UNISTD_H
506# include <unistd.h>
507#endif
508#include <stdlib.h>
509#include <errno.h>
510 main() {
511 char const *dangling_symlink = "conftest.dangle";
512 unlink(dangling_symlink);
513 if (symlink("conftest.no-such", dangling_symlink) < 0) abort();
514 if (chown(dangling_symlink, getuid(), getgid()) < 0 && errno == ENOENT) exit(0);
515 exit(1);
516 }],
c61ba345 517 rsync_cv_chown_follows_symlink=yes,rsync_cv_chown_follows_symlink=no,rsync_cv_chown_follows_symlink=yes)])
21524e30 518if test $rsync_cv_chown_follows_symlink = no; then
0d2aa5d9 519 AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1, [Define to 1 if chown modifies symlinks.])
21524e30
WD
520fi
521
24c857f1 522AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
6a5ef41f
MP
523AC_TRY_RUN([
524#include <sys/types.h>
525#include <sys/socket.h>
526
527main() {
528 int fd[2];
529 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
530}],
24c857f1
DD
531rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
532if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
0d2aa5d9 533 AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define to 1 if you have the "socketpair" function])
24c857f1 534fi
c627d613 535
79f48760 536if test x"$with_included_popt" != x"yes"; then
1ac15cd8
MP
537 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
538fi
2d1ebe9c 539
12458878 540AC_MSG_CHECKING([whether to use included libpopt])
79f48760 541if test x"$with_included_popt" = x"yes"; then
12458878 542 AC_MSG_RESULT($srcdir/popt)
1ac15cd8 543 BUILD_POPT='$(popt_OBJS)'
26ef00bd 544 CFLAGS="$CFLAGS -I$srcdir/popt"
5216de37 545 if test x"$ALLOCA" != x
7fc08908 546 then
5216de37
DD
547 # this can be removed when/if we add an included alloca.c;
548 # see autoconf documentation on AC_FUNC_ALLOCA
8af534a5 549 AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
7fc08908 550 fi
2d1ebe9c
MP
551else
552 AC_MSG_RESULT(no)
79fc6bdb 553fi
c627d613 554
0d2aa5d9
WD
555AC_CACHE_CHECK([for unsigned char],rsync_cv_SIGNED_CHAR_OK,[
556AC_TRY_COMPILE([],[signed char *s = ""],
557rsync_cv_SIGNED_CHAR_OK=yes,rsync_cv_SIGNED_CHAR_OK=no)])
558if test x"$rsync_cv_SIGNED_CHAR_OK" = x"yes"; then
559 AC_DEFINE(SIGNED_CHAR_OK, 1, [Define to 1 if "signed char" is a valid type])
7597e1a9 560fi
bcacc18b 561
7b3d4257 562AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
59503278
AT
563AC_TRY_RUN([#include <sys/types.h>
564#include <dirent.h>
565main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
566if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
7597e1a9 567di->d_name[0] == 0) exit(0); exit(1);} ],
7b3d4257
AT
568rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
569if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
0d2aa5d9 570 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [Define to 1 if readdir() is broken])
7597e1a9 571fi
1e9f155a 572
7b3d4257 573AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
d6e6ecbd
AT
574AC_TRY_COMPILE([#include <sys/types.h>
575#include <utime.h>],
7597e1a9 576[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
0d2aa5d9 577rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no)])
7b3d4257 578if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
0d2aa5d9 579 AC_DEFINE(HAVE_UTIMBUF, 1, [Define to 1 if you have the "struct utimbuf" type])
7597e1a9 580fi
d6e6ecbd 581
3060d4aa 582AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
0d2aa5d9
WD
583AC_TRY_COMPILE([#include <sys/time.h>
584#include <unistd.h>],
585[struct timeval tv; exit(gettimeofday(&tv, NULL));],
586rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no)])
a20a88d2 587if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" != x"no"; then
0d2aa5d9 588 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [Define to 1 if gettimeofday() takes a time-zone arg])
3060d4aa
AT
589fi
590
8950ac03
AT
591AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
592AC_TRY_RUN([
593#include <sys/types.h>
594#include <stdarg.h>
2ef2e822 595void foo(const char *format, ...) {
8950ac03
AT
596 va_list ap;
597 int len;
598 char buf[5];
599
600 va_start(ap, format);
601 len = vsnprintf(0, 0, format, ap);
602 va_end(ap);
603 if (len != 5) exit(1);
604
605 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
606
607 exit(0);
608}
609main() { foo("hello"); }
610],
611rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
612if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
0d2aa5d9 613 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [Define to 1 if vsprintf has a C99-compatible return value])
8950ac03
AT
614fi
615
616
f62c17e3
AT
617AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
618AC_TRY_RUN([#include <stdlib.h>
619#include <sys/types.h>
620#include <sys/stat.h>
621#include <unistd.h>
2ef2e822 622main() {
f62c17e3 623 struct stat st;
2ef2e822
WD
624 char tpl[20]="/tmp/test.XXXXXX";
625 int fd = mkstemp(tpl);
f62c17e3
AT
626 if (fd == -1) exit(1);
627 unlink(tpl);
628 if (fstat(fd, &st) != 0) exit(1);
629 if ((st.st_mode & 0777) != 0600) exit(1);
630 exit(0);
631}],
632rsync_cv_HAVE_SECURE_MKSTEMP=yes,
633rsync_cv_HAVE_SECURE_MKSTEMP=no,
634rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
635if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
5f2c5bf1
WD
636 case $target_os in
637 hpux*)
638 dnl HP-UX has a broken mkstemp() implementation they refuse to fix,
639 dnl so we noisily skip using it. See HP change request JAGaf34426
640 dnl for details. (sbonds)
641 AC_MSG_WARN(Skipping broken HP-UX mkstemp() -- using mktemp() instead)
642 ;;
643 *)
644 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [Define to 1 if mkstemp() is available and works right])
645 ;;
646 esac
f62c17e3
AT
647fi
648
3060d4aa 649
7b3d4257
AT
650AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
651AC_TRY_RUN([
652#include <stdio.h>
653#include <sys/types.h>
654#include <netinet/in.h>
655#include <arpa/inet.h>
656main() { struct in_addr ip; ip.s_addr = 0x12345678;
657if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2ef2e822 658 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
fca3ef06
AT
659exit(0);}],
660 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
7b3d4257 661if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
0d2aa5d9 662 AC_DEFINE(REPLACE_INET_NTOA, 1, [Define to 1 if inet_ntoa() needs to be replaced])
7b3d4257
AT
663fi
664
fca3ef06
AT
665
666AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
667AC_TRY_RUN([
668#include <stdio.h>
669#include <sys/types.h>
670#include <netinet/in.h>
671#include <arpa/inet.h>
2ef2e822 672main() { struct in_addr ip;
fca3ef06
AT
673if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
674 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
675if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
0d2aa5d9 676 AC_DEFINE(REPLACE_INET_ATON, 1, [Define to 1 if inet_aton() needs to be replaced])
fca3ef06
AT
677fi
678
e49d7200
WD
679AC_CACHE_CHECK([if mknod creates FIFOs],rsync_cv_MKNOD_CREATES_FIFOS,[
680AC_TRY_RUN([
681#include <stdio.h>
682#include <sys/stat.h>
683#include <errno.h>
684main() { int rc, ec; char *fn = "fifo-test";
685unlink(fn); rc = mknod(fn,S_IFIFO,0600); ec = errno; unlink(fn);
12a01be1 686if (rc) {printf("(%d %d) ",rc,ec); return ec;}
e49d7200
WD
687return 0;}],
688 rsync_cv_MKNOD_CREATES_FIFOS=yes,rsync_cv_MKNOD_CREATES_FIFOS=no,rsync_cv_MKNOD_CREATES_FIFOS=cross)])
689if test x"$rsync_cv_MKNOD_CREATES_FIFOS" = x"yes"; then
690 AC_DEFINE(MKNOD_CREATES_FIFOS, 1, [Define to 1 if mknod() can create FIFOs.])
691fi
692
693AC_CACHE_CHECK([if mknod creates sockets],rsync_cv_MKNOD_CREATES_SOCKETS,[
694AC_TRY_RUN([
695#include <stdio.h>
696#include <sys/stat.h>
697#include <errno.h>
698main() { int rc, ec; char *fn = "sock-test";
699unlink(fn); rc = mknod(fn,S_IFSOCK,0600); ec = errno; unlink(fn);
12a01be1 700if (rc) {printf("(%d %d) ",rc,ec); return ec;}
e49d7200
WD
701return 0;}],
702 rsync_cv_MKNOD_CREATES_SOCKETS=yes,rsync_cv_MKNOD_CREATES_SOCKETS=no,rsync_cv_MKNOD_CREATES_SOCKETS=cross)])
703if test x"$rsync_cv_MKNOD_CREATES_SOCKETS" = x"yes"; then
704 AC_DEFINE(MKNOD_CREATES_SOCKETS, 1, [Define to 1 if mknod() can create sockets.])
705fi
706
692da0b5
DD
707#
708# The following test was mostly taken from the tcl/tk plus patches
709#
79fc6bdb 710AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
692da0b5
DD
711rm -rf conftest*
712cat > conftest.$ac_ext <<EOF
713int main() { return 0; }
714EOF
715${CC-cc} -c -o conftest..o conftest.$ac_ext
716if test -f conftest..o; then
79fc6bdb
DD
717 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
718else
719 rsync_cv_DASHC_WORKS_WITH_DASHO=no
720fi
721rm -rf conftest*
722])
723if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
692da0b5
DD
724 OBJ_SAVE="#"
725 OBJ_RESTORE="#"
726 CC_SHOBJ_FLAG='-o $@'
692da0b5
DD
727else
728 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
729 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'
730 CC_SHOBJ_FLAG=""
692da0b5 731fi
79fc6bdb 732
692da0b5
DD
733AC_SUBST(OBJ_SAVE)
734AC_SUBST(OBJ_RESTORE)
735AC_SUBST(CC_SHOBJ_FLAG)
1ac15cd8 736AC_SUBST(BUILD_POPT)
7d29d4ba 737
bf5c2bf6
MP
738AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
739AC_OUTPUT
a4677968
MP
740
741AC_MSG_RESULT()
742AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])
743AC_MSG_RESULT()