Fix KAME patch to use proper autoconf AC_MSG macros rather than just echo/exit.
[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
6a48ca56 8LDFLAGS=${LDFLAGS-""}
50abd20b 9
bf5c2bf6
MP
10AC_CANONICAL_TARGET([])
11
12dnl Checks for programs.
13AC_PROG_CC
14AC_PROG_CPP
15AC_PROG_INSTALL
16AC_SUBST(SHELL)
8de330a3 17
56901bc7 18RSYNC_VERSION=2.4.7pre3
a358449a
MP
19AC_SUBST(RSYNC_VERSION)
20AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
21
2d1ebe9c
MP
22# compile with optimisation and without debugging by default, unless
23# --debug is given. We must decide this before testing the compiler.
24
bf5c2bf6 25AC_MSG_CHECKING([whether to include debugging symbols])
2d1ebe9c 26AC_ARG_ENABLE(debug,
bf5c2bf6
MP
27 AC_HELP_STRING([--enable-debug],
28 [including debugging symbols and features (default yes)]),
29 [], [])
2d1ebe9c 30
bf5c2bf6 31if test x"$enable_debug" = x"no"
2d1ebe9c 32then
2d1ebe9c
MP
33 AC_MSG_RESULT(no)
34 CFLAGS=${CFLAGS-"-O"}
bf5c2bf6
MP
35else
36 AC_MSG_RESULT([yes])
37 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
38 AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
39 dnl CFLAGS=${CFLAGS-"-g"}
2d1ebe9c
MP
40fi
41
1ac15cd8
MP
42CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
43
2d1ebe9c
MP
44AC_ARG_WITH(included-popt,
45 [ --with-included-popt use bundled popt library, not from system])
46
41bd28fe 47AC_ARG_WITH(rsync-path,
ddd491d4 48 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
8642efd0 49 [ RSYNC_PATH="$with_rsync_path" ],
41bd28fe 50 [ RSYNC_PATH="rsync" ])
c6a7f2f4 51AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
41bd28fe 52
7b8356d0 53AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
d4e4cbe1 54AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
7b8356d0 55
f0af1e5e
AT
56
57# arrgh. libc in the current debian stable screws up the largefile
58# stuff, getting byte range locking wrong
59AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
60AC_TRY_RUN([
61#define _FILE_OFFSET_BITS 64
62#include <stdio.h>
63#include <fcntl.h>
64#include <sys/types.h>
65#include <sys/wait.h>
66
67int main(void)
68{
69 struct flock lock;
70 int status;
71 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
72 lock.l_type = F_WRLCK;
73 lock.l_whence = SEEK_SET;
74 lock.l_start = 0;
75 lock.l_len = 1;
76 lock.l_pid = 0;
77
78 fcntl(fd,F_SETLK,&lock);
79 if (fork() == 0) {
80 lock.l_start = 1;
81 exit(fcntl(fd,F_SETLK,&lock) == 0);
82 }
83 wait(&status);
84 unlink("conftest.dat");
85 exit(WEXITSTATUS(status));
86}
87],
88rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
89if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
90 AC_SYS_LARGEFILE
91fi
92
93
94
bf5c2bf6
MP
95AC_DEFINE(ss_family, __ss_family, [KAME hack])
96AC_DEFINE(ss_len, __ss_len, [KAME hack])
97
06963d0f 98CFLAGS="$CFLAGS"
06963d0f 99AC_ARG_ENABLE(ipv6,
4f6e5fe3
MP
100 AC_HELP_STRING([--enable-ipv6], [try to support IPv6]))
101AC_MSG_CHECKING([whether IPv6 is requested])
620bbabc
MP
102if test "$xenable_ipv6" = xyes
103then
104 AC_MSG_RESULT(yes)
4f6e5fe3 105 ipv6=yes
620bbabc
MP
106else
107 AC_MSG_RESULT(no)
4f6e5fe3 108 ipv6=no
620bbabc 109fi
06963d0f
MP
110
111ipv6type=unknown
112ipv6lib=none
113ipv6trylibc=no
114
115if test "$ipv6" = "yes"; then
116 AC_MSG_CHECKING([ipv6 stack type])
117 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
118 case $i in
119 inria)
120 # http://www.kame.net/
121 AC_EGREP_CPP(yes, [
122#include <netinet/in.h>
123#ifdef IPV6_INRIA_VERSION
124yes
125#endif],
126 [ipv6type=$i;
a358449a
MP
127 AC_DEFINE(INET6, 1, [true if you have IPv6])
128 ])
06963d0f
MP
129 ;;
130 kame)
131 # http://www.kame.net/
132 AC_EGREP_CPP(yes, [
133#include <netinet/in.h>
134#ifdef __KAME__
135yes
136#endif],
a358449a
MP
137 [ipv6type=$i;
138 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
139 ;;
140 linux-glibc)
141 # http://www.v6.linux.or.jp/
142 AC_EGREP_CPP(yes, [
143#include <features.h>
144#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
145yes
146#endif],
147 [ipv6type=$i;
a358449a 148AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
149 ;;
150 linux-inet6)
151 # http://www.v6.linux.or.jp/
152 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
153 ipv6type=$i
154 ipv6lib=inet6
155 ipv6libdir=/usr/inet6/lib
156 ipv6trylibc=yes;
a358449a
MP
157 AC_DEFINE(INET6, 1, [true if you have IPv6])
158 CFLAGS="-I/usr/inet6/include $CFLAGS"
06963d0f
MP
159 fi
160 ;;
161 toshiba)
162 AC_EGREP_CPP(yes, [
163#include <sys/param.h>
164#ifdef _TOSHIBA_INET6
165yes
166#endif],
167 [ipv6type=$i;
168 ipv6lib=inet6;
169 ipv6libdir=/usr/local/v6/lib;
a358449a 170 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
171 ;;
172 v6d)
173 AC_EGREP_CPP(yes, [
174#include </usr/local/v6/include/sys/v6config.h>
175#ifdef __V6D__
176yes
177#endif],
178 [ipv6type=$i;
179 ipv6lib=v6;
180 ipv6libdir=/usr/local/v6/lib;
a358449a 181 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
182 ;;
183 zeta)
184 AC_EGREP_CPP(yes, [
185#include <sys/param.h>
186#ifdef _ZETA_MINAMI_INET6
187yes
188#endif],
189 [ipv6type=$i;
190 ipv6lib=inet6;
191 ipv6libdir=/usr/local/v6/lib;
a358449a 192 AC_DEFINE(INET6, 1, [true if you have IPv6])])
06963d0f
MP
193 ;;
194 esac
195 if test "$ipv6type" != "unknown"; then
196 break
197 fi
198 done
199 AC_MSG_RESULT($ipv6type)
200fi
201
202if test "$ipv6" = "yes" -a -f /usr/local/v6/lib/libinet6.a; then
203 ac_inet6_LDFLAGS="inet6"
204 ipv6libdir=/usr/local/v6/lib
205 LDFLAGS="$LDFLAGS -L/usr/local/v6/lib"
206 AC_CHECK_LIB(inet6, getaddrinfo, , ipv6lib="$ac_inet6_LDFLAGS")
207fi
208
209if test "$ipv6" = "yes" -a -f /usr/lib/libinet6.a; then
210 ac_inet6_LDFLAGS="inet6"
211 AC_CHECK_LIB(inet6, getaddrinfo, , ipv6lib="$ac_inet6_LDFLAGS")
212fi
213
214if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
215 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
216 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
bc3d7454 217 AC_MSG_NOTICE([You have $ipv6lib library, using it])
06963d0f
MP
218 else
219 if test "$ipv6trylibc" = "yes"; then
bc3d7454 220 AC_MSG_WARN([You do not have $ipv6lib library, using libc])
06963d0f 221 else
bc3d7454 222 AC_MSG_ERROR([No $ipv6lib library found. cannot continue. You need to fetch lib$ipv6lib.a from appropriate ipv6 kit and compile beforehand.])
06963d0f
MP
223 fi
224 fi
225fi
226
227
228AC_MSG_CHECKING(getaddrinfo bug)
229AC_TRY_RUN([
230#include <sys/types.h>
231#include <netdb.h>
232#include <string.h>
233#include <sys/socket.h>
234#include <netinet/in.h>
235
236main()
237{
238 int passive, gaierr, inet4 = 0, inet6 = 0;
239 struct addrinfo hints, *ai, *aitop;
240 char straddr[INET6_ADDRSTRLEN], strport[16];
241
242 for (passive = 0; passive <= 1; passive++) {
243 memset(&hints, 0, sizeof(hints));
244 hints.ai_family = AF_UNSPEC;
245 hints.ai_flags = passive ? AI_PASSIVE : 0;
246 hints.ai_socktype = SOCK_STREAM;
247 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
248 (void)gai_strerror(gaierr);
249 goto bad;
250 }
251 for (ai = aitop; ai; ai = ai->ai_next) {
252 if (ai->ai_addr == NULL ||
253 ai->ai_addrlen == 0 ||
254 getnameinfo(ai->ai_addr, ai->ai_addrlen,
255 straddr, sizeof(straddr), strport, sizeof(strport),
256 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
257 goto bad;
258 }
259 switch (ai->ai_family) {
260 case AF_INET:
261 if (strcmp(strport, "54321") != 0) {
262 goto bad;
263 }
264 if (passive) {
265 if (strcmp(straddr, "0.0.0.0") != 0) {
266 goto bad;
267 }
268 } else {
269 if (strcmp(straddr, "127.0.0.1") != 0) {
270 goto bad;
271 }
272 }
273 inet4++;
274 break;
275 case AF_INET6:
276 if (strcmp(strport, "54321") != 0) {
277 goto bad;
278 }
279 if (passive) {
280 if (strcmp(straddr, "::") != 0) {
281 goto bad;
282 }
283 } else {
284 if (strcmp(straddr, "::1") != 0) {
285 goto bad;
286 }
287 }
288 inet6++;
289 break;
290 case AF_UNSPEC:
291 goto bad;
292 break;
293 default:
294 /* another family support? */
295 break;
296 }
297 }
298 }
299
300 if (!(inet4 == 0 || inet4 == 2))
301 goto bad;
302 if (!(inet6 == 0 || inet6 == 2))
303 goto bad;
304
305 if (aitop)
306 freeaddrinfo(aitop);
307 exit(0);
308
309 bad:
310 if (aitop)
311 freeaddrinfo(aitop);
312 exit(1);
313}
314],
315AC_MSG_RESULT(good)
316buggygetaddrinfo=no,
317AC_MSG_RESULT(buggy)
318buggygetaddrinfo=yes,
319AC_MSG_RESULT(buggy)
320buggygetaddrinfo=yes)
321
322if test "$buggygetaddrinfo" = "yes"; then
323 if test "$ipv6" = "yes" -a "$ipv6type" != "linux"; then
bc3d7454 324 AC_MSG_ERROR([You must get working getaddrinfo() function or you can specify "--disable-ipv6"])
06963d0f 325 elif test "$ipv6type" = "linux"; then
bc3d7454 326 AC_MSG_ERROR([getaddrinfo() implementation on your system seems be buggy. Better upgrade your system library to newest version of GNU C library (aka glibc).])
06963d0f
MP
327 fi
328fi
329AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
330
bf5c2bf6
MP
331AC_CHECK_MEMBER([struct sockaddr.sa_len],
332 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
333 [],
334 [
06963d0f
MP
335#include <sys/types.h>
336#include <sys/socket.h>
bf5c2bf6 337])
06963d0f 338
cd957c70 339AC_C_BIGENDIAN
c627d613 340AC_HEADER_DIRENT
c627d613
AT
341AC_HEADER_TIME
342AC_HEADER_SYS_WAIT
8bf73749 343AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
94481d91 344AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
fdd71e17 345AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
8ee3d639 346AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
c627d613
AT
347
348AC_CHECK_SIZEOF(int)
349AC_CHECK_SIZEOF(long)
350AC_CHECK_SIZEOF(short)
351
352AC_C_INLINE
353
354AC_TYPE_SIGNAL
355AC_TYPE_UID_T
356AC_TYPE_MODE_T
357AC_TYPE_OFF_T
358AC_TYPE_SIZE_T
359AC_TYPE_PID_T
9422bb3f 360AC_TYPE_GETGROUPS
bf5c2bf6
MP
361AC_CHECK_MEMBERS([struct stat.st_rdev])
362
e2ba16cc 363AC_CHECK_TYPE([ino_t], [unsigned])
7ca6e856 364TYPE_SOCKLEN_T
c627d613 365
7b3d4257 366AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
7597e1a9 367 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
7b3d4257
AT
368 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
369if test x"$rsync_cv_errno" = x"yes"; then
d4e4cbe1 370 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
7597e1a9 371fi
c627d613 372
a784e10d
DD
373# The following test taken from the cvs sources
374# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
375# These need checks to be before checks for any other functions that
376# might be in the same libraries.
377# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
378# libsocket.so which has a bad implementation of gethostbyname (it
379# only looks in /etc/hosts), so we only look for -lsocket if we need
380# it.
381AC_CHECK_FUNCS(connect)
382if test x"$ac_cv_func_connect" = x"no"; then
383 case "$LIBS" in
384 *-lnsl*) ;;
385 *) AC_CHECK_LIB(nsl_s, printf) ;;
386 esac
387 case "$LIBS" in
388 *-lnsl*) ;;
389 *) AC_CHECK_LIB(nsl, printf) ;;
390 esac
391 case "$LIBS" in
392 *-lsocket*) ;;
393 *) AC_CHECK_LIB(socket, connect) ;;
394 esac
395 case "$LIBS" in
396 *-linet*) ;;
397 *) AC_CHECK_LIB(inet, connect) ;;
398 esac
399 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
400 dnl has been cached.
401 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
402 test x"$ac_cv_lib_inet_connect" = x"yes"; then
403 # ac_cv_func_connect=yes
404 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
d4e4cbe1 405 AC_DEFINE(HAVE_CONNECT, 1, [ ])
a784e10d
DD
406 fi
407fi
408
409#
410# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
411#
412AC_CHECK_FUNCS(strcasecmp)
413if test x"$ac_cv_func_strcasecmp" = x"no"; then
414 AC_CHECK_LIB(resolv, strcasecmp)
415fi
416
c627d613 417AC_FUNC_MEMCMP
c627d613 418AC_FUNC_UTIME_NULL
e68f3481 419AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
e0414f42 420AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
8950ac03 421AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
8ee3d639 422AC_CHECK_FUNCS(strlcat strlcpy mtrace)
24c857f1
DD
423
424AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
425AC_TRY_RUN([#include <sys/types.h>
426 #include <sys/socket.h>
427 main() {
428 int fd[2];
429 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
430 }],
431rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
432if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
d4e4cbe1 433 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
24c857f1 434fi
c627d613 435
79fc6bdb 436AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
c627d613 437AC_TRY_RUN([#include <fnmatch.h>
e7d6e0aa
AT
438main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
439 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
79fc6bdb
DD
440rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
441if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
d4e4cbe1 442 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
79fc6bdb
DD
443fi
444
1ac15cd8
MP
445if test x"$with_included_popt" != x"yes"
446then
447 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
448fi
2d1ebe9c 449
12458878 450AC_MSG_CHECKING([whether to use included libpopt])
2d1ebe9c
MP
451if test x"$with_included_popt" = x"yes"
452then
12458878 453 AC_MSG_RESULT($srcdir/popt)
1ac15cd8 454 BUILD_POPT='$(popt_OBJS)'
26ef00bd 455 CFLAGS="$CFLAGS -I$srcdir/popt"
2d1ebe9c
MP
456else
457 AC_MSG_RESULT(no)
79fc6bdb 458fi
c627d613 459
79fc6bdb 460AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
0d0e2e93 461AC_TRY_RUN([#include <stdio.h>
efb2f6bf 462main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
79fc6bdb
DD
463rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
464if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
d4e4cbe1 465 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
7597e1a9 466fi
0d0e2e93 467
7b3d4257 468AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
bcacc18b
AT
469AC_TRY_RUN([#include <stdio.h>
470#include <sys/stat.h>
7597e1a9 471main() { 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
472rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
473if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
d4e4cbe1 474 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
7597e1a9 475fi
debb4505 476
79fc6bdb 477AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
c29ee43d
AT
478AC_TRY_RUN([#include <stdio.h>
479#include <sys/types.h>
480#include <sys/stat.h>
481main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
79fc6bdb
DD
482rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
483if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
d4e4cbe1 484 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
79fc6bdb 485fi
c29ee43d 486
7b3d4257 487AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
debb4505
AT
488AC_TRY_RUN([#include <stdio.h>
489main() { char c; c=250; exit((c > 0)?0:1); }],
7b3d4257
AT
490rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
491if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
d4e4cbe1 492 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
7597e1a9 493fi
bcacc18b 494
7b3d4257 495AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
59503278
AT
496AC_TRY_RUN([#include <sys/types.h>
497#include <dirent.h>
498main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
499if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
7597e1a9 500di->d_name[0] == 0) exit(0); exit(1);} ],
7b3d4257
AT
501rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
502if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
d4e4cbe1 503 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
7597e1a9 504fi
1e9f155a 505
7b3d4257 506AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
d6e6ecbd
AT
507AC_TRY_COMPILE([#include <sys/types.h>
508#include <utime.h>],
7597e1a9 509[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
7b3d4257
AT
510rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
511if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
d4e4cbe1 512 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
7597e1a9 513fi
d6e6ecbd 514
3060d4aa
AT
515AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
516AC_TRY_RUN([
517#include <sys/time.h>
518#include <unistd.h>
519main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
520 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
521if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
d4e4cbe1 522 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
3060d4aa
AT
523fi
524
8950ac03
AT
525AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
526AC_TRY_RUN([
527#include <sys/types.h>
528#include <stdarg.h>
529void foo(const char *format, ...) {
530 va_list ap;
531 int len;
532 char buf[5];
533
534 va_start(ap, format);
535 len = vsnprintf(0, 0, format, ap);
536 va_end(ap);
537 if (len != 5) exit(1);
538
539 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
540
541 exit(0);
542}
543main() { foo("hello"); }
544],
545rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
546if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
d4e4cbe1 547 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
8950ac03
AT
548fi
549
550
f62c17e3
AT
551AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
552AC_TRY_RUN([#include <stdlib.h>
553#include <sys/types.h>
554#include <sys/stat.h>
555#include <unistd.h>
556main() {
557 struct stat st;
558 char tpl[20]="/tmp/test.XXXXXX";
559 int fd = mkstemp(tpl);
560 if (fd == -1) exit(1);
561 unlink(tpl);
562 if (fstat(fd, &st) != 0) exit(1);
563 if ((st.st_mode & 0777) != 0600) exit(1);
564 exit(0);
565}],
566rsync_cv_HAVE_SECURE_MKSTEMP=yes,
567rsync_cv_HAVE_SECURE_MKSTEMP=no,
568rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
569if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
d4e4cbe1 570 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
f62c17e3
AT
571fi
572
3060d4aa 573
7b3d4257
AT
574AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
575AC_TRY_RUN([
576#include <stdio.h>
577#include <sys/types.h>
578#include <netinet/in.h>
579#include <arpa/inet.h>
580main() { struct in_addr ip; ip.s_addr = 0x12345678;
581if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
fca3ef06
AT
582 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
583exit(0);}],
584 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
7b3d4257 585if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
d4e4cbe1 586 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
7b3d4257
AT
587fi
588
fca3ef06
AT
589
590AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
591AC_TRY_RUN([
592#include <stdio.h>
593#include <sys/types.h>
594#include <netinet/in.h>
595#include <arpa/inet.h>
596main() { struct in_addr ip;
597if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
598 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
599if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
d4e4cbe1 600 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
fca3ef06
AT
601fi
602
692da0b5
DD
603#
604# The following test was mostly taken from the tcl/tk plus patches
605#
79fc6bdb 606AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
692da0b5
DD
607rm -rf conftest*
608cat > conftest.$ac_ext <<EOF
609int main() { return 0; }
610EOF
611${CC-cc} -c -o conftest..o conftest.$ac_ext
612if test -f conftest..o; then
79fc6bdb
DD
613 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
614else
615 rsync_cv_DASHC_WORKS_WITH_DASHO=no
616fi
617rm -rf conftest*
618])
619if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
692da0b5
DD
620 OBJ_SAVE="#"
621 OBJ_RESTORE="#"
622 CC_SHOBJ_FLAG='-o $@'
692da0b5
DD
623else
624 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
625 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'
626 CC_SHOBJ_FLAG=""
692da0b5 627fi
79fc6bdb 628
692da0b5
DD
629AC_SUBST(OBJ_SAVE)
630AC_SUBST(OBJ_RESTORE)
631AC_SUBST(CC_SHOBJ_FLAG)
1ac15cd8 632AC_SUBST(BUILD_POPT)
7d29d4ba 633
bf5c2bf6
MP
634AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
635AC_OUTPUT