Fix to make_file() to exit earlier if a file is excluded, because doing
[rsync/rsync.git] / configure.in
CommitLineData
c627d613
AT
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(byteorder.h)
3AC_CONFIG_HEADER(config.h)
7ca6e856 4AC_PREREQ(2.52)
c627d613 5
6a48ca56 6LDFLAGS=${LDFLAGS-""}
50abd20b 7
8de330a3
AT
8AC_CANONICAL_SYSTEM
9AC_VALIDATE_CACHE_SYSTEM_TYPE
10
2d1ebe9c
MP
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
1ac15cd8
MP
29CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
30
2d1ebe9c
MP
31AC_ARG_WITH(included-popt,
32 [ --with-included-popt use bundled popt library, not from system])
33
41bd28fe 34AC_ARG_WITH(rsync-path,
ddd491d4 35 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
8642efd0 36 [ RSYNC_PATH="$with_rsync_path" ],
41bd28fe 37 [ RSYNC_PATH="rsync" ])
c6a7f2f4 38AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
41bd28fe 39
c627d613
AT
40dnl Checks for programs.
41AC_PROG_CC
42AC_PROG_INSTALL
43AC_SUBST(SHELL)
44
7b8356d0 45AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
d4e4cbe1 46AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
7b8356d0 47
f0af1e5e
AT
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
cd957c70 87AC_C_BIGENDIAN
c627d613 88AC_HEADER_DIRENT
c627d613
AT
89AC_HEADER_TIME
90AC_HEADER_SYS_WAIT
8bf73749 91AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
94481d91 92AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
fdd71e17 93AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
8ee3d639 94AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
c627d613
AT
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
9422bb3f 108AC_TYPE_GETGROUPS
c627d613 109AC_STRUCT_ST_RDEV
e2ba16cc 110AC_CHECK_TYPE([ino_t], [unsigned])
7ca6e856 111TYPE_SOCKLEN_T
c627d613 112
7b3d4257 113AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
7597e1a9 114 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
7b3d4257
AT
115 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
116if test x"$rsync_cv_errno" = x"yes"; then
d4e4cbe1 117 AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
7597e1a9 118fi
c627d613 119
a784e10d
DD
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
d4e4cbe1 152 AC_DEFINE(HAVE_CONNECT, 1, [ ])
a784e10d
DD
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
c627d613 164AC_FUNC_MEMCMP
c627d613 165AC_FUNC_UTIME_NULL
e68f3481 166AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
e0414f42 167AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
8950ac03 168AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
8ee3d639 169AC_CHECK_FUNCS(strlcat strlcpy mtrace)
24c857f1
DD
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
d4e4cbe1 180 AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
24c857f1 181fi
c627d613 182
79fc6bdb 183AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
c627d613 184AC_TRY_RUN([#include <fnmatch.h>
e7d6e0aa
AT
185main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
186 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
79fc6bdb
DD
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
d4e4cbe1 189 AC_DEFINE(HAVE_FNMATCH, 1, [ ])
79fc6bdb
DD
190fi
191
1ac15cd8
MP
192if test x"$with_included_popt" != x"yes"
193then
194 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
195fi
2d1ebe9c 196
12458878 197AC_MSG_CHECKING([whether to use included libpopt])
2d1ebe9c
MP
198if test x"$with_included_popt" = x"yes"
199then
12458878 200 AC_MSG_RESULT($srcdir/popt)
1ac15cd8 201 BUILD_POPT='$(popt_OBJS)'
26ef00bd 202 CFLAGS="$CFLAGS -I$srcdir/popt"
2d1ebe9c
MP
203else
204 AC_MSG_RESULT(no)
79fc6bdb 205fi
c627d613 206
79fc6bdb 207AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
0d0e2e93 208AC_TRY_RUN([#include <stdio.h>
efb2f6bf 209main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
79fc6bdb
DD
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
d4e4cbe1 212 AC_DEFINE(HAVE_LONGLONG, 1, [ ])
7597e1a9 213fi
0d0e2e93 214
7b3d4257 215AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
bcacc18b
AT
216AC_TRY_RUN([#include <stdio.h>
217#include <sys/stat.h>
7597e1a9 218main() { 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
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
d4e4cbe1 221 AC_DEFINE(HAVE_OFF64_T, 1, [ ])
7597e1a9 222fi
debb4505 223
79fc6bdb 224AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
c29ee43d
AT
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; }],
79fc6bdb
DD
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
d4e4cbe1 231 AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
79fc6bdb 232fi
c29ee43d 233
7b3d4257 234AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
debb4505
AT
235AC_TRY_RUN([#include <stdio.h>
236main() { char c; c=250; exit((c > 0)?0:1); }],
7b3d4257
AT
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
d4e4cbe1 239 AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
7597e1a9 240fi
bcacc18b 241
7b3d4257 242AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
59503278
AT
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 &&
7597e1a9 247di->d_name[0] == 0) exit(0); exit(1);} ],
7b3d4257
AT
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
d4e4cbe1 250 AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
7597e1a9 251fi
1e9f155a 252
7b3d4257 253AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
d6e6ecbd
AT
254AC_TRY_COMPILE([#include <sys/types.h>
255#include <utime.h>],
7597e1a9 256[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
7b3d4257
AT
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
d4e4cbe1 259 AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
7597e1a9 260fi
d6e6ecbd 261
3060d4aa
AT
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
d4e4cbe1 269 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
3060d4aa
AT
270fi
271
8950ac03
AT
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
d4e4cbe1 294 AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
8950ac03
AT
295fi
296
297
f62c17e3
AT
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
d4e4cbe1 317 AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
f62c17e3
AT
318fi
319
3060d4aa 320
7b3d4257
AT
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") &&
fca3ef06
AT
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)])
7b3d4257 332if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
d4e4cbe1 333 AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
7b3d4257
AT
334fi
335
fca3ef06
AT
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
d4e4cbe1 347 AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
fca3ef06
AT
348fi
349
692da0b5
DD
350#
351# The following test was mostly taken from the tcl/tk plus patches
352#
79fc6bdb 353AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
692da0b5
DD
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
79fc6bdb
DD
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
692da0b5
DD
367 OBJ_SAVE="#"
368 OBJ_RESTORE="#"
369 CC_SHOBJ_FLAG='-o $@'
692da0b5
DD
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=""
692da0b5 374fi
79fc6bdb 375
692da0b5
DD
376AC_SUBST(OBJ_SAVE)
377AC_SUBST(OBJ_RESTORE)
378AC_SUBST(CC_SHOBJ_FLAG)
1ac15cd8 379AC_SUBST(BUILD_POPT)
7d29d4ba 380
d2e02b7d 381AC_OUTPUT(Makefile lib/dummy zlib/dummy popt/dummy shconfig)