Show version when configuring.
[rsync/rsync.git] / configure.in
... / ...
CommitLineData
1dnl Process this file with autoconf to produce a configure script.
2
3AC_INIT()
4AC_CONFIG_SRCDIR([byteorder.h])
5AC_CONFIG_HEADER(config.h)
6AC_PREREQ(2.52)
7
8RSYNC_VERSION=2.4.7pre5
9AC_SUBST(RSYNC_VERSION)
10AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
11
12AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
13
14LDFLAGS=${LDFLAGS-""}
15
16AC_CANONICAL_TARGET([])
17
18dnl Checks for programs.
19AC_PROG_CC
20AC_PROG_CPP
21AC_PROG_INSTALL
22AC_PROG_CC_STDC
23AC_SUBST(SHELL)
24
25if test "$xac_cv_prog_cc_stdc" = xno
26then
27 AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
28fi
29
30# compile with optimisation and without debugging by default, unless
31# --debug is given. We must decide this before testing the compiler.
32
33AC_MSG_CHECKING([whether to include debugging symbols])
34AC_ARG_ENABLE(debug,
35 AC_HELP_STRING([--enable-debug],
36 [including debugging symbols and features (default yes)]),
37 [], [])
38
39if test x"$enable_debug" = x"no"
40then
41 AC_MSG_RESULT(no)
42 CFLAGS=${CFLAGS-"-O"}
43else
44 AC_MSG_RESULT([yes])
45 # leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
46 AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
47 dnl CFLAGS=${CFLAGS-"-g"}
48fi
49
50CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
51
52AC_ARG_WITH(included-popt,
53 [ --with-included-popt use bundled popt library, not from system])
54
55AC_ARG_WITH(rsync-path,
56 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
57 [ RSYNC_PATH="$with_rsync_path" ],
58 [ RSYNC_PATH="rsync" ])
59AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
60
61AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
62AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
63
64
65# arrgh. libc in the current debian stable screws up the largefile
66# stuff, getting byte range locking wrong
67AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
68AC_TRY_RUN([
69#define _FILE_OFFSET_BITS 64
70#include <stdio.h>
71#include <fcntl.h>
72#include <sys/types.h>
73#include <sys/wait.h>
74
75int main(void)
76{
77 struct flock lock;
78 int status;
79 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
80 lock.l_type = F_WRLCK;
81 lock.l_whence = SEEK_SET;
82 lock.l_start = 0;
83 lock.l_len = 1;
84 lock.l_pid = 0;
85
86 fcntl(fd,F_SETLK,&lock);
87 if (fork() == 0) {
88 lock.l_start = 1;
89 exit(fcntl(fd,F_SETLK,&lock) == 0);
90 }
91 wait(&status);
92 unlink("conftest.dat");
93 exit(WEXITSTATUS(status));
94}
95],
96rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
97if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
98 AC_SYS_LARGEFILE
99fi
100
101ipv6type=unknown
102ipv6lib=none
103ipv6trylibc=yes
104
105AC_ARG_ENABLE(ipv6,
106 AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
107
108if test "x$enable_ipv6" != xno
109then
110 AC_MSG_CHECKING([ipv6 stack type])
111 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
112 case $i in
113 inria)
114 # http://www.kame.net/
115 AC_EGREP_CPP(yes, [
116#include <netinet/in.h>
117#ifdef IPV6_INRIA_VERSION
118yes
119#endif],
120 [ipv6type=$i;
121 AC_DEFINE(INET6, 1, [true if you have IPv6])
122 ])
123 ;;
124 kame)
125 # http://www.kame.net/
126 AC_EGREP_CPP(yes, [
127#include <netinet/in.h>
128#ifdef __KAME__
129yes
130#endif],
131 [ipv6type=$i;
132 AC_DEFINE(INET6, 1, [true if you have IPv6])])
133 ;;
134 linux-glibc)
135 # http://www.v6.linux.or.jp/
136 AC_EGREP_CPP(yes, [
137#include <features.h>
138#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
139yes
140#endif],
141 [ipv6type=$i;
142AC_DEFINE(INET6, 1, [true if you have IPv6])])
143 ;;
144 linux-inet6)
145 # http://www.v6.linux.or.jp/
146 if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
147 ipv6type=$i
148 ipv6lib=inet6
149 ipv6libdir=/usr/inet6/lib
150 ipv6trylibc=yes;
151 AC_DEFINE(INET6, 1, [true if you have IPv6])
152 CFLAGS="-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 AC_DEFINE(INET6, 1, [true if you have IPv6])])
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 AC_DEFINE(INET6, 1, [true if you have IPv6])])
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 AC_DEFINE(INET6, 1, [true if you have IPv6])])
187 ;;
188 esac
189 if test "$ipv6type" != "unknown"; then
190 break
191 fi
192 done
193 AC_MSG_RESULT($ipv6type)
194
195 AC_SEARCH_LIBS(getaddrinfo, inet6)
196fi
197
198AC_C_BIGENDIAN
199AC_HEADER_DIRENT
200AC_HEADER_TIME
201AC_HEADER_SYS_WAIT
202AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
203AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
204AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
205AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
206AC_CHECK_HEADERS(netdb.h)
207
208AC_CHECK_SIZEOF(int)
209AC_CHECK_SIZEOF(long)
210AC_CHECK_SIZEOF(short)
211
212AC_C_INLINE
213
214AC_TYPE_SIGNAL
215AC_TYPE_UID_T
216AC_TYPE_MODE_T
217AC_TYPE_OFF_T
218AC_TYPE_SIZE_T
219AC_TYPE_PID_T
220AC_TYPE_GETGROUPS
221AC_CHECK_MEMBERS([struct stat.st_rdev])
222
223AC_CHECK_TYPE([ino_t], [unsigned])
224TYPE_SOCKLEN_T
225
226AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
227 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
228 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
229if test x"$rsync_cv_errno" = x"yes"; then
230 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
231fi
232
233# The following test taken from the cvs sources
234# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
235# These need checks to be before checks for any other functions that
236# might be in the same libraries.
237# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
238# libsocket.so which has a bad implementation of gethostbyname (it
239# only looks in /etc/hosts), so we only look for -lsocket if we need
240# it.
241AC_CHECK_FUNCS(connect)
242if test x"$ac_cv_func_connect" = x"no"; then
243 case "$LIBS" in
244 *-lnsl*) ;;
245 *) AC_CHECK_LIB(nsl_s, printf) ;;
246 esac
247 case "$LIBS" in
248 *-lnsl*) ;;
249 *) AC_CHECK_LIB(nsl, printf) ;;
250 esac
251 case "$LIBS" in
252 *-lsocket*) ;;
253 *) AC_CHECK_LIB(socket, connect) ;;
254 esac
255 case "$LIBS" in
256 *-linet*) ;;
257 *) AC_CHECK_LIB(inet, connect) ;;
258 esac
259 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
260 dnl has been cached.
261 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
262 test x"$ac_cv_lib_inet_connect" = x"yes"; then
263 # ac_cv_func_connect=yes
264 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
265 AC_DEFINE(HAVE_CONNECT, 1, [ ])
266 fi
267fi
268
269AC_CHECK_LIB(resolv, inet_ntop)
270
271AC_MSG_NOTICE([Looking in libraries: $LIBS])
272
273AC_CHECK_FUNC(inet_ntop, , AC_LIBOBJ(lib/inet_ntop))
274AC_CHECK_FUNC(inet_pton, , AC_LIBOBJ(lib/inet_pton))
275
276AC_CHECK_FUNC(getaddrinfo, , AC_LIBOBJ(lib/getaddrinfo))
277AC_CHECK_FUNC(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
278
279AC_CHECK_MEMBER([struct sockaddr.sa_len],
280 [ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
281 [],
282 [
283#include <sys/types.h>
284#include <sys/socket.h>
285])
286
287# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
288#
289AC_CHECK_FUNCS(strcasecmp)
290if test x"$ac_cv_func_strcasecmp" = x"no"; then
291 AC_CHECK_LIB(resolv, strcasecmp)
292fi
293
294AC_FUNC_MEMCMP
295AC_FUNC_UTIME_NULL
296AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
297AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
298AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
299AC_CHECK_FUNCS(strlcat strlcpy mtrace)
300
301AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
302AC_TRY_RUN([
303#include <sys/types.h>
304#include <sys/socket.h>
305
306main() {
307 int fd[2];
308 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
309}],
310rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
311if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
312 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
313fi
314
315AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
316AC_TRY_RUN([#include <fnmatch.h>
317main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
318 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
319rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
320if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
321 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
322fi
323
324if test x"$with_included_popt" != x"yes"
325then
326 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
327fi
328
329AC_MSG_CHECKING([whether to use included libpopt])
330if test x"$with_included_popt" = x"yes"
331then
332 AC_MSG_RESULT($srcdir/popt)
333 BUILD_POPT='$(popt_OBJS)'
334 CFLAGS="$CFLAGS -I$srcdir/popt"
335else
336 AC_MSG_RESULT(no)
337fi
338
339AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
340AC_TRY_RUN([#include <stdio.h>
341main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
342rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
343if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
344 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
345fi
346
347AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
348AC_TRY_RUN([#include <stdio.h>
349#include <sys/stat.h>
350main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
351rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
352if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
353 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
354fi
355
356AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
357AC_TRY_RUN([#include <stdio.h>
358#include <sys/types.h>
359#include <sys/stat.h>
360main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
361rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
362if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
363 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
364fi
365
366AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
367AC_TRY_RUN([#include <stdio.h>
368main() { char c; c=250; exit((c > 0)?0:1); }],
369rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
370if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
371 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
372fi
373
374AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
375AC_TRY_RUN([#include <sys/types.h>
376#include <dirent.h>
377main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
378if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
379di->d_name[0] == 0) exit(0); exit(1);} ],
380rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
381if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
382 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
383fi
384
385AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
386AC_TRY_COMPILE([#include <sys/types.h>
387#include <utime.h>],
388[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
389rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
390if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
391 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
392fi
393
394AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
395AC_TRY_RUN([
396#include <sys/time.h>
397#include <unistd.h>
398main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
399 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
400if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
401 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
402fi
403
404AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
405AC_TRY_RUN([
406#include <sys/types.h>
407#include <stdarg.h>
408void foo(const char *format, ...) {
409 va_list ap;
410 int len;
411 char buf[5];
412
413 va_start(ap, format);
414 len = vsnprintf(0, 0, format, ap);
415 va_end(ap);
416 if (len != 5) exit(1);
417
418 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
419
420 exit(0);
421}
422main() { foo("hello"); }
423],
424rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
425if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
426 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
427fi
428
429
430AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
431AC_TRY_RUN([#include <stdlib.h>
432#include <sys/types.h>
433#include <sys/stat.h>
434#include <unistd.h>
435main() {
436 struct stat st;
437 char tpl[20]="/tmp/test.XXXXXX";
438 int fd = mkstemp(tpl);
439 if (fd == -1) exit(1);
440 unlink(tpl);
441 if (fstat(fd, &st) != 0) exit(1);
442 if ((st.st_mode & 0777) != 0600) exit(1);
443 exit(0);
444}],
445rsync_cv_HAVE_SECURE_MKSTEMP=yes,
446rsync_cv_HAVE_SECURE_MKSTEMP=no,
447rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
448if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
449 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
450fi
451
452
453AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
454AC_TRY_RUN([
455#include <stdio.h>
456#include <sys/types.h>
457#include <netinet/in.h>
458#include <arpa/inet.h>
459main() { struct in_addr ip; ip.s_addr = 0x12345678;
460if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
461 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
462exit(0);}],
463 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
464if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
465 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
466fi
467
468
469AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
470AC_TRY_RUN([
471#include <stdio.h>
472#include <sys/types.h>
473#include <netinet/in.h>
474#include <arpa/inet.h>
475main() { struct in_addr ip;
476if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
477 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
478if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
479 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
480fi
481
482#
483# The following test was mostly taken from the tcl/tk plus patches
484#
485AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
486rm -rf conftest*
487cat > conftest.$ac_ext <<EOF
488int main() { return 0; }
489EOF
490${CC-cc} -c -o conftest..o conftest.$ac_ext
491if test -f conftest..o; then
492 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
493else
494 rsync_cv_DASHC_WORKS_WITH_DASHO=no
495fi
496rm -rf conftest*
497])
498if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
499 OBJ_SAVE="#"
500 OBJ_RESTORE="#"
501 CC_SHOBJ_FLAG='-o $@'
502else
503 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
504 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'
505 CC_SHOBJ_FLAG=""
506fi
507
508AC_SUBST(OBJ_SAVE)
509AC_SUBST(OBJ_RESTORE)
510AC_SUBST(CC_SHOBJ_FLAG)
511AC_SUBST(BUILD_POPT)
512
513AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
514AC_OUTPUT