1 dnl Process this file with autoconf to produce a configure script.
3 AC_CONFIG_HEADER(config.h)
9 AC_VALIDATE_CACHE_SYSTEM_TYPE
11 # compile with optimisation and without debugging by default, unless
12 # --debug is given. We must decide this before testing the compiler.
15 [ --enable-debug including debugging symbols and features])
17 AC_MSG_CHECKING([whether to include debugging symbols])
18 if test x"$enable_debug" = x"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])
29 CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
31 AC_ARG_WITH(included-popt,
32 [ --with-included-popt use bundled popt library, not from system])
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", [ ])
40 dnl Checks for programs.
45 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
46 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ])
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,[
53 #define _FILE_OFFSET_BITS 64
56 #include <sys/types.h>
63 int fd = open("conftest.dat", O_CREAT|O_RDWR, 0600);
64 lock.l_type = F_WRLCK;
65 lock.l_whence = SEEK_SET;
70 fcntl(fd,F_SETLK,&lock);
73 exit(fcntl(fd,F_SETLK,&lock) == 0);
76 unlink("conftest.dat");
77 exit(WEXITSTATUS(status));
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
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)
98 AC_CHECK_SIZEOF(short)
110 AC_CHECK_TYPE([ino_t], [unsigned])
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, [ ])
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
128 AC_CHECK_FUNCS(connect)
129 if test x"$ac_cv_func_connect" = x"no"; then
132 *) AC_CHECK_LIB(nsl_s, printf) ;;
136 *) AC_CHECK_LIB(nsl, printf) ;;
140 *) AC_CHECK_LIB(socket, connect) ;;
144 *) AC_CHECK_LIB(inet, connect) ;;
146 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
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, [ ])
157 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
159 AC_CHECK_FUNCS(strcasecmp)
160 if test x"$ac_cv_func_strcasecmp" = x"no"; then
161 AC_CHECK_LIB(resolv, strcasecmp)
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)
171 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
172 AC_TRY_RUN([#include <sys/types.h>
173 #include <sys/socket.h>
176 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
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, [ ])
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, [ ])
192 if test x"$with_included_popt" != x"yes"
194 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
197 AC_MSG_CHECKING([whether to use included libpopt])
198 if test x"$with_included_popt" = x"yes"
200 AC_MSG_RESULT($srcdir/popt)
201 BUILD_POPT='$(popt_OBJS)'
202 CFLAGS="$CFLAGS -I$srcdir/popt"
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, [ ])
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, [ ])
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, [ ])
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, [ ])
242 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
243 AC_TRY_RUN([#include <sys/types.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, [ ])
253 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
254 AC_TRY_COMPILE([#include <sys/types.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, [ ])
262 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
264 #include <sys/time.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, [ ])
272 AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
274 #include <sys/types.h>
276 void foo(const char *format, ...) {
281 va_start(ap, format);
282 len = vsnprintf(0, 0, format, ap);
284 if (len != 5) exit(1);
286 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
290 main() { foo("hello"); }
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, [ ])
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>
305 char tpl[20]="/tmp/test.XXXXXX";
306 int fd = mkstemp(tpl);
307 if (fd == -1) exit(1);
309 if (fstat(fd, &st) != 0) exit(1);
310 if ((st.st_mode & 0777) != 0600) exit(1);
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, [ ])
321 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
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); }
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, [ ])
337 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
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, [ ])
351 # The following test was mostly taken from the tcl/tk plus patches
353 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
355 cat > conftest.$ac_ext <<EOF
356 int main() { return 0; }
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
362 rsync_cv_DASHC_WORKS_WITH_DASHO=no
366 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
369 CC_SHOBJ_FLAG='-o $@'
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'
377 AC_SUBST(OBJ_RESTORE)
378 AC_SUBST(CC_SHOBJ_FLAG)
381 AC_OUTPUT(Makefile lib/dummy zlib/dummy popt/dummy shconfig)