Fix to make_file() to exit earlier if a file is excluded, because doing
[rsync/rsync.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(byteorder.h)
3 AC_CONFIG_HEADER(config.h)
4 AC_PREREQ(2.52)
5
6 LDFLAGS=${LDFLAGS-""}
7
8 AC_CANONICAL_SYSTEM
9 AC_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
14 AC_ARG_ENABLE(debug,
15         [  --enable-debug          including debugging symbols and features])
16
17 AC_MSG_CHECKING([whether to include debugging symbols])
18 if test x"$enable_debug" = x"yes"
19 then
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"}
24 else
25     AC_MSG_RESULT(no)
26     CFLAGS=${CFLAGS-"-O"}
27 fi
28
29 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
30
31 AC_ARG_WITH(included-popt,
32         [  --with-included-popt    use bundled popt library, not from system])
33
34 AC_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" ])
38 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
39
40 dnl Checks for programs.
41 AC_PROG_CC
42 AC_PROG_INSTALL
43 AC_SUBST(SHELL)
44
45 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
46 AC_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
51 AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
52 AC_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
59 int 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 ],
80 rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
81 if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
82    AC_SYS_LARGEFILE
83 fi
84
85
86
87 AC_C_BIGENDIAN
88 AC_HEADER_DIRENT
89 AC_HEADER_TIME
90 AC_HEADER_SYS_WAIT
91 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
92 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
93 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
94 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
95
96 AC_CHECK_SIZEOF(int)
97 AC_CHECK_SIZEOF(long)
98 AC_CHECK_SIZEOF(short)
99
100 AC_C_INLINE
101
102 AC_TYPE_SIGNAL
103 AC_TYPE_UID_T
104 AC_TYPE_MODE_T
105 AC_TYPE_OFF_T
106 AC_TYPE_SIZE_T
107 AC_TYPE_PID_T
108 AC_TYPE_GETGROUPS
109 AC_STRUCT_ST_RDEV
110 AC_CHECK_TYPE([ino_t], [unsigned])
111 TYPE_SOCKLEN_T
112
113 AC_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)])
116 if test x"$rsync_cv_errno" = x"yes"; then
117    AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ])
118 fi
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.
128 AC_CHECK_FUNCS(connect)
129 if 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
154 fi
155
156
157 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
158 #
159 AC_CHECK_FUNCS(strcasecmp)
160 if test x"$ac_cv_func_strcasecmp" = x"no"; then
161     AC_CHECK_LIB(resolv, strcasecmp)
162 fi
163
164 AC_FUNC_MEMCMP
165 AC_FUNC_UTIME_NULL
166 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
167 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
168 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
169 AC_CHECK_FUNCS(strlcat strlcpy mtrace)
170
171 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
172 AC_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             }],
178 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
179 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
180     AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
181 fi
182
183 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
184 AC_TRY_RUN([#include <fnmatch.h>
185 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
186                fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
187 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
188 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
189     AC_DEFINE(HAVE_FNMATCH, 1, [ ])
190 fi
191
192 if test x"$with_included_popt" != x"yes"
193 then
194     AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
195 fi
196
197 AC_MSG_CHECKING([whether to use included libpopt])
198 if test x"$with_included_popt" = x"yes"
199 then
200     AC_MSG_RESULT($srcdir/popt)
201     BUILD_POPT='$(popt_OBJS)'
202     CFLAGS="$CFLAGS -I$srcdir/popt"
203 else
204     AC_MSG_RESULT(no)
205 fi
206
207 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
208 AC_TRY_RUN([#include <stdio.h>
209 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
210 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
211 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
212     AC_DEFINE(HAVE_LONGLONG, 1, [ ])
213 fi
214
215 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
216 AC_TRY_RUN([#include <stdio.h>
217 #include <sys/stat.h>
218 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
219 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
220 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
221     AC_DEFINE(HAVE_OFF64_T, 1, [ ])
222 fi
223
224 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
225 AC_TRY_RUN([#include <stdio.h>
226 #include <sys/types.h>
227 #include <sys/stat.h>
228 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
229 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
230 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
231     AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ])
232 fi
233
234 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
235 AC_TRY_RUN([#include <stdio.h>
236 main() { char c; c=250; exit((c > 0)?0:1); }],
237 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
238 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
239     AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ])
240 fi
241
242 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
243 AC_TRY_RUN([#include <sys/types.h>
244 #include <dirent.h>
245 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
246 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
247 di->d_name[0] == 0) exit(0); exit(1);} ],
248 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
249 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
250     AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ])
251 fi
252
253 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
254 AC_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));],
257 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
258 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
259     AC_DEFINE(HAVE_UTIMBUF, 1, [ ])
260 fi
261
262 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
263 AC_TRY_RUN([
264 #include <sys/time.h>
265 #include <unistd.h>
266 main() { 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)])
268 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
269     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ])
270 fi
271
272 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
273 AC_TRY_RUN([
274 #include <sys/types.h>
275 #include <stdarg.h>
276 void 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 }
290 main() { foo("hello"); }
291 ],
292 rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
293 if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
294     AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
295 fi
296
297
298 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
299 AC_TRY_RUN([#include <stdlib.h>
300 #include <sys/types.h>
301 #include <sys/stat.h>
302 #include <unistd.h>
303 main() { 
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 }],
313 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
314 rsync_cv_HAVE_SECURE_MKSTEMP=no,
315 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
316 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
317     AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ])
318 fi
319
320
321 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
322 AC_TRY_RUN([
323 #include <stdio.h>
324 #include <sys/types.h>
325 #include <netinet/in.h>
326 #include <arpa/inet.h>
327 main() { struct in_addr ip; ip.s_addr = 0x12345678;
328 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
329     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); } 
330 exit(0);}],
331            rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
332 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
333     AC_DEFINE(REPLACE_INET_NTOA, 1, [ ])
334 fi
335
336
337 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
338 AC_TRY_RUN([
339 #include <stdio.h>
340 #include <sys/types.h>
341 #include <netinet/in.h>
342 #include <arpa/inet.h>
343 main() { struct in_addr ip; 
344 if (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)])
346 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
347     AC_DEFINE(REPLACE_INET_ATON, 1, [ ])
348 fi
349
350 #
351 # The following test was mostly taken from the tcl/tk plus patches
352 #
353 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
354 rm -rf conftest*
355 cat > conftest.$ac_ext <<EOF
356 int main() { return 0; }
357 EOF
358 ${CC-cc} -c -o conftest..o conftest.$ac_ext
359 if test -f conftest..o; then
360     rsync_cv_DASHC_WORKS_WITH_DASHO=yes
361 else
362     rsync_cv_DASHC_WORKS_WITH_DASHO=no
363 fi
364 rm -rf conftest*
365 ])
366 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
367     OBJ_SAVE="#"
368     OBJ_RESTORE="#"
369     CC_SHOBJ_FLAG='-o $@'
370 else
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=""
374 fi
375
376 AC_SUBST(OBJ_SAVE)
377 AC_SUBST(OBJ_RESTORE)
378 AC_SUBST(CC_SHOBJ_FLAG)
379 AC_SUBST(BUILD_POPT)
380
381 AC_OUTPUT(Makefile lib/dummy zlib/dummy popt/dummy shconfig)