Commit | Line | Data |
---|---|---|
c627d613 AT |
1 | dnl Process this file with autoconf to produce a configure script. |
2 | AC_INIT(byteorder.h) | |
3 | AC_CONFIG_HEADER(config.h) | |
7ca6e856 | 4 | AC_PREREQ(2.52) |
c627d613 | 5 | |
6a48ca56 | 6 | LDFLAGS=${LDFLAGS-""} |
50abd20b | 7 | |
8de330a3 AT |
8 | AC_CANONICAL_SYSTEM |
9 | AC_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 | ||
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 | ||
1ac15cd8 MP |
29 | CFLAGS="$CFLAGS -DHAVE_CONFIG_H" |
30 | ||
2d1ebe9c MP |
31 | AC_ARG_WITH(included-popt, |
32 | [ --with-included-popt use bundled popt library, not from system]) | |
33 | ||
41bd28fe | 34 | AC_ARG_WITH(rsync-path, |
ddd491d4 | 35 | [ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")], |
41bd28fe DD |
36 | [ RSYNC_PATH="$with_rsync_name" ], |
37 | [ RSYNC_PATH="rsync" ]) | |
c6a7f2f4 | 38 | AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ]) |
41bd28fe | 39 | |
c627d613 AT |
40 | dnl Checks for programs. |
41 | AC_PROG_CC | |
42 | AC_PROG_INSTALL | |
43 | AC_SUBST(SHELL) | |
44 | ||
7b8356d0 | 45 | AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0) |
d4e4cbe1 | 46 | AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [ ]) |
7b8356d0 | 47 | |
3fa64fd0 | 48 | AC_SYS_LARGEFILE |
cd957c70 | 49 | AC_C_BIGENDIAN |
c627d613 | 50 | AC_HEADER_DIRENT |
c627d613 AT |
51 | AC_HEADER_TIME |
52 | AC_HEADER_SYS_WAIT | |
8bf73749 | 53 | AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h) |
94481d91 | 54 | AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h) |
fdd71e17 | 55 | AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h) |
8ee3d639 | 56 | AC_CHECK_HEADERS(glob.h alloca.h mcheck.h) |
c627d613 AT |
57 | |
58 | AC_CHECK_SIZEOF(int) | |
59 | AC_CHECK_SIZEOF(long) | |
60 | AC_CHECK_SIZEOF(short) | |
61 | ||
62 | AC_C_INLINE | |
63 | ||
64 | AC_TYPE_SIGNAL | |
65 | AC_TYPE_UID_T | |
66 | AC_TYPE_MODE_T | |
67 | AC_TYPE_OFF_T | |
68 | AC_TYPE_SIZE_T | |
69 | AC_TYPE_PID_T | |
9422bb3f | 70 | AC_TYPE_GETGROUPS |
c627d613 | 71 | AC_STRUCT_ST_RDEV |
e2ba16cc | 72 | AC_CHECK_TYPE([ino_t], [unsigned]) |
7ca6e856 | 73 | TYPE_SOCKLEN_T |
c627d613 | 74 | |
7b3d4257 | 75 | AC_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)]) |
78 | if test x"$rsync_cv_errno" = x"yes"; then | |
d4e4cbe1 | 79 | AC_DEFINE(HAVE_ERRNO_DECL, 1, [ ]) |
7597e1a9 | 80 | fi |
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. | |
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 | |
d4e4cbe1 | 114 | AC_DEFINE(HAVE_CONNECT, 1, [ ]) |
a784e10d DD |
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 | ||
c627d613 | 126 | AC_FUNC_MEMCMP |
c627d613 | 127 | AC_FUNC_UTIME_NULL |
e68f3481 | 128 | AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod) |
e0414f42 | 129 | AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime) |
8950ac03 | 130 | AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk) |
8ee3d639 | 131 | AC_CHECK_FUNCS(strlcat strlcpy mtrace) |
24c857f1 DD |
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 | |
d4e4cbe1 | 142 | AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ]) |
24c857f1 | 143 | fi |
c627d613 | 144 | |
79fc6bdb | 145 | AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[ |
c627d613 | 146 | AC_TRY_RUN([#include <fnmatch.h> |
e7d6e0aa AT |
147 | main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 && |
148 | fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }], | |
79fc6bdb DD |
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 | |
d4e4cbe1 | 151 | AC_DEFINE(HAVE_FNMATCH, 1, [ ]) |
79fc6bdb DD |
152 | fi |
153 | ||
1ac15cd8 MP |
154 | if test x"$with_included_popt" != x"yes" |
155 | then | |
156 | AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes]) | |
157 | fi | |
2d1ebe9c | 158 | |
12458878 | 159 | AC_MSG_CHECKING([whether to use included libpopt]) |
2d1ebe9c MP |
160 | if test x"$with_included_popt" = x"yes" |
161 | then | |
12458878 | 162 | AC_MSG_RESULT($srcdir/popt) |
1ac15cd8 | 163 | BUILD_POPT='$(popt_OBJS)' |
26ef00bd | 164 | CFLAGS="$CFLAGS -I$srcdir/popt" |
2d1ebe9c MP |
165 | else |
166 | AC_MSG_RESULT(no) | |
79fc6bdb | 167 | fi |
c627d613 | 168 | |
79fc6bdb | 169 | AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[ |
0d0e2e93 | 170 | AC_TRY_RUN([#include <stdio.h> |
efb2f6bf | 171 | main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }], |
79fc6bdb DD |
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 | |
d4e4cbe1 | 174 | AC_DEFINE(HAVE_LONGLONG, 1, [ ]) |
7597e1a9 | 175 | fi |
0d0e2e93 | 176 | |
7b3d4257 | 177 | AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[ |
bcacc18b AT |
178 | AC_TRY_RUN([#include <stdio.h> |
179 | #include <sys/stat.h> | |
7597e1a9 | 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); }], |
7b3d4257 AT |
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 | |
d4e4cbe1 | 183 | AC_DEFINE(HAVE_OFF64_T, 1, [ ]) |
7597e1a9 | 184 | fi |
debb4505 | 185 | |
79fc6bdb | 186 | AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[ |
c29ee43d AT |
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; }], | |
79fc6bdb DD |
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 | |
d4e4cbe1 | 193 | AC_DEFINE(HAVE_SHORT_INO_T, 1, [ ]) |
79fc6bdb | 194 | fi |
c29ee43d | 195 | |
7b3d4257 | 196 | AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[ |
debb4505 AT |
197 | AC_TRY_RUN([#include <stdio.h> |
198 | main() { char c; c=250; exit((c > 0)?0:1); }], | |
7b3d4257 AT |
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 | |
d4e4cbe1 | 201 | AC_DEFINE(HAVE_UNSIGNED_CHAR, 1, [ ]) |
7597e1a9 | 202 | fi |
bcacc18b | 203 | |
7b3d4257 | 204 | AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[ |
59503278 AT |
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 && | |
7597e1a9 | 209 | di->d_name[0] == 0) exit(0); exit(1);} ], |
7b3d4257 AT |
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 | |
d4e4cbe1 | 212 | AC_DEFINE(HAVE_BROKEN_READDIR, 1, [ ]) |
7597e1a9 | 213 | fi |
1e9f155a | 214 | |
7b3d4257 | 215 | AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[ |
d6e6ecbd AT |
216 | AC_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 |
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 | |
d4e4cbe1 | 221 | AC_DEFINE(HAVE_UTIMBUF, 1, [ ]) |
7597e1a9 | 222 | fi |
d6e6ecbd | 223 | |
3060d4aa AT |
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 | |
d4e4cbe1 | 231 | AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [ ]) |
3060d4aa AT |
232 | fi |
233 | ||
8950ac03 AT |
234 | AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[ |
235 | AC_TRY_RUN([ | |
236 | #include <sys/types.h> | |
237 | #include <stdarg.h> | |
238 | void foo(const char *format, ...) { | |
239 | va_list ap; | |
240 | int len; | |
241 | char buf[5]; | |
242 | ||
243 | va_start(ap, format); | |
244 | len = vsnprintf(0, 0, format, ap); | |
245 | va_end(ap); | |
246 | if (len != 5) exit(1); | |
247 | ||
248 | if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); | |
249 | ||
250 | exit(0); | |
251 | } | |
252 | main() { foo("hello"); } | |
253 | ], | |
254 | rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)]) | |
255 | if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then | |
d4e4cbe1 | 256 | AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) |
8950ac03 AT |
257 | fi |
258 | ||
259 | ||
f62c17e3 AT |
260 | AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[ |
261 | AC_TRY_RUN([#include <stdlib.h> | |
262 | #include <sys/types.h> | |
263 | #include <sys/stat.h> | |
264 | #include <unistd.h> | |
265 | main() { | |
266 | struct stat st; | |
267 | char tpl[20]="/tmp/test.XXXXXX"; | |
268 | int fd = mkstemp(tpl); | |
269 | if (fd == -1) exit(1); | |
270 | unlink(tpl); | |
271 | if (fstat(fd, &st) != 0) exit(1); | |
272 | if ((st.st_mode & 0777) != 0600) exit(1); | |
273 | exit(0); | |
274 | }], | |
275 | rsync_cv_HAVE_SECURE_MKSTEMP=yes, | |
276 | rsync_cv_HAVE_SECURE_MKSTEMP=no, | |
277 | rsync_cv_HAVE_SECURE_MKSTEMP=cross)]) | |
278 | if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then | |
d4e4cbe1 | 279 | AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [ ]) |
f62c17e3 AT |
280 | fi |
281 | ||
3060d4aa | 282 | |
7b3d4257 AT |
283 | AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[ |
284 | AC_TRY_RUN([ | |
285 | #include <stdio.h> | |
286 | #include <sys/types.h> | |
287 | #include <netinet/in.h> | |
288 | #include <arpa/inet.h> | |
289 | main() { struct in_addr ip; ip.s_addr = 0x12345678; | |
290 | if (strcmp(inet_ntoa(ip),"18.52.86.120") && | |
fca3ef06 AT |
291 | strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); } |
292 | exit(0);}], | |
293 | rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)]) | |
7b3d4257 | 294 | if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then |
d4e4cbe1 | 295 | AC_DEFINE(REPLACE_INET_NTOA, 1, [ ]) |
7b3d4257 AT |
296 | fi |
297 | ||
fca3ef06 AT |
298 | |
299 | AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[ | |
300 | AC_TRY_RUN([ | |
301 | #include <stdio.h> | |
302 | #include <sys/types.h> | |
303 | #include <netinet/in.h> | |
304 | #include <arpa/inet.h> | |
305 | main() { struct in_addr ip; | |
306 | if (inet_aton("example", &ip) == 0) exit(0); exit(1);}], | |
307 | rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)]) | |
308 | if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then | |
d4e4cbe1 | 309 | AC_DEFINE(REPLACE_INET_ATON, 1, [ ]) |
fca3ef06 AT |
310 | fi |
311 | ||
692da0b5 DD |
312 | # |
313 | # The following test was mostly taken from the tcl/tk plus patches | |
314 | # | |
79fc6bdb | 315 | AC_CACHE_CHECK([whether -c -o works],rsync_cv_DASHC_WORKS_WITH_DASHO,[ |
692da0b5 DD |
316 | rm -rf conftest* |
317 | cat > conftest.$ac_ext <<EOF | |
318 | int main() { return 0; } | |
319 | EOF | |
320 | ${CC-cc} -c -o conftest..o conftest.$ac_ext | |
321 | if test -f conftest..o; then | |
79fc6bdb DD |
322 | rsync_cv_DASHC_WORKS_WITH_DASHO=yes |
323 | else | |
324 | rsync_cv_DASHC_WORKS_WITH_DASHO=no | |
325 | fi | |
326 | rm -rf conftest* | |
327 | ]) | |
328 | if test x"$rsync_cv_DASHC_WORKS_WITH_DASHO" = x"yes"; then | |
692da0b5 DD |
329 | OBJ_SAVE="#" |
330 | OBJ_RESTORE="#" | |
331 | CC_SHOBJ_FLAG='-o $@' | |
692da0b5 DD |
332 | else |
333 | OBJ_SAVE=' @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;' | |
334 | 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' | |
335 | CC_SHOBJ_FLAG="" | |
692da0b5 | 336 | fi |
79fc6bdb | 337 | |
692da0b5 DD |
338 | AC_SUBST(OBJ_SAVE) |
339 | AC_SUBST(OBJ_RESTORE) | |
340 | AC_SUBST(CC_SHOBJ_FLAG) | |
1ac15cd8 | 341 | AC_SUBST(BUILD_POPT) |
7d29d4ba | 342 | |
db199cfa | 343 | AC_OUTPUT(Makefile lib/dummy zlib/dummy) |