Note that GETINFO (via the controller) for network-status will not work on non-authdi...
[tor.git] / configure.in
blob0f455e7f4c1b2db53fb5867575c94d404592c837
2 AC_INIT
3 AM_INIT_AUTOMAKE(tor, 0.1.0.0-alpha-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])
35 AC_SEARCH_LIBS(pthread_create, [pthread])
36 AC_SEARCH_LIBS(pthread_detach, [pthread])
37 AC_SEARCH_LIBS(event_loop, [event], , AC_MSG_ERROR(Libevent library not found. Tor requires libevent to build.))
39 saved_LIBS="$LIBS"
40 saved_LDFLAGS="$LDFLAGS"
41 saved_CPPFLAGS="$CPPFLAGS"
42 if test "x$prefix" != "xNONE" ; then
43         tryssldir="$tryssldir $prefix"
45 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
46         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
47                 CPPFLAGS="$saved_CPPFLAGS"
48                 LDFLAGS="$saved_LDFLAGS"
49                 LIBS="$saved_LIBS -lssl -lcrypto"
51                 # Skip directories if they don't exist
52                 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
53                         continue;
54                 fi
55                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
56                         # Try to use $ssldir/lib if it exists, otherwise
57                         # $ssldir
58                         if test -d "$ssldir/lib" ; then
59                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
60                                 if test ! -z "$need_dash_r" ; then
61                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
62                                 fi
63                         else
64                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
65                                 if test ! -z "$need_dash_r" ; then
66                                         LDFLAGS="-R$ssldir $LDFLAGS"
67                                 fi
68                         fi
69                         # Try to use $ssldir/include if it exists, otherwise
70                         # $ssldir
71                         if test -d "$ssldir/include" ; then
72                                 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
73                         else
74                                 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
75                         fi
76                 fi
78                 # Basic test to check for compatible version and correct linking
79                 # *does not* test for RSA - that comes later.
80                 AC_TRY_RUN(
81                         [
82 #include <string.h>
83 #include <openssl/rand.h>
84 int main(void)
86         char a[2048];
87         memset(a, 0, sizeof(a));
88         RAND_add(a, sizeof(a), sizeof(a));
89         return(RAND_status() <= 0);
91                         ],
92                         [
93                                 found_crypto=1
94                                 break;
95                         ], []
96                 )
98                 if test ! -z "$found_crypto" ; then
99                         break;
100                 fi
101         done
103         if test -z "$found_crypto" ; then
104                 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
105         fi
106         if test -z "$ssldir" ; then
107                 ssldir="(system)"
108         fi
110         ac_cv_openssldir=$ssldir
112 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
113  then
114         dnl Need to recover ssldir - test above runs in subshell
115         ssldir=$ac_cv_openssldir
116         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
117                 # Try to use $ssldir/lib if it exists, otherwise
118                 # $ssldir
119                 if test -d "$ssldir/lib" ; then
120                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
121                         if test ! -z "$need_dash_r" ; then
122                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
123                         fi
124                 else
125                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
126                         if test ! -z "$need_dash_r" ; then
127                                 LDFLAGS="-R$ssldir $LDFLAGS"
128                         fi
129                 fi
130                 # Try to use $ssldir/include if it exists, otherwise
131                 # $ssldir
132                 if test -d "$ssldir/include" ; then
133                         CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
134                 else
135                         CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
136                 fi
137         fi
139 LIBS="$saved_LIBS"
141 AC_SYS_LARGEFILE
143 dnl The warning message here is no longer strictly accurate.
145 AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h sys/stat.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))
147 AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))
149 AC_CHECK_HEADERS(zlib.h, , AC_MSG_ERROR(Zlib header (zlib.h) not found. Tor requires zlib to build. You may need to install a zlib development package.))
151 dnl These headers are not essential
153 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 pthread.h stddef.h inttypes.h)
155 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam ftello pthread_create getaddrinfo localtime_r gmtime_r)
156 AC_FUNC_FSEEKO
158 AC_CHECK_MEMBERS([struct timeval.tv_sec])
161 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
162 dnl Watch out.
164 AC_CHECK_SIZEOF(int8_t)
165 AC_CHECK_SIZEOF(int16_t)
166 AC_CHECK_SIZEOF(int32_t)
167 AC_CHECK_SIZEOF(int64_t)
168 AC_CHECK_SIZEOF(uint8_t)
169 AC_CHECK_SIZEOF(uint16_t)
170 AC_CHECK_SIZEOF(uint32_t)
171 AC_CHECK_SIZEOF(uint64_t)
172 AC_CHECK_SIZEOF(intptr_t)
173 AC_CHECK_SIZEOF(uintptr_t)
175 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
177 AC_CHECK_SIZEOF(char)
178 AC_CHECK_SIZEOF(short)
179 AC_CHECK_SIZEOF(int)
180 AC_CHECK_SIZEOF(long)
181 AC_CHECK_SIZEOF(long long)
182 AC_CHECK_SIZEOF(__int64)
183 AC_CHECK_SIZEOF(void *)
184 AC_CHECK_SIZEOF(time_t)
186 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
188 AC_CHECK_SIZEOF(cell_t)
190 # Now, let's see about alignment requirements.  On some platforms, we override
191 # the default.
192 case $host in
193  ia64-*-* | arm-*-* )
194     tor_cv_unaligned_ok=no
195     ;;
196  *)
197 AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
198 [AC_RUN_IFELSE([AC_LANG_SOURCE(
199 [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
200 return *(int*)(&s[1]); }]])],
201        [tor_cv_unaligned_ok=yes],
202        [tor_cv_unaligned_ok=no],
203        [tor_cv_unaligned_ok=cross])])
204 esac
206 if test $tor_cv_unaligned_ok = yes; then
207   AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
208             [Define to 1 iff unaligned int access is allowed])
211 # Now make sure that NULL can be represented as zero bytes.
212 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
213 [AC_RUN_IFELSE([AC_LANG_SOURCE(
214 [[#include <stdlib.h>
215 #include <string.h>
216 #include <stdio.h>
217 #ifdef HAVE_STDDEF_H
218 #include <stddef.h>
219 #endif
220 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
221 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
222        [tor_cv_null_is_zero=yes],
223        [tor_cv_null_is_zero=no],
224        [tor_cv_null_is_zero=cross])])
226 if test $tor_cv_null_is_zero = yes; then
227   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
228             [Define to 1 iff memset(0) sets pointers to NULL])
231 # Whether we should use the dmalloc memory allocation debugging library.
232 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
233 AC_ARG_WITH(dmalloc,
234 [  --with-dmalloc          Use debug memory allocation library. ],
235 [if [[ "$withval" = "yes" ]]; then
236   dmalloc=1
237   AC_MSG_RESULT(yes)
238 else
239   dmalloc=1
240   AC_MSG_RESULT(no)
241 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
244 if [[ $dmalloc -eq 1 ]]; then
245   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
246   AC_SEARCH_LIBS(dmalloc_malloc, [dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
247   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
248   AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
251 # Check for gethostbyname_r in all its glorious incompatible versions.
252 #   (This logic is based on that in Python's configure.in)
253 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
254   [Define this if you have any gethostbyname_r()])
256 AC_CHECK_FUNC(gethostbyname_r, [
257   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
258   OLD_CFLAGS=$CFLAGS
259   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
260   AC_TRY_COMPILE([
261 #include <netdb.h>
262   ], [
263     char *cp1, *cp2;
264     struct hostent *h1, *h2;
265     int i1, i2;
266     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
267   ], [
268     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
269     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
270      [Define this if gethostbyname_r takes 6 arguments])
271     AC_MSG_RESULT(6)
272   ], [
273     AC_TRY_COMPILE([
274 #include <netdb.h>
275     ], [
276       char *cp1, *cp2;
277       struct hostent *h1;
278       int i1, i2;
279       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
280     ], [
281       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
282       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
283         [Define this if gethostbyname_r takes 5 arguments])
284       AC_MSG_RESULT(5)
285    ], [
286       AC_TRY_COMPILE([
287 #include <netdb.h>
288      ], [
289        char *cp1;
290        struct hostent *h1;
291        struct hostent_data hd;
292        (void) gethostbyname_r(cp1,h1,&hd);
293      ], [
294        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
295        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
296          [Define this if gethostbyname_r takes 3 arguments])
297        AC_MSG_RESULT(3)
298      ], [
299        AC_MSG_RESULT(0)
300      ])
301   ])
302  ])
303  CFLAGS=$OLD_CFLAGS
306 # $prefix stores the value of the --prefix command line option, or
307 # NONE if the option wasn't set.  In the case that it wasn't set, make
308 # it be the default, so that we can use it to expand directories now.
309 if test "x$prefix" = "xNONE"; then
310   prefix=$ac_default_prefix
313 # and similarly for $exec_prefix
314 if test "x$exec_prefix" = "xNONE"; then
315   exec_prefix=$prefix
318 CONFDIR=`eval echo $sysconfdir/tor`
319 AC_SUBST(CONFDIR)
320 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
321 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
323 BINDIR=`eval echo $bindir`
324 AC_SUBST(BINDIR)
326 LOCALSTATEDIR=`eval echo $localstatedir`
327 AC_SUBST(LOCALSTATEDIR)
329 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
330 # than autoconf's macros like.
331 CFLAGS="$CFLAGS -Wall -g -O2"
332 # Add some more warnings which we use in the cvs version but not in the
333 # released versions.  (Some relevant gcc versions can't handle these.)
334 #CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls"
335 # Add these in when you feel like fun.
336 #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement"
338 echo "confdir: $CONFDIR"
340 AC_OUTPUT(Makefile tor.spec contrib/tor.sh contrib/torctl contrib/torify contrib/Makefile contrib/osx/Makefile contrib/osx/TorBundleDesc.plist contrib/osx/TorBundleInfo.plist contrib/osx/TorDesc.plist contrib/osx/TorInfo.plist 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)
342 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
343   ./contrib/updateVersions.pl