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