Stop using the wrong DataDirectory when we're validating.
[tor.git] / configure.in
blob646de789be0ec7d63bdef002f5b35bd02142d598
2 AC_INIT
3 AM_INIT_AUTOMAKE(tor, 0.0.9pre5-cvs)
4 AM_CONFIG_HEADER(orconfig.h)
6 AC_CANONICAL_HOST
8 if test -f /etc/redhat-release; then
9     CFLAGS="$CFLAGS -I/usr/kerberos/include"
12 AC_ARG_ENABLE(debug,
13 [  --enable-debug          compiles with debugging info],
14 [if test x$enableval = xyes; then
15     CFLAGS="$CFLAGS -g"
16 fi])
18 AC_PROG_CC
19 AC_PROG_MAKE_SET
20 AC_PROG_RANLIB
22 # The big search for OpenSSL
23 # copied from openssh's configure.ac
24 AC_ARG_WITH(ssl-dir,
25         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
26         [
27                 if test "x$withval" != "xno" ; then
28                         tryssldir=$withval
29                 fi
30         ]
33 AC_SEARCH_LIBS(socket, [socket])
34 AC_SEARCH_LIBS(gethostbyname, [nsl])
36 saved_LIBS="$LIBS"
37 saved_LDFLAGS="$LDFLAGS"
38 saved_CPPFLAGS="$CPPFLAGS"
39 if test "x$prefix" != "xNONE" ; then
40         tryssldir="$tryssldir $prefix"
42 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
43         for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
44                 CPPFLAGS="$saved_CPPFLAGS"
45                 LDFLAGS="$saved_LDFLAGS"
46                 LIBS="$saved_LIBS -lssl -lcrypto"
48                 # Skip directories if they don't exist
49                 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
50                         continue;
51                 fi
52                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
53                         # Try to use $ssldir/lib if it exists, otherwise 
54                         # $ssldir
55                         if test -d "$ssldir/lib" ; then
56                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
57                                 if test ! -z "$need_dash_r" ; then
58                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
59                                 fi
60                         else
61                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
62                                 if test ! -z "$need_dash_r" ; then
63                                         LDFLAGS="-R$ssldir $LDFLAGS"
64                                 fi
65                         fi
66                         # Try to use $ssldir/include if it exists, otherwise 
67                         # $ssldir
68                         if test -d "$ssldir/include" ; then
69                                 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
70                         else
71                                 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
72                         fi
73                 fi
75                 # Basic test to check for compatible version and correct linking
76                 # *does not* test for RSA - that comes later.
77                 AC_TRY_RUN(
78                         [
79 #include <string.h>
80 #include <openssl/rand.h>
81 int main(void) 
83         char a[2048];
84         memset(a, 0, sizeof(a));
85         RAND_add(a, sizeof(a), sizeof(a));
86         return(RAND_status() <= 0);
88                         ],
89                         [
90                                 found_crypto=1
91                                 break;
92                         ], []
93                 )
95                 if test ! -z "$found_crypto" ; then
96                         break;
97                 fi
98         done
100         if test -z "$found_crypto" ; then
101                 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
102         fi
103         if test -z "$ssldir" ; then
104                 ssldir="(system)"
105         fi
107         ac_cv_openssldir=$ssldir
109 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
110  then
111         dnl Need to recover ssldir - test above runs in subshell
112         ssldir=$ac_cv_openssldir
113         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
114                 # Try to use $ssldir/lib if it exists, otherwise 
115                 # $ssldir
116                 if test -d "$ssldir/lib" ; then
117                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
118                         if test ! -z "$need_dash_r" ; then
119                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
120                         fi
121                 else
122                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
123                         if test ! -z "$need_dash_r" ; then
124                                 LDFLAGS="-R$ssldir $LDFLAGS"
125                         fi
126                 fi
127                 # Try to use $ssldir/include if it exists, otherwise 
128                 # $ssldir
129                 if test -d "$ssldir/include" ; then
130                         CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
131                 else
132                         CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
133                 fi
134         fi
136 LIBS="$saved_LIBS"
138 dnl The warning message here is no longer strictly accurate.
140 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 zlib.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
142 dnl These headers are not essential
144 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 syslog.h sys/time.h sys/resource.h)
146 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull)
148 AC_CHECK_MEMBERS([struct timeval.tv_sec])
150 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
151 dnl Watch out.
153 AC_CHECK_SIZEOF(int8_t)
154 AC_CHECK_SIZEOF(int16_t)
155 AC_CHECK_SIZEOF(int32_t)
156 AC_CHECK_SIZEOF(int64_t)
157 AC_CHECK_SIZEOF(uint8_t)
158 AC_CHECK_SIZEOF(uint16_t)
159 AC_CHECK_SIZEOF(uint32_t)
160 AC_CHECK_SIZEOF(uint64_t)
161 AC_CHECK_SIZEOF(intptr_t)
162 AC_CHECK_SIZEOF(uintptr_t)
164 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
166 AC_CHECK_SIZEOF(char)
167 AC_CHECK_SIZEOF(short)
168 AC_CHECK_SIZEOF(int)
169 AC_CHECK_SIZEOF(long)
170 AC_CHECK_SIZEOF(long long)
171 AC_CHECK_SIZEOF(__int64)
172 AC_CHECK_SIZEOF(void *)
174 # Now, let's see about alignment requirements.  On some platforms, we override
175 # the default.
176 case $host in
177  ia64-*-* | arm-*-* )
178     tor_cv_unaligned_ok=no
179     ;;
180  *)
181 AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
182 [AC_RUN_IFELSE([AC_LANG_SOURCE(
183 [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
184 return *(int*)(&s[1]); }]])],
185        [tor_cv_unaligned_ok=yes],
186        [tor_cv_unaligned_ok=no],
187        [tor_cv_unaligned_ok=cross])])
188 esac
190 if test $tor_cv_unaligned_ok = yes; then
191   AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
192             [Define to 1 iff unaligned int access is allowed])
195 # Now make sure that NULL can be represented as zero bytes.
196 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
197 [AC_RUN_IFELSE([AC_LANG_SOURCE(
198 [[#include <stdlib.h>
199 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
200 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
201        [tor_cv_null_is_zero=yes],
202        [tor_cv_null_is_zero=no],
203        [tor_cv_null_is_zero=cross])])
205 if test $tor_cv_null_is_zero = yes; then
206   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
207             [Define to 1 iff memset(0) sets pointers to NULL])
210 # $prefix stores the value of the --prefix command line option, or
211 # NONE if the option wasn't set.  In the case that it wasn't set, make
212 # it be the default, so that we can use it to expand directories now.
213 if test "x$prefix" = "xNONE"; then
214   prefix=$ac_default_prefix
217 # and similarly for $exec_prefix
218 if test "x$exec_prefix" = "xNONE"; then
219   exec_prefix=$prefix
222 CONFDIR=`eval echo $sysconfdir/tor`
223 AC_SUBST(CONFDIR)
224 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
225 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
227 BINDIR=`eval echo $bindir`
228 AC_SUBST(BINDIR)
230 LOCALSTATEDIR=`eval echo $localstatedir`
231 AC_SUBST(LOCALSTATEDIR)
233 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
234 # than autoconf's macros like.
235 CFLAGS="$CFLAGS -Wall -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -g -O2"
236 # Add some more warnings which we use in the cvs version but not in the
237 # released versions.
238 CFLAGS="$CFLAGS -Wwrite-strings -Wredundant-decls"
240 # Add these in when you feel like fun.
241 # -Wbad-function-cast -Werror  -Wdeclaration-after-statement
243 echo "confdir: $CONFDIR"
245 AC_OUTPUT(Makefile tor.spec contrib/tor.sh contrib/torify contrib/Makefile src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile doc/design-paper/Makefile src/config/Makefile src/common/Makefile src/or/Makefile src/win32/Makefile src/tools/Makefile)