no space after -I or Tru64 barfs
[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.12)
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 # look for getconf early as this affects just about everything
32 AC_CHECK_PROG(HAVE_GETCONF, getconf, "yes", "no")
33 if test $HAVE_GETCONF = "yes"; then
34         CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS 2> /dev/null`
35         LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS 2> /dev/null`
36 fi
37
38 AC_ARG_WITH(included-popt,
39         [  --with-included-popt    use bundled popt library, not from system])
40
41 dnl Checks for programs.
42 AC_PROG_CC
43 AC_PROG_INSTALL
44 AC_SUBST(SHELL)
45
46 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
47 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH)
48
49 AC_SYS_LARGEFILE
50 AC_C_BIGENDIAN
51 AC_HEADER_DIRENT
52 AC_HEADER_TIME
53 AC_HEADER_SYS_WAIT
54 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
55 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
56 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
57 AC_CHECK_HEADERS(glob.h alloca.h mcheck.h)
58
59 AC_CHECK_SIZEOF(int)
60 AC_CHECK_SIZEOF(long)
61 AC_CHECK_SIZEOF(short)
62
63 AC_C_INLINE
64
65 AC_TYPE_SIGNAL
66 AC_TYPE_UID_T
67 AC_TYPE_MODE_T
68 AC_TYPE_OFF_T
69 AC_TYPE_SIZE_T
70 AC_TYPE_PID_T
71 AC_TYPE_GETGROUPS
72 AC_STRUCT_ST_RDEV
73 AC_CHECK_TYPE(ino_t,unsigned)
74
75 AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
76     AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
77         rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
78 if test x"$rsync_cv_errno" = x"yes"; then
79    AC_DEFINE(HAVE_ERRNO_DECL)
80 fi
81
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.
90 AC_CHECK_FUNCS(connect)
91 if 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
116 fi
117
118
119 # if we can't find strcasecmp, look in -lresolv (for Unixware at least)
120 #
121 AC_CHECK_FUNCS(strcasecmp)
122 if test x"$ac_cv_func_strcasecmp" = x"no"; then
123     AC_CHECK_LIB(resolv, strcasecmp)
124 fi
125
126 AC_FUNC_MEMCMP
127 AC_FUNC_UTIME_NULL
128 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
129 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
130 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf setsid glob strpbrk)
131 AC_CHECK_FUNCS(strlcat strlcpy mtrace)
132
133 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
134 AC_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             }],
140 rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
141 if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
142     AC_DEFINE(HAVE_SOCKETPAIR)
143 fi
144
145 AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
146 AC_TRY_RUN([#include <fnmatch.h>
147 main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
148                fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
149 rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
150 if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
151     AC_DEFINE(HAVE_FNMATCH)
152 fi
153
154 if test x"$with_included_popt" != x"yes"
155 then
156     AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
157 fi
158
159 AC_MSG_CHECKING("whether to use included libpopt")
160 if test x"$with_included_popt" = x"yes"
161 then
162     AC_MSG_RESULT("$srcdir/popt")
163     BUILD_POPT='$(popt_OBJS)'
164     CFLAGS="$CFLAGS -I$srcdir/popt"
165 else
166     AC_MSG_RESULT(no)
167 fi
168
169 AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
170 AC_TRY_RUN([#include <stdio.h>
171 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
172 rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
173 if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
174     AC_DEFINE(HAVE_LONGLONG)
175 fi
176
177 AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
178 AC_TRY_RUN([#include <stdio.h>
179 #include <sys/stat.h>
180 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
181 rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
182 if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
183     AC_DEFINE(HAVE_OFF64_T)
184 fi
185
186 AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
187 AC_TRY_RUN([#include <stdio.h>
188 #include <sys/types.h>
189 #include <sys/stat.h>
190 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
191 rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
192 if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
193     AC_DEFINE(HAVE_SHORT_INO_T)
194 fi
195
196 AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
197 AC_TRY_RUN([#include <stdio.h>
198 main() { char c; c=250; exit((c > 0)?0:1); }],
199 rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
200 if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
201     AC_DEFINE(HAVE_UNSIGNED_CHAR)
202 fi
203
204 AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
205 AC_TRY_RUN([#include <sys/types.h>
206 #include <dirent.h>
207 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
208 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
209 di->d_name[0] == 0) exit(0); exit(1);} ],
210 rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
211 if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
212     AC_DEFINE(HAVE_BROKEN_READDIR)
213 fi
214
215 AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
216 AC_TRY_COMPILE([#include <sys/types.h>
217 #include <utime.h>],
218 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
219 rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
220 if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
221     AC_DEFINE(HAVE_UTIMBUF)
222 fi
223
224 AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
225 AC_TRY_RUN([
226 #include <sys/time.h>
227 #include <unistd.h>
228 main() { 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)])
230 if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
231     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
232 fi
233
234 AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
235 AC_TRY_RUN([#include <stdlib.h>
236 #include <sys/types.h>
237 #include <sys/stat.h>
238 #include <unistd.h>
239 main() { 
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 }],
249 rsync_cv_HAVE_SECURE_MKSTEMP=yes,
250 rsync_cv_HAVE_SECURE_MKSTEMP=no,
251 rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
252 if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
253     AC_DEFINE(HAVE_SECURE_MKSTEMP)
254 fi
255
256
257 AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
258 AC_TRY_RUN([
259 #include <stdio.h>
260 #include <sys/types.h>
261 #include <netinet/in.h>
262 #include <arpa/inet.h>
263 main() { struct in_addr ip; ip.s_addr = 0x12345678;
264 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
265     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); } 
266 exit(0);}],
267            rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
268 if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
269     AC_DEFINE(REPLACE_INET_NTOA)
270 fi
271
272
273 AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
274 AC_TRY_RUN([
275 #include <stdio.h>
276 #include <sys/types.h>
277 #include <netinet/in.h>
278 #include <arpa/inet.h>
279 main() { struct in_addr ip; 
280 if (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)])
282 if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
283     AC_DEFINE(REPLACE_INET_ATON)
284 fi
285
286 #
287 # The following test was mostly taken from the tcl/tk plus patches
288 #
289 AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[
290 rm -rf conftest*
291 cat > conftest.$ac_ext <<EOF
292 int main() { return 0; }
293 EOF
294 ${CC-cc} -c -o conftest..o conftest.$ac_ext
295 if test -f conftest..o; then
296     rsync_cv_DASHC_WORKS_WITH_DASHO=yes
297 else
298     rsync_cv_DASHC_WORKS_WITH_DASHO=no
299 fi
300 rm -rf conftest*
301 ])
302 if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then
303     OBJ_SAVE="#"
304     OBJ_RESTORE="#"
305     CC_SHOBJ_FLAG='-o $@'
306 else
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=""
310 fi
311
312 AC_SUBST(OBJ_SAVE)
313 AC_SUBST(OBJ_RESTORE)
314 AC_SUBST(CC_SHOBJ_FLAG)
315 AC_SUBST(BUILD_POPT)
316
317 AC_OUTPUT(Makefile lib/dummy zlib/dummy)