Add intptr_t and uintptr_t to torint.h
[tor.git] / configure.in
blob7981df8b17d5b38d9b8e7e1a5f03a5225aed2d11
2 AC_INIT
3 AM_INIT_AUTOMAKE(tor, 0.0.6)
4 AM_CONFIG_HEADER(orconfig.h)
6 CFLAGS="$CFLAGS -Wall -g -O2 -I/usr/kerberos/include"
8 AC_ARG_ENABLE(debug,
9 [  --enable-debug          compiles with debugging info],
10 [if test x$enableval = xyes; then
11     CFLAGS="$CFLAGS -g"
12 fi])
14 AC_PROG_CC
15 AC_PROG_MAKE_SET
16 AC_PROG_RANLIB
18 # The big search for OpenSSL
19 # copied from openssh's configure.ac
20 AC_ARG_WITH(ssl-dir,
21         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
22         [
23                 if test "x$withval" != "xno" ; then
24                         tryssldir=$withval
25                 fi
26         ]
29 AC_SEARCH_LIBS(socket, [socket])
30 AC_SEARCH_LIBS(gethostbyname, [nsl])
32 saved_LIBS="$LIBS"
33 saved_LDFLAGS="$LDFLAGS"
34 saved_CPPFLAGS="$CPPFLAGS"
35 if test "x$prefix" != "xNONE" ; then
36         tryssldir="$tryssldir $prefix"
38 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
39         for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
40                 CPPFLAGS="$saved_CPPFLAGS"
41                 LDFLAGS="$saved_LDFLAGS"
42                 LIBS="$saved_LIBS -lssl -lcrypto"
44                 # Skip directories if they don't exist
45                 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
46                         continue;
47                 fi
48                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
49                         # Try to use $ssldir/lib if it exists, otherwise 
50                         # $ssldir
51                         if test -d "$ssldir/lib" ; then
52                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
53                                 if test ! -z "$need_dash_r" ; then
54                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
55                                 fi
56                         else
57                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
58                                 if test ! -z "$need_dash_r" ; then
59                                         LDFLAGS="-R$ssldir $LDFLAGS"
60                                 fi
61                         fi
62                         # Try to use $ssldir/include if it exists, otherwise 
63                         # $ssldir
64                         if test -d "$ssldir/include" ; then
65                                 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
66                         else
67                                 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
68                         fi
69                 fi
71                 # Basic test to check for compatible version and correct linking
72                 # *does not* test for RSA - that comes later.
73                 AC_TRY_RUN(
74                         [
75 #include <string.h>
76 #include <openssl/rand.h>
77 int main(void) 
79         char a[2048];
80         memset(a, 0, sizeof(a));
81         RAND_add(a, sizeof(a), sizeof(a));
82         return(RAND_status() <= 0);
84                         ],
85                         [
86                                 found_crypto=1
87                                 break;
88                         ], []
89                 )
91                 if test ! -z "$found_crypto" ; then
92                         break;
93                 fi
94         done
96         if test -z "$found_crypto" ; then
97                 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
98         fi
99         if test -z "$ssldir" ; then
100                 ssldir="(system)"
101         fi
103         ac_cv_openssldir=$ssldir
105 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
106  then
107         dnl Need to recover ssldir - test above runs in subshell
108         ssldir=$ac_cv_openssldir
109         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
110                 # Try to use $ssldir/lib if it exists, otherwise 
111                 # $ssldir
112                 if test -d "$ssldir/lib" ; then
113                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
114                         if test ! -z "$need_dash_r" ; then
115                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
116                         fi
117                 else
118                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
119                         if test ! -z "$need_dash_r" ; then
120                                 LDFLAGS="-R$ssldir $LDFLAGS"
121                         fi
122                 fi
123                 # Try to use $ssldir/include if it exists, otherwise 
124                 # $ssldir
125                 if test -d "$ssldir/include" ; then
126                         CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
127                 else
128                         CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
129                 fi
130         fi
132 LIBS="$saved_LIBS -lssl -lcrypto"
134 dnl The warning message here is no longer strictly accurate.
136 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))
138 dnl These headers are not essential
140 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)
142 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime)
143 AC_REPLACE_FUNCS(strlcat strlcpy)
145 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
146 dnl Watch out.
148 AC_CHECK_SIZEOF(int8_t)
149 AC_CHECK_SIZEOF(int16_t)
150 AC_CHECK_SIZEOF(int32_t)
151 AC_CHECK_SIZEOF(int64_t)
152 AC_CHECK_SIZEOF(uint8_t)
153 AC_CHECK_SIZEOF(uint16_t)
154 AC_CHECK_SIZEOF(uint32_t)
155 AC_CHECK_SIZEOF(uint64_t)
156 AC_CHECK_SIZEOF(intptr_t)
157 AC_CHECK_SIZEOF(uintptr_t)
159 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
161 AC_CHECK_SIZEOF(char)
162 AC_CHECK_SIZEOF(short)
163 AC_CHECK_SIZEOF(int)
164 AC_CHECK_SIZEOF(long)
165 AC_CHECK_SIZEOF(long long)
166 AC_CHECK_SIZEOF(__int64)
167 AC_CHECK_SIZEOF(void *)
169 # Now, let's see about alignment requirements
170 AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
171 [AC_RUN_IFELSE([AC_LANG_SOURCE(
172 [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
173 return *(int*)(&s[1]); }]])],
174        [tor_cv_unaligned_ok=yes],
175        [tor_cv_unaligned_ok=no],
176        [tor_cv_unaligned_ok=cross])])
177 if test $tor_cv_unaligned_ok = yes; then
178   AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
179             [Define to 1 iff unaligned int access is allowed])
182 # $prefix stores the value of the --prefix command line option, or
183 # NONE if the option wasn't set.  In the case that it wasn't set, make
184 # it be the default, so that we can use it to expand directories now.
185 if test "x$prefix" = "xNONE"; then
186   prefix=$ac_default_prefix
189 # and similarly for $exec_prefix
190 if test "x$exec_prefix" = "xNONE"; then
191   exec_prefix=$prefix
194 CONFDIR=`eval echo $sysconfdir/tor`
195 AC_SUBST(CONFDIR)
196 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
197 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
199 BINDIR=`eval echo $bindir`
200 AC_SUBST(BINDIR)
202 LOCALSTATEDIR=`eval echo $localstatedir`
203 AC_SUBST(LOCALSTATEDIR)
205 echo "confdir: $CONFDIR"
207 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)