Fix for systems such as Unixware that have a cc that does not support -o
[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
5 AC_CANONICAL_SYSTEM
6 AC_VALIDATE_CACHE_SYSTEM_TYPE
7
8 dnl Checks for programs.
9 AC_PROG_CC
10 AC_PROG_INSTALL
11 AC_SUBST(SHELL)
12
13 AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
14 AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH)
15
16 AC_HEADER_DIRENT
17 AC_HEADER_TIME
18 AC_HEADER_SYS_WAIT
19 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
20 AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
21 AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
22 AC_CHECK_HEADERS(glob.h)
23
24 AC_CHECK_SIZEOF(int)
25 AC_CHECK_SIZEOF(long)
26 AC_CHECK_SIZEOF(short)
27
28 AC_C_INLINE
29
30 AC_TYPE_SIGNAL
31 AC_TYPE_UID_T
32 AC_TYPE_MODE_T
33 AC_TYPE_OFF_T
34 AC_TYPE_SIZE_T
35 AC_TYPE_PID_T
36 AC_STRUCT_ST_RDEV
37 AC_CHECK_TYPE(ino_t,unsigned)
38
39 echo $ac_n "checking for errno in errno.h... $ac_c"
40 AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
41 echo yes; AC_DEFINE(HAVE_ERRNO_DECL),
42 echo no)
43
44 AC_FUNC_MEMCMP
45 AC_FUNC_UTIME_NULL
46 AC_CHECK_FUNCS(mmap munmap waitpid getcwd strdup strerror chown chmod mknod)
47 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
48 AC_CHECK_FUNCS(memmove getopt_long lchown vsnprintf snprintf setsid glob strpbrk)
49
50 echo $ac_n "checking for working fnmatch... $ac_c"
51 AC_TRY_RUN([#include <fnmatch.h>
52 main() { exit(fnmatch("*.o", "x.o", 0) == 0? 0: 1); }],
53 echo yes;AC_DEFINE(HAVE_FNMATCH), 
54 echo no)
55
56 echo $ac_n "checking for long long ... $ac_c"
57 AC_TRY_RUN([#include <stdio.h>
58 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
59 echo yes;AC_DEFINE(HAVE_LONGLONG), 
60 echo no)
61
62 echo $ac_n "checking for off64_t ... $ac_c"
63 AC_TRY_RUN([#include <stdio.h>
64 #include <sys/stat.h>
65 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; exit((lstat64("/dev/null", &st)==0)?0:1); }],
66 echo yes;AC_DEFINE(HAVE_OFF64_T), 
67 echo no)
68
69 echo $ac_n "checking for short ino_t ... $ac_c"
70 AC_TRY_RUN([#include <stdio.h>
71 #include <sys/types.h>
72 #include <sys/stat.h>
73 main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
74 echo yes;AC_DEFINE(HAVE_SHORT_INO_T), 
75 echo no)
76
77 echo $ac_n "checking for unsigned char ... $ac_c"
78 AC_TRY_RUN([#include <stdio.h>
79 main() { char c; c=250; exit((c > 0)?0:1); }],
80 echo yes;AC_DEFINE(HAVE_UNSIGNED_CHAR), 
81 echo no)
82
83 echo $ac_n "checking for broken readdir ... $ac_c"
84 AC_TRY_RUN([#include <sys/types.h>
85 #include <dirent.h>
86 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
87 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
88 di->d_name[0] == 0) return 0; return 1;} ],
89 echo yes - you are using the broken /usr/ucb/cc;AC_DEFINE(HAVE_BROKEN_READDIR), 
90 echo no)
91
92 echo $ac_n "checking for utimbuf ... $ac_c"
93 AC_TRY_COMPILE([#include <sys/types.h>
94 #include <utime.h>],
95 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
96 echo yes;AC_DEFINE(HAVE_UTIMBUF), 
97 echo no)
98
99 # The following test taken from the cvs sources
100 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
101 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
102 # libsocket.so which has a bad implementation of gethostbyname (it
103 # only looks in /etc/hosts), so we only look for -lsocket if we need
104 # it.
105 AC_CHECK_FUNC(connect, :, 
106 [case "$LIBS" in
107 *-lnsl*) ;;
108 *) AC_CHECK_LIB(nsl_s, printf) ;;
109 esac
110 case "$LIBS" in
111 *-lnsl*) ;;
112 *) AC_CHECK_LIB(nsl, printf) ;;
113 esac
114 case "$LIBS" in
115 *-lsocket*) ;;
116 *) AC_CHECK_LIB(socket, connect) ;;
117 esac
118 case "$LIBS" in
119 *-linet*) ;;
120 *) AC_CHECK_LIB(inet, connect) ;;
121 esac
122 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
123 dnl has been cached.
124 if test "$ac_cv_lib_socket_connect" = "yes" || 
125    test "$ac_cv_lib_inet_connect" = "yes"; then
126   ac_cv_func_connect=yes
127   AC_DEFINE(HAVE_CONNECT)
128 fi])
129
130 #
131 # The following test was mostly taken from the tcl/tk plus patches
132 #
133 echo $ac_n "checking whether -c -o works ... $ac_c"
134 rm -rf conftest*
135 cat > conftest.$ac_ext <<EOF
136 int main() { return 0; }
137 EOF
138 ${CC-cc} -c -o conftest..o conftest.$ac_ext
139 if test -f conftest..o; then
140     OBJ_SAVE="#"
141     OBJ_RESTORE="#"
142     CC_SHOBJ_FLAG='-o $@'
143     echo yes
144 else
145     OBJ_SAVE='  @b=`basename $@ .o`;rm -f $$b.o.sav;if test -f $$b.o; then mv $$b.o $$b.o.sav;fi;'
146     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'
147     CC_SHOBJ_FLAG=""
148     echo no
149 fi
150 rm -rf conftest*
151 AC_SUBST(OBJ_SAVE)
152 AC_SUBST(OBJ_RESTORE)
153 AC_SUBST(CC_SHOBJ_FLAG)
154
155
156 AC_OUTPUT(Makefile lib/dummy zlib/dummy)