fixed check for timeout in generator
[rsync/rsync.git] / configure.in
... / ...
CommitLineData
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(byteorder.h)
3AC_CONFIG_HEADER(config.h)
4AC_PREREQ(2.52)
5
6LDFLAGS=${LDFLAGS-""}
7
8AC_CANONICAL_SYSTEM
9AC_VALIDATE_CACHE_SYSTEM_TYPE
10
11# compile with optimisation and without debugging by default, unless
12# --debug is given. We must decide this before testing the compiler.
13
14AC_ARG_ENABLE(debug,
15 [ --enable-debug including debugging symbols and features])
16
17AC_MSG_CHECKING([whether to include debugging symbols])
18if test x"$enable_debug" = x"yes"
19then
20 AC_MSG_RESULT(yes)
21 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
22 AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
23 CFLAGS=${CFLAGS-"-g"}
24else
25 AC_MSG_RESULT(no)
26 CFLAGS=${CFLAGS-"-O"}
27fi
28
29CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
30
31AC_ARG_WITH(included-popt,
32 [ --with-included-popt use bundled popt library, not from system])
33
34AC_ARG_WITH(rsync-path,
35 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
36 [ RSYNC_PATH="$with_rsync_path" ],
37 [ RSYNC_PATH="rsync" ])
38AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
39
40dnl Checks for programs.
41AC_PROG_CC
42AC_PROG_INSTALL
43AC_SUBST(SHELL)
44
45AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
46AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
47
48
49# arrgh. libc in the current debian stable screws up the largefile
50# stuff, getting byte range locking wrong
51AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
52AC_TRY_RUN([
53#define _FILE_OFFSET_BITS 64
54#include <stdio.h>
55#include <fcntl.h>
56#include <sys/types.h>
57#include <sys/wait.h>
58
59int main(void)
60{
61 struct flock lock;
62 int status;
63 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
64 lock.l_type = F_WRLCK;
65 lock.l_whence = SEEK_SET;
66 lock.l_start = 0;
67 lock.l_len = 1;
68 lock.l_pid = 0;
69
70 fcntl(fd,F_SETLK,&lock);
71 if (fork() == 0) {
72 lock.l_start = 1;
73 exit(fcntl(fd,F_SETLK,&lock) == 0);
74 }
75 wait(&status);
76 unlink("conftest.dat");
77 exit(WEXITSTATUS(status));
78}
79],
80rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
81if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
82 AC_SYS_LARGEFILE
83fi
84
85
86
87AC_C_BIGENDIAN
88AC_HEADER_DIRENT
89AC_HEADER_TIME
90AC_HEADER_SYS_WAIT
91AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
92AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
93AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
94AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
95
96AC_CHECK_SIZEOF(int)
97AC_CHECK_SIZEOF(long)
98AC_CHECK_SIZEOF(short)
99
100AC_C_INLINE
101
102AC_TYPE_SIGNAL
103AC_TYPE_UID_T
104AC_TYPE_MODE_T
105AC_TYPE_OFF_T
106AC_TYPE_SIZE_T
107AC_TYPE_PID_T
108AC_TYPE_GETGROUPS
109AC_STRUCT_ST_RDEV
110AC_CHECK_TYPE([ino_t], [unsigned])
111TYPE_SOCKLEN_T
112
113AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
114 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
115 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
116if test x"$rsync_cv_errno" = x"yes"; then
117 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
118fi
119
120# The following test taken from the cvs sources
121# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
122# These need checks to be before checks for any other functions that
123# might be in the same libraries.
124# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
125# libsocket.so which has a bad implementation of gethostbyname (it
126# only looks in /etc/hosts), so we only look for -lsocket if we need
127# it.
128AC_CHECK_FUNCS(connect)
129if test x"$ac_cv_func_connect" = x"no"; then
130 case "$LIBS" in
131 *-lnsl*) ;;
132 *) AC_CHECK_LIB(nsl_s, printf) ;;
133 esac
134 case "$LIBS" in
135 *-lnsl*) ;;
136 *) AC_CHECK_LIB(nsl, printf) ;;
137 esac
138 case "$LIBS" in
139 *-lsocket*) ;;
140 *) AC_CHECK_LIB(socket, connect) ;;
141 esac
142 case "$LIBS" in
143 *-linet*) ;;
144 *) AC_CHECK_LIB(inet, connect) ;;
145 esac
146 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
147 dnl has been cached.
148 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
149 test x"$ac_cv_lib_inet_connect" = x"yes"; then
150 # ac_cv_func_connect=yes
151 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
152 AC_DEFINE(HAVE_CONNECT, 1, [ ])
153 fi
154fi
155
156#
157# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
158#
159AC_CHECK_FUNCS(strcasecmp)
160if test x"$ac_cv_func_strcasecmp" = x"no"; then
161 AC_CHECK_LIB(resolv, strcasecmp)
162fi
163
164AC_FUNC_MEMCMP
165AC_FUNC_UTIME_NULL
166AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
167AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
168AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
169AC_CHECK_FUNCS(strlcat strlcpy mtrace)
170
171AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
172AC_TRY_RUN([#include <sys/types.h>
173 #include <sys/socket.h>
174 main() {
175 int fd[2];
176 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
177 }],
178rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
179if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
180 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
181fi
182
183AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
184AC_TRY_RUN([#include <fnmatch.h>
185main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
186 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
187rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
188if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
189 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
190fi
191
192if test x"$with_included_popt" != x"yes"
193then
194 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
195fi
196
197AC_MSG_CHECKING([whether to use included libpopt])
198if test x"$with_included_popt" = x"yes"
199then
200 AC_MSG_RESULT($srcdir/popt)
201 BUILD_POPT='$(popt_OBJS)'
202 CFLAGS="$CFLAGS -I$srcdir/popt"
203else
204 AC_MSG_RESULT(no)
205fi
206
207AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
208AC_TRY_RUN([#include <stdio.h>
209main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
210rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
211if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
212 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
213fi
214
215AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
216AC_TRY_RUN([#include <stdio.h>
217#include <sys/stat.h>
218main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
219rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
220if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
221 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
222fi
223
224AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
225AC_TRY_RUN([#include <stdio.h>
226#include <sys/types.h>
227#include <sys/stat.h>
228main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
229rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
230if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
231 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
232fi
233
234AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
235AC_TRY_RUN([#include <stdio.h>
236main() { char c; c=250; exit((c > 0)?0:1); }],
237rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
238if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
239 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
240fi
241
242AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
243AC_TRY_RUN([#include <sys/types.h>
244#include <dirent.h>
245main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
246if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
247di->d_name[0] == 0) exit(0); exit(1);} ],
248rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
249if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
250 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
251fi
252
253AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
254AC_TRY_COMPILE([#include <sys/types.h>
255#include <utime.h>],
256[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
257rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
258if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
259 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
260fi
261
262AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
263AC_TRY_RUN([
264#include <sys/time.h>
265#include <unistd.h>
266main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
267 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
268if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
269 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
270fi
271
272AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
273AC_TRY_RUN([
274#include <sys/types.h>
275#include <stdarg.h>
276void foo(const char *format, ...) {
277 va_list ap;
278 int len;
279 char buf[5];
280
281 va_start(ap, format);
282 len = vsnprintf(0, 0, format, ap);
283 va_end(ap);
284 if (len != 5) exit(1);
285
286 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
287
288 exit(0);
289}
290main() { foo("hello"); }
291],
292rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
293if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
294 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
295fi
296
297
298AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
299AC_TRY_RUN([#include <stdlib.h>
300#include <sys/types.h>
301#include <sys/stat.h>
302#include <unistd.h>
303main() {
304 struct stat st;
305 char tpl[20]="/tmp/test.XXXXXX";
306 int fd = mkstemp(tpl);
307 if (fd == -1) exit(1);
308 unlink(tpl);
309 if (fstat(fd, &st) != 0) exit(1);
310 if ((st.st_mode & 0777) != 0600) exit(1);
311 exit(0);
312}],
313rsync_cv_HAVE_SECURE_MKSTEMP=yes,
314rsync_cv_HAVE_SECURE_MKSTEMP=no,
315rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
316if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
317 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
318fi
319
320
321AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
322AC_TRY_RUN([
323#include <stdio.h>
324#include <sys/types.h>
325#include <netinet/in.h>
326#include <arpa/inet.h>
327main() { struct in_addr ip; ip.s_addr = 0x12345678;
328if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
329 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
330exit(0);}],
331 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
332if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
333 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
334fi
335
336
337AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
338AC_TRY_RUN([
339#include <stdio.h>
340#include <sys/types.h>
341#include <netinet/in.h>
342#include <arpa/inet.h>
343main() { struct in_addr ip;
344if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
345 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
346if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
347 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
348fi
349
350#
351# The following test was mostly taken from the tcl/tk plus patches
352#
353AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
354rm -rf conftest*
355cat > conftest.$ac_ext <<EOF
356int main() { return 0; }
357EOF
358${CC-cc} -c -o conftest..o conftest.$ac_ext
359if test -f conftest..o; then
360 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
361else
362 rsync_cv_DASHC_WORKS_WITH_DASHO=no
363fi
364rm -rf conftest*
365])
366if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
367 OBJ_SAVE="#"
368 OBJ_RESTORE="#"
369 CC_SHOBJ_FLAG='-o $@'
370else
371 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
372 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'
373 CC_SHOBJ_FLAG=""
374fi
375
376AC_SUBST(OBJ_SAVE)
377AC_SUBST(OBJ_RESTORE)
378AC_SUBST(CC_SHOBJ_FLAG)
379AC_SUBST(BUILD_POPT)
380
381AC_OUTPUT(Makefile lib/dummy zlib/dummy shconfig)