we are pre16
[tor.git] / configure.in
blob99ed7c2bd7cd7eb18481eab6841b51c08113b9cd
2 AC_INIT
3 AM_INIT_AUTOMAKE(tor, 0.0.2pre16)
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 saved_LIBS="$LIBS"
30 saved_LDFLAGS="$LDFLAGS"
31 saved_CPPFLAGS="$CPPFLAGS"
32 if test "x$prefix" != "xNONE" ; then
33         tryssldir="$tryssldir $prefix"
35 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
36         for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
37                 CPPFLAGS="$saved_CPPFLAGS"
38                 LDFLAGS="$saved_LDFLAGS"
39                 LIBS="$saved_LIBS -lssl -lcrypto"
41                 # Skip directories if they don't exist
42                 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
43                         continue;
44                 fi
45                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
46                         # Try to use $ssldir/lib if it exists, otherwise 
47                         # $ssldir
48                         if test -d "$ssldir/lib" ; then
49                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
50                                 if test ! -z "$need_dash_r" ; then
51                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
52                                 fi
53                         else
54                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
55                                 if test ! -z "$need_dash_r" ; then
56                                         LDFLAGS="-R$ssldir $LDFLAGS"
57                                 fi
58                         fi
59                         # Try to use $ssldir/include if it exists, otherwise 
60                         # $ssldir
61                         if test -d "$ssldir/include" ; then
62                                 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
63                         else
64                                 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
65                         fi
66                 fi
68                 # Basic test to check for compatible version and correct linking
69                 # *does not* test for RSA - that comes later.
70                 AC_TRY_RUN(
71                         [
72 #include <string.h>
73 #include <openssl/rand.h>
74 int main(void) 
76         char a[2048];
77         memset(a, 0, sizeof(a));
78         RAND_add(a, sizeof(a), sizeof(a));
79         return(RAND_status() <= 0);
81                         ],
82                         [
83                                 found_crypto=1
84                                 break;
85                         ], []
86                 )
88                 if test ! -z "$found_crypto" ; then
89                         break;
90                 fi
91         done
93         if test -z "$found_crypto" ; then
94                 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])      
95         fi
96         if test -z "$ssldir" ; then
97                 ssldir="(system)"
98         fi
100         ac_cv_openssldir=$ssldir
102 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
103  then
104         dnl Need to recover ssldir - test above runs in subshell
105         ssldir=$ac_cv_openssldir
106         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
107                 # Try to use $ssldir/lib if it exists, otherwise 
108                 # $ssldir
109                 if test -d "$ssldir/lib" ; then
110                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
111                         if test ! -z "$need_dash_r" ; then
112                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
113                         fi
114                 else
115                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
116                         if test ! -z "$need_dash_r" ; then
117                                 LDFLAGS="-R$ssldir $LDFLAGS"
118                         fi
119                 fi
120                 # Try to use $ssldir/include if it exists, otherwise 
121                 # $ssldir
122                 if test -d "$ssldir/include" ; then
123                         CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
124                 else
125                         CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
126                 fi
127         fi
129 LIBS="$saved_LIBS -lssl -lcrypto"
131 dnl The warning message here is no longer strictly accurate.
133 AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.h sys/poll.h sys/types.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))
135 dnl These headers are not essential
137 AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h netinet/in.h arpa/inet.h)
139 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname daemon)
141 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
142 dnl Watch out.
144 AC_CHECK_SIZEOF(int8_t)
145 AC_CHECK_SIZEOF(int16_t)
146 AC_CHECK_SIZEOF(int32_t)
147 AC_CHECK_SIZEOF(int64_t)
148 AC_CHECK_SIZEOF(uint8_t)
149 AC_CHECK_SIZEOF(uint16_t)
150 AC_CHECK_SIZEOF(uint32_t)
151 AC_CHECK_SIZEOF(uint64_t)
153 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t])
155 AC_CHECK_SIZEOF(char)
156 AC_CHECK_SIZEOF(short)
157 AC_CHECK_SIZEOF(int)
158 AC_CHECK_SIZEOF(long)
159 AC_CHECK_SIZEOF(long long)
160 AC_CHECK_SIZEOF(__int64)
162 # $prefix stores the value of the --prefix command line option, or
163 # NONE if the option wasn't set.  In the case that it wasn't set, make
164 # it be the default, so that we can use it to expand directories now.
165 if test "x$prefix" = "xNONE"; then
166   prefix=$ac_default_prefix
169 # and similarly for $exec_prefix
170 if test "x$exec_prefix" = "xNONE"; then
171   exec_prefix=$prefix
174 CONFDIR=`eval echo $sysconfdir/tor`
175 AC_SUBST(CONFDIR)
176 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
177 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
179 BINDIR=`eval echo $bindir`
180 AC_SUBST(BINDIR)
182 LOCALSTATEDIR=`eval echo $localstatedir`
183 AC_SUBST(LOCALSTATEDIR)
185 echo "confdir: $CONFDIR"
187 AC_OUTPUT(Makefile tor.sh src/config/torrc doc/tor.1 src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)