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