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