Make setgroups(0,0) unconditional -- accidentally thinking we have
[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)
7ca6e856 6AC_PREREQ(2.52)
c627d613 7
7583ded8 8RSYNC_VERSION=2.5.3pre2
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
21AC_PROG_INSTALL
68b2cc55 22AC_PROG_CC_STDC
bf5c2bf6 23AC_SUBST(SHELL)
8de330a3 24
70ed474b
MP
25AC_DEFINE([_GNU_SOURCE], 1,
26 [Define _GNU_SOURCE so that we get all necessary prototypes])
27
68b2cc55
MP
28if test "$xac_cv_prog_cc_stdc" = xno
29then
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,
bf5c2bf6
MP
40 AC_HELP_STRING([--enable-debug],
41 [including debugging symbols and features (default yes)]),
42 [], [])
2d1ebe9c 43
bf5c2bf6 44if test x"$enable_debug" = x"no"
2d1ebe9c 45then
2d1ebe9c
MP
46 AC_MSG_RESULT(no)
47 CFLAGS=${CFLAGS-"-O"}
bf5c2bf6
MP
48else
49 AC_MSG_RESULT([yes])
50 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
23bf32f7 51 dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
bf5c2bf6 52 dnl CFLAGS=${CFLAGS-"-g"}
2d1ebe9c
MP
53fi
54
da7b6397
MP
55
56
57
58AC_ARG_ENABLE(profile,
59 AC_HELP_STRING([--enable-profile],
60 [turn on CPU profiling (default no)],
61 [], []))
62if test x"$enable_profile" = xyes
63then
64 CFLAGS="$CFLAGS -pg"
65fi
66
67
68# This is needed for our included version of popt. Kind of silly, but
69# I don't want our version too far out of sync.
1ac15cd8
MP
70CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
71
47759343
MP
72# If GCC, turn on warnings.
73if test "x$GCC" = "xyes"
74then
99f106d1 75 CFLAGS="$CFLAGS -Wall -W"
47759343
MP
76fi
77
2d1ebe9c
MP
78AC_ARG_WITH(included-popt,
79 [ --with-included-popt use bundled popt library, not from system])
80
41bd28fe 81AC_ARG_WITH(rsync-path,
ddd491d4 82 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
8642efd0 83 [ RSYNC_PATH="$with_rsync_path" ],
41bd28fe 84 [ RSYNC_PATH="rsync" ])
81c652d5
MP
85
86AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
87
88AC_ARG_WITH(rsh,
89 AC_HELP_STRING([--with-rsh=CMD], [set rsh command to CMD (default: \"remsh\" or \"rsh\")]))
41bd28fe 90
7b8356d0 91AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
81c652d5
MP
92AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [remote shell is remsh not rsh])
93
94if test x"$with_rsh" != x
95then
96 RSYNC_RSH="$with_rsh"
97elif test x"$HAVE_REMSH" = x1
98then
99 RSYNC_RSH="remsh"
100else
101 RSYNC_RSH="rsh"
102fi
7b8356d0 103
81c652d5 104AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
f0af1e5e
AT
105
106# arrgh. libc in the current debian stable screws up the largefile
107# stuff, getting byte range locking wrong
108AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
109AC_TRY_RUN([
110#define _FILE_OFFSET_BITS 64
111#include <stdio.h>
112#include <fcntl.h>
113#include <sys/types.h>
114#include <sys/wait.h>
115
116int main(void)
117{
118 struct flock lock;
119 int status;
120 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
121 lock.l_type = F_WRLCK;
122 lock.l_whence = SEEK_SET;
123 lock.l_start = 0;
124 lock.l_len = 1;
125 lock.l_pid = 0;
126
127 fcntl(fd,F_SETLK,&lock);
128 if (fork() == 0) {
129 lock.l_start = 1;
130 exit(fcntl(fd,F_SETLK,&lock) == 0);
131 }
132 wait(&status);
133 unlink("conftest.dat");
134 exit(WEXITSTATUS(status));
135}
136],
137rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
138if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
139 AC_SYS_LARGEFILE
140fi
141
06963d0f
MP
142ipv6type=unknown
143ipv6lib=none
22cd0063 144ipv6trylibc=yes
06963d0f 145
17d5a07e
MP
146AC_ARG_ENABLE(ipv6,
147 AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
148
149if test "x$enable_ipv6" != xno
150then
06963d0f
MP
151 AC_MSG_CHECKING([ipv6 stack type])
152 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
153 case $i in
154 inria)
155 # http://www.kame.net/
156 AC_EGREP_CPP(yes, [
157#include <netinet/in.h>
158#ifdef IPV6_INRIA_VERSION
159yes
160#endif],
161 [ipv6type=$i;
a358449a
MP
162 AC_DEFINE(INET6, 1, [true if you have IPv6])
163 ])
06963d0f
MP
164 ;;
165 kame)
166 # http://www.kame.net/
167 AC_EGREP_CPP(yes, [
168#include <netinet/in.h>
169#ifdef __KAME__
170yes
171#endif],
a358449a
MP
172 [ipv6type=$i;
173 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
174 ;;
175 linux-glibc)
176 # http://www.v6.linux.or.jp/
177 AC_EGREP_CPP(yes, [
178#include <features.h>
179#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
180yes
181#endif],
182 [ipv6type=$i;
a358449a 183AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
184 ;;
185 linux-inet6)
186 # http://www.v6.linux.or.jp/
187 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
188 ipv6type=$i
189 ipv6lib=inet6
190 ipv6libdir=/usr/inet6/lib
191 ipv6trylibc=yes;
a358449a
MP
192 AC_DEFINE(INET6, 1, [true if you have IPv6])
193 CFLAGS="-I/usr/inet6/include $CFLAGS"
06963d0f
MP
194 fi
195 ;;
196 toshiba)
197 AC_EGREP_CPP(yes, [
198#include <sys/param.h>
199#ifdef _TOSHIBA_INET6
200yes
201#endif],
202 [ipv6type=$i;
203 ipv6lib=inet6;
204 ipv6libdir=/usr/local/v6/lib;
a358449a 205 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
206 ;;
207 v6d)
208 AC_EGREP_CPP(yes, [
209#include </usr/local/v6/include/sys/v6config.h>
210#ifdef __V6D__
211yes
212#endif],
213 [ipv6type=$i;
214 ipv6lib=v6;
215 ipv6libdir=/usr/local/v6/lib;
a358449a 216 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
217 ;;
218 zeta)
219 AC_EGREP_CPP(yes, [
220#include <sys/param.h>
221#ifdef _ZETA_MINAMI_INET6
222yes
223#endif],
224 [ipv6type=$i;
225 ipv6lib=inet6;
226 ipv6libdir=/usr/local/v6/lib;
a358449a 227 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
228 ;;
229 esac
230 if test "$ipv6type" != "unknown"; then
231 break
232 fi
233 done
234 AC_MSG_RESULT($ipv6type)
06963d0f 235
17d5a07e
MP
236 AC_SEARCH_LIBS(getaddrinfo, inet6)
237fi
06963d0f 238
cd957c70 239AC_C_BIGENDIAN
c627d613 240AC_HEADER_DIRENT
c627d613
AT
241AC_HEADER_TIME
242AC_HEADER_SYS_WAIT
8bf73749 243AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
94481d91 244AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
fdd71e17 245AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
9dec7aa9 246AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
15c17078 247AC_CHECK_HEADERS(netdb.h)
e5a2b854 248AC_CHECK_HEADERS(malloc.h)
c627d613
AT
249
250AC_CHECK_SIZEOF(int)
251AC_CHECK_SIZEOF(long)
252AC_CHECK_SIZEOF(short)
253
254AC_C_INLINE
255
256AC_TYPE_SIGNAL
257AC_TYPE_UID_T
258AC_TYPE_MODE_T
259AC_TYPE_OFF_T
260AC_TYPE_SIZE_T
261AC_TYPE_PID_T
9422bb3f 262AC_TYPE_GETGROUPS
bf5c2bf6
MP
263AC_CHECK_MEMBERS([struct stat.st_rdev])
264
e2ba16cc 265AC_CHECK_TYPE([ino_t], [unsigned])
7ca6e856 266TYPE_SOCKLEN_T
c627d613 267
7b3d4257 268AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
7597e1a9 269 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
7b3d4257
AT
270 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
271if test x"$rsync_cv_errno" = x"yes"; then
d4e4cbe1 272 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
7597e1a9 273fi
c627d613 274
a784e10d
DD
275# The following test taken from the cvs sources
276# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
277# These need checks to be before checks for any other functions that
278# might be in the same libraries.
279# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
280# libsocket.so which has a bad implementation of gethostbyname (it
281# only looks in /etc/hosts), so we only look for -lsocket if we need
282# it.
283AC_CHECK_FUNCS(connect)
284if test x"$ac_cv_func_connect" = x"no"; then
285 case "$LIBS" in
286 *-lnsl*) ;;
287 *) AC_CHECK_LIB(nsl_s, printf) ;;
288 esac
289 case "$LIBS" in
290 *-lnsl*) ;;
291 *) AC_CHECK_LIB(nsl, printf) ;;
292 esac
293 case "$LIBS" in
294 *-lsocket*) ;;
295 *) AC_CHECK_LIB(socket, connect) ;;
296 esac
297 case "$LIBS" in
298 *-linet*) ;;
299 *) AC_CHECK_LIB(inet, connect) ;;
300 esac
301 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
302 dnl has been cached.
303 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
304 test x"$ac_cv_lib_inet_connect" = x"yes"; then
305 # ac_cv_func_connect=yes
306 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
d4e4cbe1 307 AC_DEFINE(HAVE_CONNECT, 1, [ ])
a784e10d
DD
308 fi
309fi
310
8f694072
MP
311AC_CHECK_LIB(resolv, inet_ntop)
312
99f106d1 313dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
e94989fe 314
9fecec5e
MP
315AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop))
316AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
356bbb83 317
7a49cb56
MP
318# Tru64 UNIX has getaddrinfo() but has it renamed in libc as
319# something else so we must include <netdb.h> to get the
320# redefinition.
321AC_MSG_CHECKING([for getaddrinfo])
322AC_TRY_LINK([#include <sys/types.h>
323#include <sys/socket.h>
324#include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
325 [AC_MSG_RESULT([yes])
326 AC_DEFINE(HAVE_GETADDRINFO, 1,
327 [Define if you have the `getaddrinfo' function.])],
328 [AC_MSG_RESULT([no])
329 AC_LIBOBJ(lib/getaddrinfo)])
9fecec5e 330AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
82923068 331
356bbb83
MP
332AC_CHECK_MEMBER([struct sockaddr.sa_len],
333 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
334 [],
335 [
336#include <sys/types.h>
337#include <sys/socket.h>
338])
339
2d6dbe29
MP
340AC_MSG_CHECKING(struct sockaddr_storage)
341AC_TRY_COMPILE([#include <sys/types.h>
342#include <sys/socket.h>],
343[struct sockaddr_storage x;],
344 AC_MSG_RESULT(yes)
9fecec5e
MP
345 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
346 [Define if you have strct sockaddr_storage.] ),
2d6dbe29
MP
347 AC_MSG_RESULT(no))
348
a784e10d
DD
349# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
350#
351AC_CHECK_FUNCS(strcasecmp)
352if test x"$ac_cv_func_strcasecmp" = x"no"; then
353 AC_CHECK_LIB(resolv, strcasecmp)
354fi
355
87fcb639
MP
356dnl At the moment we don't test for a broken memcmp(), because all we
357dnl need to do is test for equality, not comparison, and it seems that
358dnl every platform has a memcmp that can do at least that.
359dnl AC_FUNC_MEMCMP
360
c627d613 361AC_FUNC_UTIME_NULL
e68f3481 362AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
e0414f42 363AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
8950ac03 364AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
7583ded8 365AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo)
24c857f1
DD
366
367AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
6a5ef41f
MP
368AC_TRY_RUN([
369#include <sys/types.h>
370#include <sys/socket.h>
371
372main() {
373 int fd[2];
374 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
375}],
24c857f1
DD
376rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
377if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
d4e4cbe1 378 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
24c857f1 379fi
c627d613 380
79fc6bdb 381AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
c627d613 382AC_TRY_RUN([#include <fnmatch.h>
e7d6e0aa
AT
383main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
384 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
79fc6bdb
DD
385rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
386if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
d4e4cbe1 387 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
79fc6bdb
DD
388fi
389
1ac15cd8
MP
390if test x"$with_included_popt" != x"yes"
391then
392 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
393fi
2d1ebe9c 394
12458878 395AC_MSG_CHECKING([whether to use included libpopt])
2d1ebe9c
MP
396if test x"$with_included_popt" = x"yes"
397then
12458878 398 AC_MSG_RESULT($srcdir/popt)
1ac15cd8 399 BUILD_POPT='$(popt_OBJS)'
26ef00bd 400 CFLAGS="$CFLAGS -I$srcdir/popt"
2d1ebe9c
MP
401else
402 AC_MSG_RESULT(no)
79fc6bdb 403fi
c627d613 404
79fc6bdb 405AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
0d0e2e93 406AC_TRY_RUN([#include <stdio.h>
efb2f6bf 407main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
79fc6bdb
DD
408rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
409if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
d4e4cbe1 410 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
7597e1a9 411fi
0d0e2e93 412
7b3d4257 413AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
bcacc18b
AT
414AC_TRY_RUN([#include <stdio.h>
415#include <sys/stat.h>
7597e1a9 416main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
7b3d4257
AT
417rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
418if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
d4e4cbe1 419 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
7597e1a9 420fi
debb4505 421
79fc6bdb 422AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
c29ee43d
AT
423AC_TRY_RUN([#include <stdio.h>
424#include <sys/types.h>
425#include <sys/stat.h>
426main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
79fc6bdb
DD
427rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
428if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
d4e4cbe1 429 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
79fc6bdb 430fi
c29ee43d 431
7b3d4257 432AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
debb4505
AT
433AC_TRY_RUN([#include <stdio.h>
434main() { char c; c=250; exit((c > 0)?0:1); }],
7b3d4257
AT
435rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
436if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
d4e4cbe1 437 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
7597e1a9 438fi
bcacc18b 439
7b3d4257 440AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
59503278
AT
441AC_TRY_RUN([#include <sys/types.h>
442#include <dirent.h>
443main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
444if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
7597e1a9 445di->d_name[0] == 0) exit(0); exit(1);} ],
7b3d4257
AT
446rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
447if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
d4e4cbe1 448 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
7597e1a9 449fi
1e9f155a 450
7b3d4257 451AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
d6e6ecbd
AT
452AC_TRY_COMPILE([#include <sys/types.h>
453#include <utime.h>],
7597e1a9 454[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
7b3d4257
AT
455rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
456if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
d4e4cbe1 457 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
7597e1a9 458fi
d6e6ecbd 459
3060d4aa
AT
460AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
461AC_TRY_RUN([
462#include <sys/time.h>
463#include <unistd.h>
464main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
465 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
466if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
d4e4cbe1 467 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
3060d4aa
AT
468fi
469
8950ac03
AT
470AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
471AC_TRY_RUN([
472#include <sys/types.h>
473#include <stdarg.h>
474void foo(const char *format, ...) {
475 va_list ap;
476 int len;
477 char buf[5];
478
479 va_start(ap, format);
480 len = vsnprintf(0, 0, format, ap);
481 va_end(ap);
482 if (len != 5) exit(1);
483
484 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
485
486 exit(0);
487}
488main() { foo("hello"); }
489],
490rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
491if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
d4e4cbe1 492 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
8950ac03
AT
493fi
494
495
f62c17e3
AT
496AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
497AC_TRY_RUN([#include <stdlib.h>
498#include <sys/types.h>
499#include <sys/stat.h>
500#include <unistd.h>
501main() {
502 struct stat st;
503 char tpl[20]="/tmp/test.XXXXXX";
504 int fd = mkstemp(tpl);
505 if (fd == -1) exit(1);
506 unlink(tpl);
507 if (fstat(fd, &st) != 0) exit(1);
508 if ((st.st_mode & 0777) != 0600) exit(1);
509 exit(0);
510}],
511rsync_cv_HAVE_SECURE_MKSTEMP=yes,
512rsync_cv_HAVE_SECURE_MKSTEMP=no,
513rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
514if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
d4e4cbe1 515 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
f62c17e3
AT
516fi
517
3060d4aa 518
7b3d4257
AT
519AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
520AC_TRY_RUN([
521#include <stdio.h>
522#include <sys/types.h>
523#include <netinet/in.h>
524#include <arpa/inet.h>
525main() { struct in_addr ip; ip.s_addr = 0x12345678;
526if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
fca3ef06
AT
527 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
528exit(0);}],
529 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
7b3d4257 530if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
d4e4cbe1 531 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
7b3d4257
AT
532fi
533
fca3ef06
AT
534
535AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
536AC_TRY_RUN([
537#include <stdio.h>
538#include <sys/types.h>
539#include <netinet/in.h>
540#include <arpa/inet.h>
541main() { struct in_addr ip;
542if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
543 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
544if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
d4e4cbe1 545 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
fca3ef06
AT
546fi
547
692da0b5
DD
548#
549# The following test was mostly taken from the tcl/tk plus patches
550#
79fc6bdb 551AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
692da0b5
DD
552rm -rf conftest*
553cat > conftest.$ac_ext <<EOF
554int main() { return 0; }
555EOF
556${CC-cc} -c -o conftest..o conftest.$ac_ext
557if test -f conftest..o; then
79fc6bdb
DD
558 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
559else
560 rsync_cv_DASHC_WORKS_WITH_DASHO=no
561fi
562rm -rf conftest*
563])
564if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
692da0b5
DD
565 OBJ_SAVE="#"
566 OBJ_RESTORE="#"
567 CC_SHOBJ_FLAG='-o $@'
692da0b5
DD
568else
569 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
570 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'
571 CC_SHOBJ_FLAG=""
692da0b5 572fi
79fc6bdb 573
692da0b5
DD
574AC_SUBST(OBJ_SAVE)
575AC_SUBST(OBJ_RESTORE)
576AC_SUBST(CC_SHOBJ_FLAG)
1ac15cd8 577AC_SUBST(BUILD_POPT)
7d29d4ba 578
bf5c2bf6
MP
579AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
580AC_OUTPUT
a4677968
MP
581
582AC_MSG_RESULT()
583AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])
584AC_MSG_RESULT()