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