bump to 0.2.0.6-alpha-dev so we're ready to fix more bugs :)
[tor.git] / configure.in
blob1f62c111623ce54dcf69a70fec9cdd50e7b319e1
1 dnl $Id$
2 dnl Copyright (c) 2001-2004, Roger Dingledine
3 dnl Copyright (c) 2004-2007, Roger Dingledine, Nick Mathewson
4 dnl See LICENSE for licensing information
6 AC_INIT
7 AM_INIT_AUTOMAKE(tor, 0.2.0.6-alpha-dev)
8 AM_CONFIG_HEADER(orconfig.h)
10 AC_CANONICAL_HOST
12 if test -f /etc/redhat-release ; then
13     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
16 # Not a no-op; we want to make sure that CPPFLAGS is set before we use
17 # the += operator on it in src/or/Makefile.am
18 CPPFLAGS="$CPPFLAGS -I../common"
20 AC_ARG_ENABLE(debug,
21  AS_HELP_STRING(--enable-debug, compile with debugging info),
22 [if test x$enableval = xyes; then
23     CFLAGS="$CFLAGS -g"
24 fi])
26 AC_ARG_ENABLE(cell-pool,
27      AS_HELP_STRING(--disable-cell-pool, disable pool allocator for cells))
29 if test x$enable_cell_pool != xno; then
30   AC_DEFINE(ENABLE_CELL_POOL, 1,
31             [Defined if we try to use the pool allocator for queued cells])
34 AC_ARG_ENABLE(transparent,
35      AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
36      [case "${enableval}" in
37         yes) transparent=true ;;
38         no)  transparent=false ;;
39         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
40       esac], [transparent=true])
42 AC_ARG_ENABLE(threads,
43      AS_HELP_STRING(--disable-threads, disable multi-threading support))
45 if test x$enable_threads = x; then
46    case $host in
47     *-*-solaris* )
48      # Don't try multithreading on solaris -- cpuworkers seem to lock.
49      AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
50 cpu workers lock up here, so I will disable threads.])
51      enable_threads="no";;
52     *)
53      enable_threads="yes";;
54    esac
57 if test $enable_threads = "yes"; then
58   AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
61 case $host in
62    *-*-solaris* )
63      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
64      ;;
65 esac
67 AC_ARG_ENABLE(gcc-warnings,
68      AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
70 AC_PROG_CC
71 AC_PROG_MAKE_SET
72 AC_PROG_RANLIB
74 TORUSER=_tor
75 AC_ARG_WITH(tor-user,
76         [  --with-tor-user=NAME    Specify username for tor daemon ],
77         [
78            TORUSER=$withval
79         ]
81 AC_SUBST(TORUSER)
83 TORGROUP=_tor
84 AC_ARG_WITH(tor-group,
85         [  --with-tor-group=NAME   Specify group name for tor daemon ],
86         [
87            TORGROUP=$withval
88         ]
90 AC_SUBST(TORGROUP)
93 dnl If WIN32 is defined and non-zero, we are building for win32
94 AC_MSG_CHECKING([for win32])
95 AC_RUN_IFELSE([
96 int main(int c, char **v) {
97 #ifdef WIN32
98 #if WIN32
99   return 0;
100 #else
101   return 1;
102 #endif
103 #else
104   return 2;
105 #endif
107 bwin32=true; AC_MSG_RESULT([yes]),
108 bwin32=false; AC_MSG_RESULT([no]),
109 bwin32=cross; AC_MSG_RESULT([cross])
112 if test $bwin32 = cross; then
113 AC_MSG_CHECKING([for win32 (cross)])
114 AC_COMPILE_IFELSE([
115 #ifdef WIN32
116 int main(int c, char **v) {return 0;}
117 #else
118 #error
119 int main(int c, char **v) {return x(y);}
120 #endif
122 bwin32=true; AC_MSG_RESULT([yes]),
123 bwin32=false; AC_MSG_RESULT([no]))
126 if test $bwin32 = true; then
127 AC_DEFINE(MS_WINDOWS, 1, [Define to 1 if we are building for Windows.])
130 dnl Enable C99 when compiling with MIPSpro
131 AC_MSG_CHECKING([for MIPSpro compiler])
132 AC_COMPILE_IFELSE(AC_LANG_PROGRAM(, [
133 #if (defined(__sgi) && defined(_COMPILER_VERSION))
134 #error
135   return x(y);
136 #endif
138 bmipspro=false; AC_MSG_RESULT(no),
139 bmipspro=true; AC_MSG_RESULT(yes))
141 if test $bmipspro = true; then
142   CFLAGS="$CFLAGS -c99"
145 AC_SEARCH_LIBS(socket, [socket])
146 AC_SEARCH_LIBS(gethostbyname, [nsl])
147 AC_SEARCH_LIBS(dlopen, [dl])
148 AC_SEARCH_LIBS(inet_aton, [resolv])
150 if test $enable_threads = "yes"; then
151   AC_SEARCH_LIBS(pthread_create, [pthread])
152   AC_SEARCH_LIBS(pthread_detach, [pthread])
155 dnl -------------------------------------------------------------------
156 dnl Check for functions before libevent, since libevent-1.2 apparently
157 dnl exports strlcpy without defining it in a header.
159 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull ftello getaddrinfo localtime_r gmtime_r memmem strtok_r inet_pton inet_ntop mallinfo)
161 if test $enable_threads = "yes"; then
162   AC_CHECK_HEADERS(pthread.h)
163   AC_CHECK_FUNCS(pthread_create)
166 dnl ------------------------------------------------------
167 dnl Where do you live, libevent?  And how do we call you?
169 if test $bwin32 = true; then
170   TOR_LIB_WS32=-lws2_32
171   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
172   # think it's actually necessary.
173   TOR_LIB_GDI=-lgdi32
174 else
175   TOR_LIB_WS32=
176   TOR_LIB_GDI=
178 AC_SUBST(TOR_LIB_WS32)
179 AC_SUBST(TOR_LIB_GDI)
181 dnl This is a disgusting hack so we safely include recent libevent headers.
182 AC_CHECK_TYPE(u_int64_t, unsigned long long)
183 AC_CHECK_TYPE(u_int32_t, unsigned long)
184 AC_CHECK_TYPE(u_int16_t, unsigned short)
185 AC_CHECK_TYPE(u_int8_t, unsigned char)
187 tor_libevent_pkg_redhat="libevent"
188 tor_libevent_pkg_debian="libevent-dev"
189 tor_libevent_devpkg_redhat="libevent-devel"
190 tor_libevent_devpkg_debian="libevent-dev"
192 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $TOR_LIB_WS32], [
193 #include <stdlib.h>
194 #include <sys/time.h>
195 #include <sys/types.h>
196 #include <event.h>], [void exit(int); void *event_init(void);],
197     [event_init(); exit(0);], [--with-libevent-dir], [/opt/libevent])
199 dnl Now check for particular libevent functions.
200 save_LIBS="$LIBS"
201 save_LDFLAGS="$LDFLAGS"
202 save_CPPFLAGS="$CPPFLAGS"
203 LIBS="-levent $TOR_LIB_WS32 $LIBS"
204 LDFLAGS="$TOR_LDFLAGS_libevent $LIBS"
205 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
206 AC_CHECK_FUNCS(event_get_version event_get_method event_set_log_callback)
207 LIBS="$save_LIBS"
208 LDFLAGS="$save_LDFLAGS"
209 CPPFLAGS="$save_CPPFLAGS"
211 dnl ------------------------------------------------------
212 dnl Where do you live, openssl?  And how do we call you?
214 tor_openssl_pkg_redhat="openssl"
215 tor_openssl_pkg_debian="libssl"
216 tor_openssl_devpkg_redhat="openssl-devel"
217 tor_openssl_devpkg_debian="libssl-dev"
219 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
220     [#include <openssl/rand.h>],
221     [void RAND_add(const void *buf, int num, double entropy);],
222     [RAND_add((void*)0,0,0); exit(0);], [--with-ssl-dir],
223     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
225 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
227 dnl ------------------------------------------------------
228 dnl Where do you live, zlib?  And how do we call you?
230 tor_openssl_pkg_redhat="zlib"
231 tor_openssl_pkg_debian="zlib1g"
232 tor_openssl_devpkg_redhat="zlib-devel"
233 tor_openssl_devpkg_debian="zlib1g-dev"
235 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
236     [#include <zlib.h>],
237     [const char * zlibVersion(void);],
238     [zlibVersion(); exit(0);], [--with-zlib-dir],
239     [/opt/zlib])
241 dnl Make sure to enable support for large off_t if avalable.
243 AC_SYS_LARGEFILE
245 AC_CHECK_HEADERS(unistd.h string.h signal.h ctype.h sys/stat.h sys/types.h fcntl.h sys/fcntl.h sys/time.h errno.h assert.h time.h, , AC_MSG_WARN(Some headers were not found, compilation may fail.  If compilation succeeds, please send your orconfig.h to the developers so we can fix this warning.))
247 AC_CHECK_HEADERS(netdb.h sys/ioctl.h sys/socket.h arpa/inet.h netinet/in.h pwd.h grp.h sys/un.h)
249 dnl These headers are not essential
251 AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h inttypes.h utime.h sys/utime.h sys/mman.h netintet/in.h netinet/in6.h malloc.h)
253 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
254 [#ifdef HAVE_SYS_TYPES_H
255 #include <sys/types.h>
256 #endif
257 #ifdef HAVE_SYS_SOCKET_H
258 #include <sys/socket.h>
259 #endif])
260 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
261 [#ifdef HAVE_SYS_TYPES_H
262 #include <sys/types.h>
263 #endif
264 #ifdef HAVE_SYS_SOCKET_H
265 #include <sys/socket.h>
266 #endif
267 #ifdef HAVE_NET_IF_H
268 #include <net/if.h>
269 #endif])
270 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
271         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
272 [#ifdef HAVE_SYS_TYPES_H
273 #include <sys/types.h>
274 #endif
275 #ifdef HAVE_SYS_SOCKET_H
276 #include <sys/socket.h>
277 #endif])
279 if test x$transparent = xtrue ; then
280    transparent_ok=0
281    if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
282      transparent_ok=1
283    fi
284    if test x$linux_netfilter_ipv4 = x1 ; then
285      transparent_ok=1
286    fi
287    if test x$transparent_ok = x1 ; then
288      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
289      case $host in
290        *-*-openbsd*)
291          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
292      esac
293    else
294      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
295    fi
298 AC_FUNC_FSEEKO
300 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
301 [#ifdef HAVE_SYS_TYPES_H
302 #include <sys/types.h>
303 #endif
304 #ifdef HAVE_SYS_TIME_H
305 #include <sys/time.h>
306 #endif])
308 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
309 dnl Watch out.
311 AC_CHECK_SIZEOF(int8_t)
312 AC_CHECK_SIZEOF(int16_t)
313 AC_CHECK_SIZEOF(int32_t)
314 AC_CHECK_SIZEOF(int64_t)
315 AC_CHECK_SIZEOF(uint8_t)
316 AC_CHECK_SIZEOF(uint16_t)
317 AC_CHECK_SIZEOF(uint32_t)
318 AC_CHECK_SIZEOF(uint64_t)
319 AC_CHECK_SIZEOF(intptr_t)
320 AC_CHECK_SIZEOF(uintptr_t)
322 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
324 AC_CHECK_SIZEOF(char)
325 AC_CHECK_SIZEOF(short)
326 AC_CHECK_SIZEOF(int)
327 AC_CHECK_SIZEOF(long)
328 AC_CHECK_SIZEOF(long long)
329 AC_CHECK_SIZEOF(__int64)
330 AC_CHECK_SIZEOF(void *)
331 AC_CHECK_SIZEOF(time_t)
332 AC_CHECK_SIZEOF(size_t)
334 AC_CHECK_TYPES([uint, u_char])
336 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, struct sockaddr_storage, sa_family_t], , ,
337 [#ifdef HAVE_SYS_TYPES_H
338 #include <sys/types.h>
339 #endif
340 #ifdef HAVE_NETINET_IN_H
341 #include <netinet/in.h>
342 #endif
343 #ifdef HAVE_NETINET_IN6_H
344 #include <netinet/in6.h>
345 #endif
346 #ifdef HAVE_SYS_SOCKET_H
347 #include <sys/socket.h>
348 #endif
349 #ifdef MS_WINDOWS
350 #define WIN32_WINNT 0x400
351 #define _WIN32_WINNT 0x400
352 #define WIN32_LEAN_AND_MEAN
353 #if defined(_MSC_VER) && (_MSC_VER < 1300)
354 #include <winsock.h>
355 #else
356 #include <winsock2.h>
357 #include <ws2tcpip.h>
358 #endif
359 #endif
362 if test -z "$CROSS_COMPILE"; then
363 AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
364 AC_RUN_IFELSE(AC_LANG_SOURCE([
365 #ifdef HAVE_SYS_TYPES_H
366 #include <sys/types.h>
367 #endif
368 #ifdef HAVE_SYS_TIME_H
369 #include <sys/time.h>
370 #endif
371 #ifdef HAVE_TIME_H
372 #include <time.h>
373 #endif
374 int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }]),
375   tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
377 else
378   # Cross-compiling; let's hope the target platform isn't loony.
379   AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
380   tor_cv_time_t_signed=yes
383 if test $tor_cv_time_t_signed = yes; then
384   AC_DEFINE([TIME_T_IS_SIGNED], 1,
385             [Define to 1 iff time_t is signed])
388 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
389 #ifdef HAVE_SYS_SOCKET_H
390 #include <sys/socket.h>
391 #endif
394 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
396 AC_CHECK_SIZEOF(cell_t)
398 # Now make sure that NULL can be represented as zero bytes.
399 if test -z "$CROSS_COMPILE"; then
400 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
401 [AC_RUN_IFELSE([AC_LANG_SOURCE(
402 [[#include <stdlib.h>
403 #include <string.h>
404 #include <stdio.h>
405 #ifdef HAVE_STDDEF_H
406 #include <stddef.h>
407 #endif
408 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
409 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
410        [tor_cv_null_is_zero=yes],
411        [tor_cv_null_is_zero=no],
412        [tor_cv_null_is_zero=cross])])
414 else
415   # Cross-compiling; let's hope that the target isn't raving mad.
416   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
417   tor_cv_null_is_zero=yes
420 if test $tor_cv_null_is_zero = yes; then
421   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
422             [Define to 1 iff memset(0) sets pointers to NULL])
425 # And what happens when we malloc zero?
427 if test -z "$CROSS_COMPILE"; then
428 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
429 [AC_RUN_IFELSE([AC_LANG_SOURCE(
430 [[#include <stdlib.h>
431 #include <string.h>
432 #include <stdio.h>
433 #ifdef HAVE_STDDEF_H
434 #include <stddef.h>
435 #endif
436 int main () { return malloc(0)?0:1; }]])],
437        [tor_cv_malloc_zero_works=yes],
438        [tor_cv_malloc_zero_works=no],
439        [tor_cv_malloc_zero_works=cross])])
441 else
442   # Cross-compiling; let's hope that the target isn't raving mad.
443   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
444   tor_cv_malloc_zero_works=no
447 if test $tor_cv_malloc_zero_works = yes; then
448   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
449             [Define to 1 iff malloc(0) returns a pointer])
452 # whether we seem to be in a 2s-complement world.
453 if test -z "$CROSS_COMPILE"; then
454 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
455 [AC_RUN_IFELSE([AC_LANG_SOURCE(
456 [[int main () { int problem = ((-99) != (~99)+1);
457 return problem ? 1 : 0; }]])],
458        [tor_cv_twos_complement=yes],
459        [tor_cv_twos_complement=no],
460        [tor_cv_twos_complement=cross])])
462 else
463   # Cross-compiling; let's hope that the target isn't raving mad.
464   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
465   tor_cv_twos_complement=yes
468 if test $tor_cv_twos_complement = yes; then
469   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
470             [Define to 1 iff we represent negative integers with two's complement])
473 # Whether we should use the dmalloc memory allocation debugging library.
474 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
475 AC_ARG_WITH(dmalloc,
476 [  --with-dmalloc          Use debug memory allocation library. ],
477 [if [[ "$withval" = "yes" ]]; then
478   dmalloc=1
479   AC_MSG_RESULT(yes)
480 else
481   dmalloc=1
482   AC_MSG_RESULT(no)
483 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
486 if [[ $dmalloc -eq 1 ]]; then
487   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
488   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
489   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
490   AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
493 # Allow user to specify an alternate syslog facility
494 AC_ARG_WITH(syslog-facility,
495 [  --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
496 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
497 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
498 AC_SUBST(LOGFACILITY)
500 # Check for gethostbyname_r in all its glorious incompatible versions.
501 #   (This logic is based on that in Python's configure.in)
502 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
503   [Define this if you have any gethostbyname_r()])
505 AC_CHECK_FUNC(gethostbyname_r, [
506   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
507   OLD_CFLAGS=$CFLAGS
508   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
509   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([
510 #include <netdb.h>
511   ], [[
512     char *cp1, *cp2;
513     struct hostent *h1, *h2;
514     int i1, i2;
515     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
516   ]]),[
517     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
518     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
519      [Define this if gethostbyname_r takes 6 arguments])
520     AC_MSG_RESULT(6)
521   ], [
522     AC_TRY_COMPILE([
523 #include <netdb.h>
524     ], [
525       char *cp1, *cp2;
526       struct hostent *h1;
527       int i1, i2;
528       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
529     ], [
530       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
531       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
532         [Define this if gethostbyname_r takes 5 arguments])
533       AC_MSG_RESULT(5)
534    ], [
535       AC_TRY_COMPILE([
536 #include <netdb.h>
537      ], [
538        char *cp1;
539        struct hostent *h1;
540        struct hostent_data hd;
541        (void) gethostbyname_r(cp1,h1,&hd);
542      ], [
543        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
544        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
545          [Define this if gethostbyname_r takes 3 arguments])
546        AC_MSG_RESULT(3)
547      ], [
548        AC_MSG_RESULT(0)
549      ])
550   ])
551  ])
552  CFLAGS=$OLD_CFLAGS
555 AC_CACHE_CHECK([whether the C compiler supports __func__],
556   tor_cv_have_func_macro,
557   AC_COMPILE_IFELSE([
558 #include <stdio.h>
559 int main(int c, char **v) { puts(__func__); }],
560   tor_cv_have_func_macro=yes,
561   tor_cv_have_func_macro=no))
563 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
564   tor_cv_have_FUNC_macro,
565   AC_COMPILE_IFELSE([
566 #include <stdio.h>
567 int main(int c, char **v) { puts(__FUNC__); }],
568   tor_cv_have_FUNC_macro=yes,
569   tor_cv_have_FUNC_macro=no))
571 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
572   tor_cv_have_FUNCTION_macro,
573   AC_COMPILE_IFELSE([
574 #include <stdio.h>
575 int main(int c, char **v) { puts(__FUNCTION__); }],
576   tor_cv_have_FUNCTION_macro=yes,
577   tor_cv_have_FUNCTION_macro=no))
579 if test $tor_cv_have_func_macro = 'yes'; then
580   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
583 if test $tor_cv_have_FUNC_macro = 'yes'; then
584   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
587 if test $tor_cv_have_FUNCTION_macro = 'yes'; then
588   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
589            [Defined if the compiler supports __FUNCTION__])
592 # $prefix stores the value of the --prefix command line option, or
593 # NONE if the option wasn't set.  In the case that it wasn't set, make
594 # it be the default, so that we can use it to expand directories now.
595 if test "x$prefix" = "xNONE"; then
596   prefix=$ac_default_prefix
599 # and similarly for $exec_prefix
600 if test "x$exec_prefix" = "xNONE"; then
601   exec_prefix=$prefix
604 if test "x$CONFDIR" = "x"; then
605   CONFDIR=`eval echo $sysconfdir/tor`
607 AC_SUBST(CONFDIR)
608 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
609 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
611 BINDIR=`eval echo $bindir`
612 AC_SUBST(BINDIR)
614 LOCALSTATEDIR=`eval echo $localstatedir`
615 AC_SUBST(LOCALSTATEDIR)
616 AH_TEMPLATE([LOCALSTATEDIR], [Default location to store state files.])
617 AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
619 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
620 # than autoconf's macros like.
621 if test $ac_cv_c_compiler_gnu = yes; then
622   CFLAGS="$CFLAGS -Wall -g -O2"
623 else
624   CFLAGS="$CFLAGS -g -O"
625   enable_gcc_warnings=no
628 # Add some more warnings which we use in development but not in the
629 # released versions.  (Some relevant gcc versions can't handle these.)
630 if test x$enable_gcc_warnings = xyes; then
632   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [
633 #if !defined(__GNUC__) || (__GNUC__ < 4)
634 #error
635 #endif]), have_gcc4=yes, have_gcc4=no)
637   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [
638 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
639 #error
640 #endif]), have_gcc42=yes, have_gcc42=no)
642   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum -Werror"
643   # Disabled, so we can use mallinfo(): -Waggregate-return
645   if test x$have_gcc4 = xyes ; then 
646     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
647     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
648   fi
650   if test x$have_gcc42 = xyes ; then 
651     # These warnings break gcc 4.0.2 and work on gcc 4.2
652     # XXXX020 Use -fstack-protector.
653     # XXXX020 See if any of these work with earlier versions.
654     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=5"
655   fi
657 ##This will break the world on some 64-bit architectures
658 # CFLAGS="$CFLAGS -Winline"
662 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
664 AC_CONFIG_FILES([Makefile tor.spec Doxyfile contrib/tor.sh contrib/torctl contrib/torify contrib/tor.logrotate contrib/Makefile contrib/osx/Makefile contrib/osx/TorBundleDesc.plist contrib/osx/TorBundleInfo.plist contrib/osx/TorDesc.plist contrib/osx/TorInfo.plist contrib/osx/TorStartupDesc.plist src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile doc/design-paper/Makefile doc/spec/Makefile src/config/Makefile src/common/Makefile src/or/Makefile src/win32/Makefile src/tools/Makefile contrib/suse/Makefile contrib/suse/tor.sh])
665 AC_OUTPUT
667 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
668   ./contrib/updateVersions.pl