Override unaligned-access-ok check when $host_cpu is ia64. Apparently, ia64-linux...
[tor.git] / configure.in
blobd9395fe7e521bb52ed1f2cd7169f8f70a7e45927
2 AC_INIT
3 AM_INIT_AUTOMAKE(tor, 0.0.7pre1-cvs-2)
4 AM_CONFIG_HEADER(orconfig.h)
6 AC_CANONICAL_HOST
8 CFLAGS="$CFLAGS -Wall -g -O2 -I/usr/kerberos/include"
10 AC_ARG_ENABLE(debug,
11 [  --enable-debug          compiles with debugging info],
12 [if test x$enableval = xyes; then
13     CFLAGS="$CFLAGS -g"
14 fi])
16 AC_PROG_CC
17 AC_PROG_MAKE_SET
18 AC_PROG_RANLIB
20 # The big search for OpenSSL
21 # copied from openssh's configure.ac
22 AC_ARG_WITH(ssl-dir,
23         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
24         [
25                 if test "x$withval" != "xno" ; then
26                         tryssldir=$withval
27                 fi
28         ]
31 AC_SEARCH_LIBS(socket, [socket])
32 AC_SEARCH_LIBS(gethostbyname, [nsl])
34 saved_LIBS="$LIBS"
35 saved_LDFLAGS="$LDFLAGS"
36 saved_CPPFLAGS="$CPPFLAGS"
37 if test "x$prefix" != "xNONE" ; then
38         tryssldir="$tryssldir $prefix"
40 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
41         for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
42                 CPPFLAGS="$saved_CPPFLAGS"
43                 LDFLAGS="$saved_LDFLAGS"
44                 LIBS="$saved_LIBS -lssl -lcrypto"
46                 # Skip directories if they don't exist
47                 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
48                         continue;
49                 fi
50                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
51                         # Try to use $ssldir/lib if it exists, otherwise 
52                         # $ssldir
53                         if test -d "$ssldir/lib" ; then
54                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
55                                 if test ! -z "$need_dash_r" ; then
56                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
57                                 fi
58                         else
59                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
60                                 if test ! -z "$need_dash_r" ; then
61                                         LDFLAGS="-R$ssldir $LDFLAGS"
62                                 fi
63                         fi
64                         # Try to use $ssldir/include if it exists, otherwise 
65                         # $ssldir
66                         if test -d "$ssldir/include" ; then
67                                 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
68                         else
69                                 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
70                         fi
71                 fi
73                 # Basic test to check for compatible version and correct linking
74                 # *does not* test for RSA - that comes later.
75                 AC_TRY_RUN(
76                         [
77 #include <string.h>
78 #include <openssl/rand.h>
79 int main(void) 
81         char a[2048];
82         memset(a, 0, sizeof(a));
83         RAND_add(a, sizeof(a), sizeof(a));
84         return(RAND_status() <= 0);
86                         ],
87                         [
88                                 found_crypto=1
89                                 break;
90                         ], []
91                 )
93                 if test ! -z "$found_crypto" ; then
94                         break;
95                 fi
96         done
98         if test -z "$found_crypto" ; then
99                 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
100         fi
101         if test -z "$ssldir" ; then
102                 ssldir="(system)"
103         fi
105         ac_cv_openssldir=$ssldir
107 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
108  then
109         dnl Need to recover ssldir - test above runs in subshell
110         ssldir=$ac_cv_openssldir
111         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
112                 # Try to use $ssldir/lib if it exists, otherwise 
113                 # $ssldir
114                 if test -d "$ssldir/lib" ; then
115                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
116                         if test ! -z "$need_dash_r" ; then
117                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
118                         fi
119                 else
120                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
121                         if test ! -z "$need_dash_r" ; then
122                                 LDFLAGS="-R$ssldir $LDFLAGS"
123                         fi
124                 fi
125                 # Try to use $ssldir/include if it exists, otherwise 
126                 # $ssldir
127                 if test -d "$ssldir/include" ; then
128                         CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
129                 else
130                         CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
131                 fi
132         fi
134 LIBS="$saved_LIBS -lssl -lcrypto"
136 dnl The warning message here is no longer strictly accurate.
138 AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.h sys/poll.h sys/types.h fcntl.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h time.h pwd.h grp.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
140 dnl These headers are not essential
142 AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h)
144 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime)
145 AC_REPLACE_FUNCS(strlcat strlcpy)
147 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
148 dnl Watch out.
150 AC_CHECK_SIZEOF(int8_t)
151 AC_CHECK_SIZEOF(int16_t)
152 AC_CHECK_SIZEOF(int32_t)
153 AC_CHECK_SIZEOF(int64_t)
154 AC_CHECK_SIZEOF(uint8_t)
155 AC_CHECK_SIZEOF(uint16_t)
156 AC_CHECK_SIZEOF(uint32_t)
157 AC_CHECK_SIZEOF(uint64_t)
158 AC_CHECK_SIZEOF(intptr_t)
159 AC_CHECK_SIZEOF(uintptr_t)
161 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
163 AC_CHECK_SIZEOF(char)
164 AC_CHECK_SIZEOF(short)
165 AC_CHECK_SIZEOF(int)
166 AC_CHECK_SIZEOF(long)
167 AC_CHECK_SIZEOF(long long)
168 AC_CHECK_SIZEOF(__int64)
169 AC_CHECK_SIZEOF(void *)
171 # Now, let's see about alignment requirements.  On some platforms, we override
172 # the default.
173 case $host in
174  ia64-*-* | arm-*-* )
175     tor_cv_unaligned_ok=no
176     ;;
177  *)
178 AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
179 [AC_RUN_IFELSE([AC_LANG_SOURCE(
180 [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
181 return *(int*)(&s[1]); }]])],
182        [tor_cv_unaligned_ok=yes],
183        [tor_cv_unaligned_ok=no],
184        [tor_cv_unaligned_ok=cross])])
185 esac
187 if test $tor_cv_unaligned_ok = yes; then
188   AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
189             [Define to 1 iff unaligned int access is allowed])
192 # $prefix stores the value of the --prefix command line option, or
193 # NONE if the option wasn't set.  In the case that it wasn't set, make
194 # it be the default, so that we can use it to expand directories now.
195 if test "x$prefix" = "xNONE"; then
196   prefix=$ac_default_prefix
199 # and similarly for $exec_prefix
200 if test "x$exec_prefix" = "xNONE"; then
201   exec_prefix=$prefix
204 CONFDIR=`eval echo $sysconfdir/tor`
205 AC_SUBST(CONFDIR)
206 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
207 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
209 BINDIR=`eval echo $bindir`
210 AC_SUBST(BINDIR)
212 LOCALSTATEDIR=`eval echo $localstatedir`
213 AC_SUBST(LOCALSTATEDIR)
215 echo "confdir: $CONFDIR"
217 AC_OUTPUT(Makefile contrib/tor.sh contrib/torify contrib/Makefile contrib/tor.spec src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)