use _S_IFLNK not S_IFLNK
[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)
8ee3d639 4AC_PREREQ(2.12)
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
6a48ca56 31# look for getconf early as this affects just about everything
ef325f0c
AT
32AC_CHECK_PROG(HAVE_GETCONF, getconf, "yes", "no")
33if test $HAVE_GETCONF = "yes"; then
34 CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS 2> /dev/null`
35 LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS 2> /dev/null`
6a48ca56
AT
36fi
37
2d1ebe9c
MP
38AC_ARG_WITH(included-popt,
39 [ --with-included-popt use bundled popt library, not from system])
40
c627d613
AT
41dnl Checks for programs.
42AC_PROG_CC
43AC_PROG_INSTALL
44AC_SUBST(SHELL)
45
7b8356d0
AT
46AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
47AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH)
48
3fa64fd0 49AC_SYS_LARGEFILE
cd957c70 50AC_C_BIGENDIAN
c627d613 51AC_HEADER_DIRENT
c627d613
AT
52AC_HEADER_TIME
53AC_HEADER_SYS_WAIT
8bf73749 54AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
94481d91 55AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
fdd71e17 56AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
8ee3d639 57AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
c627d613
AT
58
59AC_CHECK_SIZEOF(int)
60AC_CHECK_SIZEOF(long)
61AC_CHECK_SIZEOF(short)
62
63AC_C_INLINE
64
65AC_TYPE_SIGNAL
66AC_TYPE_UID_T
67AC_TYPE_MODE_T
68AC_TYPE_OFF_T
69AC_TYPE_SIZE_T
70AC_TYPE_PID_T
9422bb3f 71AC_TYPE_GETGROUPS
c627d613 72AC_STRUCT_ST_RDEV
dc5ddbcc 73AC_CHECK_TYPE(ino_t,unsigned)
c627d613 74
7b3d4257 75AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
7597e1a9 76 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
7b3d4257
AT
77 rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
78if test x"$rsync_cv_errno" = x"yes"; then
7597e1a9
AT
79 AC_DEFINE(HAVE_ERRNO_DECL)
80fi
c627d613 81
a784e10d
DD
82# The following test taken from the cvs sources
83# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
84# These need checks to be before checks for any other functions that
85# might be in the same libraries.
86# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
87# libsocket.so which has a bad implementation of gethostbyname (it
88# only looks in /etc/hosts), so we only look for -lsocket if we need
89# it.
90AC_CHECK_FUNCS(connect)
91if test x"$ac_cv_func_connect" = x"no"; then
92 case "$LIBS" in
93 *-lnsl*) ;;
94 *) AC_CHECK_LIB(nsl_s, printf) ;;
95 esac
96 case "$LIBS" in
97 *-lnsl*) ;;
98 *) AC_CHECK_LIB(nsl, printf) ;;
99 esac
100 case "$LIBS" in
101 *-lsocket*) ;;
102 *) AC_CHECK_LIB(socket, connect) ;;
103 esac
104 case "$LIBS" in
105 *-linet*) ;;
106 *) AC_CHECK_LIB(inet, connect) ;;
107 esac
108 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
109 dnl has been cached.
110 if test x"$ac_cv_lib_socket_connect" = x"yes" ||
111 test x"$ac_cv_lib_inet_connect" = x"yes"; then
112 # ac_cv_func_connect=yes
113 # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
114 AC_DEFINE(HAVE_CONNECT)
115 fi
116fi
117
118#
119# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
120#
121AC_CHECK_FUNCS(strcasecmp)
122if test x"$ac_cv_func_strcasecmp" = x"no"; then
123 AC_CHECK_LIB(resolv, strcasecmp)
124fi
125
c627d613 126AC_FUNC_MEMCMP
c627d613 127AC_FUNC_UTIME_NULL
e68f3481 128AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
e0414f42 129AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
79fc6bdb 130AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf setsid glob strpbrk)
8ee3d639 131AC_CHECK_FUNCS(strlcat strlcpy mtrace)
24c857f1
DD
132
133AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
134AC_TRY_RUN([#include <sys/types.h>
135 #include <sys/socket.h>
136 main() {
137 int fd[2];
138 exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
139 }],
140rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
141if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
142 AC_DEFINE(HAVE_SOCKETPAIR)
143fi
c627d613 144
79fc6bdb 145AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
c627d613 146AC_TRY_RUN([#include <fnmatch.h>
e7d6e0aa
AT
147main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
148 fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
79fc6bdb
DD
149rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
150if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
151 AC_DEFINE(HAVE_FNMATCH)
152fi
153
1ac15cd8
MP
154if test x"$with_included_popt" != x"yes"
155then
156 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
157fi
2d1ebe9c 158
1ac15cd8 159AC_MSG_CHECKING("whether to use included libpopt")
2d1ebe9c
MP
160if test x"$with_included_popt" = x"yes"
161then
1ac15cd8
MP
162 AC_MSG_RESULT("$srcdir/popt")
163 BUILD_POPT='$(popt_OBJS)'
164 CFLAGS="$CFLAGS -I $srcdir/popt"
2d1ebe9c
MP
165else
166 AC_MSG_RESULT(no)
79fc6bdb 167fi
c627d613 168
79fc6bdb 169AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
0d0e2e93 170AC_TRY_RUN([#include <stdio.h>
efb2f6bf 171main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
79fc6bdb
DD
172rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
173if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
7597e1a9
AT
174 AC_DEFINE(HAVE_LONGLONG)
175fi
0d0e2e93 176
7b3d4257 177AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
bcacc18b
AT
178AC_TRY_RUN([#include <stdio.h>
179#include <sys/stat.h>
7597e1a9 180main() { 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
181rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
182if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
7597e1a9
AT
183 AC_DEFINE(HAVE_OFF64_T)
184fi
debb4505 185
79fc6bdb 186AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
c29ee43d
AT
187AC_TRY_RUN([#include <stdio.h>
188#include <sys/types.h>
189#include <sys/stat.h>
190main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
79fc6bdb
DD
191rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
192if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
193 AC_DEFINE(HAVE_SHORT_INO_T)
194fi
c29ee43d 195
7b3d4257 196AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
debb4505
AT
197AC_TRY_RUN([#include <stdio.h>
198main() { char c; c=250; exit((c > 0)?0:1); }],
7b3d4257
AT
199rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
200if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
7597e1a9
AT
201 AC_DEFINE(HAVE_UNSIGNED_CHAR)
202fi
bcacc18b 203
7b3d4257 204AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
59503278
AT
205AC_TRY_RUN([#include <sys/types.h>
206#include <dirent.h>
207main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
208if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
7597e1a9 209di->d_name[0] == 0) exit(0); exit(1);} ],
7b3d4257
AT
210rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
211if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
7597e1a9
AT
212 AC_DEFINE(HAVE_BROKEN_READDIR)
213fi
1e9f155a 214
7b3d4257 215AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
d6e6ecbd
AT
216AC_TRY_COMPILE([#include <sys/types.h>
217#include <utime.h>],
7597e1a9 218[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
7b3d4257
AT
219rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
220if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
7597e1a9
AT
221 AC_DEFINE(HAVE_UTIMBUF)
222fi
d6e6ecbd 223
3060d4aa
AT
224AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
225AC_TRY_RUN([
226#include <sys/time.h>
227#include <unistd.h>
228main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
229 rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
230if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
231 AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
232fi
233
f62c17e3
AT
234AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
235AC_TRY_RUN([#include <stdlib.h>
236#include <sys/types.h>
237#include <sys/stat.h>
238#include <unistd.h>
239main() {
240 struct stat st;
241 char tpl[20]="/tmp/test.XXXXXX";
242 int fd = mkstemp(tpl);
243 if (fd == -1) exit(1);
244 unlink(tpl);
245 if (fstat(fd, &st) != 0) exit(1);
246 if ((st.st_mode & 0777) != 0600) exit(1);
247 exit(0);
248}],
249rsync_cv_HAVE_SECURE_MKSTEMP=yes,
250rsync_cv_HAVE_SECURE_MKSTEMP=no,
251rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
252if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
253 AC_DEFINE(HAVE_SECURE_MKSTEMP)
254fi
255
3060d4aa 256
7b3d4257
AT
257AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
258AC_TRY_RUN([
259#include <stdio.h>
260#include <sys/types.h>
261#include <netinet/in.h>
262#include <arpa/inet.h>
263main() { struct in_addr ip; ip.s_addr = 0x12345678;
264if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
fca3ef06
AT
265 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
266exit(0);}],
267 rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
7b3d4257
AT
268if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
269 AC_DEFINE(REPLACE_INET_NTOA)
270fi
271
fca3ef06
AT
272
273AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
274AC_TRY_RUN([
275#include <stdio.h>
276#include <sys/types.h>
277#include <netinet/in.h>
278#include <arpa/inet.h>
279main() { struct in_addr ip;
280if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
281 rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
282if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
283 AC_DEFINE(REPLACE_INET_ATON)
284fi
285
692da0b5
DD
286#
287# The following test was mostly taken from the tcl/tk plus patches
288#
79fc6bdb 289AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
692da0b5
DD
290rm -rf conftest*
291cat > conftest.$ac_ext <<EOF
292int main() { return 0; }
293EOF
294${CC-cc} -c -o conftest..o conftest.$ac_ext
295if test -f conftest..o; then
79fc6bdb
DD
296 rsync_cv_DASHC_WORKS_WITH_DASHO=yes
297else
298 rsync_cv_DASHC_WORKS_WITH_DASHO=no
299fi
300rm -rf conftest*
301])
302if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
692da0b5
DD
303 OBJ_SAVE="#"
304 OBJ_RESTORE="#"
305 CC_SHOBJ_FLAG='-o $@'
692da0b5
DD
306else
307 OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
308 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'
309 CC_SHOBJ_FLAG=""
692da0b5 310fi
79fc6bdb 311
692da0b5
DD
312AC_SUBST(OBJ_SAVE)
313AC_SUBST(OBJ_RESTORE)
314AC_SUBST(CC_SHOBJ_FLAG)
1ac15cd8 315AC_SUBST(BUILD_POPT)
7d29d4ba 316
db199cfa 317AC_OUTPUT(Makefile lib/dummy zlib/dummy)