remove vestiges of libcrypto and libssl
[tor/rransom.git] / configure.in
blob6bf7b53d3f5b9dc3d3f36425a4d40e0b600b9599
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.12-alpha-dev)
8 AM_CONFIG_HEADER(orconfig.h)
10 AC_CANONICAL_HOST
12 if test -f /etc/redhat-release ; then
13   if test -f /usr/kerberos/include ; then
14     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
15   fi
18 # Not a no-op; we want to make sure that CPPFLAGS is set before we use
19 # the += operator on it in src/or/Makefile.am
20 CPPFLAGS="$CPPFLAGS -I../common"
22 AC_ARG_ENABLE(debug,
23  AS_HELP_STRING(--enable-debug, compile with debugging info),
24 [if test x$enableval = xyes; then
25     CFLAGS="$CFLAGS -g"
26 fi])
28 AC_ARG_ENABLE(cell-pool,
29      AS_HELP_STRING(--disable-cell-pool, disable pool allocator for cells))
31 if test x$enable_cell_pool != xno; then
32   AC_DEFINE(ENABLE_CELL_POOL, 1,
33             [Defined if we try to use the pool allocator for queued cells])
36 AC_ARG_ENABLE(transparent,
37      AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
38      [case "${enableval}" in
39         yes) transparent=true ;;
40         no)  transparent=false ;;
41         *) AC_MSG_ERROR(bad value for --enable-transparent) ;;
42       esac], [transparent=true])
44 AC_ARG_ENABLE(threads,
45      AS_HELP_STRING(--disable-threads, disable multi-threading support))
47 if test x$enable_threads = x; then
48    case $host in
49     *-*-solaris* )
50      # Don't try multithreading on solaris -- cpuworkers seem to lock.
51      AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
52 cpu workers lock up here, so I will disable threads.])
53      enable_threads="no";;
54     *)
55      enable_threads="yes";;
56    esac
59 if test "$enable_threads" = "yes"; then
60   AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
63 case $host in
64    *-*-solaris* )
65      AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
66      ;;
67 esac
69 AC_ARG_ENABLE(gcc-warnings,
70      AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
72 AC_PROG_CC
73 AC_PROG_CPP
74 AC_PROG_MAKE_SET
75 AC_PROG_RANLIB
77 TORUSER=_tor
78 AC_ARG_WITH(tor-user,
79         [  --with-tor-user=NAME    Specify username for tor daemon ],
80         [
81            TORUSER=$withval
82         ]
84 AC_SUBST(TORUSER)
86 TORGROUP=_tor
87 AC_ARG_WITH(tor-group,
88         [  --with-tor-group=NAME   Specify group name for tor daemon ],
89         [
90            TORGROUP=$withval
91         ]
93 AC_SUBST(TORGROUP)
96 dnl If WIN32 is defined and non-zero, we are building for win32
97 AC_MSG_CHECKING([for win32])
98 AC_RUN_IFELSE([
99 int main(int c, char **v) {
100 #ifdef WIN32
101 #if WIN32
102   return 0;
103 #else
104   return 1;
105 #endif
106 #else
107   return 2;
108 #endif
110 bwin32=true; AC_MSG_RESULT([yes]),
111 bwin32=false; AC_MSG_RESULT([no]),
112 bwin32=cross; AC_MSG_RESULT([cross])
115 if test "$bwin32" = cross; then
116 AC_MSG_CHECKING([for win32 (cross)])
117 AC_COMPILE_IFELSE([
118 #ifdef WIN32
119 int main(int c, char **v) {return 0;}
120 #else
121 #error
122 int main(int c, char **v) {return x(y);}
123 #endif
125 bwin32=true; AC_MSG_RESULT([yes]),
126 bwin32=false; AC_MSG_RESULT([no]))
129 if test "$bwin32" = true; then
130 AC_DEFINE(MS_WINDOWS, 1, [Define to 1 if we are building for Windows.])
132 AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue)
134 dnl Enable C99 when compiling with MIPSpro
135 AC_MSG_CHECKING([for MIPSpro compiler])
136 AC_COMPILE_IFELSE(AC_LANG_PROGRAM(, [
137 #if (defined(__sgi) && defined(_COMPILER_VERSION))
138 #error
139   return x(y);
140 #endif
142 bmipspro=false; AC_MSG_RESULT(no),
143 bmipspro=true; AC_MSG_RESULT(yes))
145 if test "$bmipspro" = true; then
146   CFLAGS="$CFLAGS -c99"
149 AC_C_BIGENDIAN
151 AC_SEARCH_LIBS(socket, [socket])
152 AC_SEARCH_LIBS(gethostbyname, [nsl])
153 AC_SEARCH_LIBS(dlopen, [dl])
154 AC_SEARCH_LIBS(inet_aton, [resolv])
156 if test "$enable_threads" = "yes"; then
157   AC_SEARCH_LIBS(pthread_create, [pthread])
158   AC_SEARCH_LIBS(pthread_detach, [pthread])
161 dnl -------------------------------------------------------------------
162 dnl Check for functions before libevent, since libevent-1.2 apparently
163 dnl exports strlcpy without defining it in a header.
165 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)
167 if test "$enable_threads" = "yes"; then
168   AC_CHECK_HEADERS(pthread.h)
169   AC_CHECK_FUNCS(pthread_create)
172 dnl ------------------------------------------------------
173 dnl Where do you live, libevent?  And how do we call you?
175 if test "$bwin32" = true; then
176   TOR_LIB_WS32=-lws2_32
177   # Some of the cargo-cults recommend -lwsock32 as well, but I don't
178   # think it's actually necessary.
179   TOR_LIB_GDI=-lgdi32
180 else
181   TOR_LIB_WS32=
182   TOR_LIB_GDI=
184 AC_SUBST(TOR_LIB_WS32)
185 AC_SUBST(TOR_LIB_GDI)
187 dnl We need to do this before we try our disgusting hack below.
188 AC_CHECK_HEADERS([sys/types.h])
190 dnl This is a disgusting hack so we safely include older libevent headers.
191 AC_CHECK_TYPE(u_int64_t, unsigned long long)
192 AC_CHECK_TYPE(u_int32_t, unsigned long)
193 AC_CHECK_TYPE(u_int16_t, unsigned short)
194 AC_CHECK_TYPE(u_int8_t, unsigned char)
196 tor_libevent_pkg_redhat="libevent"
197 tor_libevent_pkg_debian="libevent-dev"
198 tor_libevent_devpkg_redhat="libevent-devel"
199 tor_libevent_devpkg_debian="libevent-dev"
201 TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $TOR_LIB_WS32], [
202 #include <stdlib.h>
203 #include <sys/time.h>
204 #include <sys/types.h>
205 #include <event.h>], [void exit(int); void *event_init(void);],
206     [event_init(); exit(0);], [--with-libevent-dir], [/opt/libevent])
208 dnl Now check for particular libevent functions.
209 save_LIBS="$LIBS"
210 save_LDFLAGS="$LDFLAGS"
211 save_CPPFLAGS="$CPPFLAGS"
212 LIBS="-levent $TOR_LIB_WS32 $LIBS"
213 LDFLAGS="$TOR_LDFLAGS_libevent $LIBS"
214 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
215 AC_CHECK_FUNCS(event_get_version event_get_method event_set_log_callback)
216 LIBS="$save_LIBS"
217 LDFLAGS="$save_LDFLAGS"
218 CPPFLAGS="$save_CPPFLAGS"
220 dnl ------------------------------------------------------
221 dnl Where do you live, openssl?  And how do we call you?
223 tor_openssl_pkg_redhat="openssl"
224 tor_openssl_pkg_debian="libssl"
225 tor_openssl_devpkg_redhat="openssl-devel"
226 tor_openssl_devpkg_debian="libssl-dev"
228 TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI],
229     [#include <openssl/rand.h>],
230     [void RAND_add(const void *buf, int num, double entropy);],
231     [RAND_add((void*)0,0,0); exit(0);], [--with-ssl-dir],
232     [/usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /opt/openssl])
234 dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay()
236 dnl ------------------------------------------------------
237 dnl Where do you live, zlib?  And how do we call you?
239 tor_openssl_pkg_redhat="zlib"
240 tor_openssl_pkg_debian="zlib1g"
241 tor_openssl_devpkg_redhat="zlib-devel"
242 tor_openssl_devpkg_debian="zlib1g-dev"
244 TOR_SEARCH_LIBRARY(zlib, $tryzlibdir, [-lz],
245     [#include <zlib.h>],
246     [const char * zlibVersion(void);],
247     [zlibVersion(); exit(0);], [--with-zlib-dir],
248     [/opt/zlib])
250 dnl Make sure to enable support for large off_t if avalable.
252 AC_SYS_LARGEFILE
254 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.))
256 AC_CHECK_HEADERS(netdb.h sys/ioctl.h sys/socket.h arpa/inet.h netinet/in.h pwd.h grp.h sys/un.h)
258 dnl These headers are not essential
260 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 sys/syslimits.h)
262 AC_CHECK_HEADERS(net/if.h, net_if_found=1, net_if_found=0,
263 [#ifdef HAVE_SYS_TYPES_H
264 #include <sys/types.h>
265 #endif
266 #ifdef HAVE_SYS_SOCKET_H
267 #include <sys/socket.h>
268 #endif])
269 AC_CHECK_HEADERS(net/pfvar.h, net_pfvar_found=1, net_pfvar_found=0,
270 [#ifdef HAVE_SYS_TYPES_H
271 #include <sys/types.h>
272 #endif
273 #ifdef HAVE_SYS_SOCKET_H
274 #include <sys/socket.h>
275 #endif
276 #ifdef HAVE_NET_IF_H
277 #include <net/if.h>
278 #endif])
279 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
280         linux_netfilter_ipv4=1, linux_netfilter_ipv4=0,
281 [#ifdef HAVE_SYS_TYPES_H
282 #include <sys/types.h>
283 #endif
284 #ifdef HAVE_SYS_SOCKET_H
285 #include <sys/socket.h>
286 #endif])
288 if test x$transparent = xtrue ; then
289    transparent_ok=0
290    if test x$net_if_found = x1 && test x$net_pfvar_found = x1 ; then
291      transparent_ok=1
292    fi
293    if test x$linux_netfilter_ipv4 = x1 ; then
294      transparent_ok=1
295    fi
296    if test x$transparent_ok = x1 ; then
297      AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
298      case $host in
299        *-*-openbsd*)
300          AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
301      esac
302    else
303      AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
304    fi
307 AC_FUNC_FSEEKO
309 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
310 [#ifdef HAVE_SYS_TYPES_H
311 #include <sys/types.h>
312 #endif
313 #ifdef HAVE_SYS_TIME_H
314 #include <sys/time.h>
315 #endif])
317 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
318 dnl Watch out.
320 AC_CHECK_SIZEOF(int8_t)
321 AC_CHECK_SIZEOF(int16_t)
322 AC_CHECK_SIZEOF(int32_t)
323 AC_CHECK_SIZEOF(int64_t)
324 AC_CHECK_SIZEOF(uint8_t)
325 AC_CHECK_SIZEOF(uint16_t)
326 AC_CHECK_SIZEOF(uint32_t)
327 AC_CHECK_SIZEOF(uint64_t)
328 AC_CHECK_SIZEOF(intptr_t)
329 AC_CHECK_SIZEOF(uintptr_t)
331 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
333 AC_CHECK_SIZEOF(char)
334 AC_CHECK_SIZEOF(short)
335 AC_CHECK_SIZEOF(int)
336 AC_CHECK_SIZEOF(long)
337 AC_CHECK_SIZEOF(long long)
338 AC_CHECK_SIZEOF(__int64)
339 AC_CHECK_SIZEOF(void *)
340 AC_CHECK_SIZEOF(time_t)
341 AC_CHECK_SIZEOF(size_t)
343 AC_CHECK_TYPES([uint, u_char])
345 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, struct sockaddr_storage, sa_family_t], , ,
346 [#ifdef HAVE_SYS_TYPES_H
347 #include <sys/types.h>
348 #endif
349 #ifdef HAVE_NETINET_IN_H
350 #include <netinet/in.h>
351 #endif
352 #ifdef HAVE_NETINET_IN6_H
353 #include <netinet/in6.h>
354 #endif
355 #ifdef HAVE_SYS_SOCKET_H
356 #include <sys/socket.h>
357 #endif
358 #ifdef MS_WINDOWS
359 #define WIN32_WINNT 0x400
360 #define _WIN32_WINNT 0x400
361 #define WIN32_LEAN_AND_MEAN
362 #if defined(_MSC_VER) && (_MSC_VER < 1300)
363 #include <winsock.h>
364 #else
365 #include <winsock2.h>
366 #include <ws2tcpip.h>
367 #endif
368 #endif
370 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16], , ,
371 [#ifdef HAVE_SYS_TYPES_H
372 #include <sys/types.h>
373 #endif
374 #ifdef HAVE_NETINET_IN_H
375 #include <netinet/in.h>
376 #endif
377 #ifdef HAVE_NETINET_IN6_H
378 #include <netinet/in6.h>
379 #endif
380 #ifdef HAVE_SYS_SOCKET_H
381 #include <sys/socket.h>
382 #endif
383 #ifdef MS_WINDOWS
384 #define WIN32_WINNT 0x400
385 #define _WIN32_WINNT 0x400
386 #define WIN32_LEAN_AND_MEAN
387 #if defined(_MSC_VER) && (_MSC_VER < 1300)
388 #include <winsock.h>
389 #else
390 #include <winsock2.h>
391 #include <ws2tcpip.h>
392 #endif
393 #endif
396 AC_CHECK_TYPES([rlim_t], , ,
397 [#ifdef HAVE_SYS_TYPES_H
398 #include <sys/types.h>
399 #endif
400 #ifdef HAVE_SYS_RESOURCE_H
401 #include <sys/resource.h>
402 #endif
405 if test -z "$CROSS_COMPILE"; then
406 AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
407 AC_RUN_IFELSE(AC_LANG_SOURCE([
408 #ifdef HAVE_SYS_TYPES_H
409 #include <sys/types.h>
410 #endif
411 #ifdef HAVE_SYS_TIME_H
412 #include <sys/time.h>
413 #endif
414 #ifdef HAVE_TIME_H
415 #include <time.h>
416 #endif
417 int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }]),
418   tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
420 else
421   # Cross-compiling; let's hope the target platform isn't loony.
422   AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
423   tor_cv_time_t_signed=yes
426 if test "$tor_cv_time_t_signed" = yes; then
427   AC_DEFINE([TIME_T_IS_SIGNED], 1,
428             [Define to 1 iff time_t is signed])
431 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
432 #ifdef HAVE_SYS_SOCKET_H
433 #include <sys/socket.h>
434 #endif
437 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
439 AC_CHECK_SIZEOF(cell_t)
441 # Now make sure that NULL can be represented as zero bytes.
442 if test -z "$CROSS_COMPILE"; then
443 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
444 [AC_RUN_IFELSE([AC_LANG_SOURCE(
445 [[#include <stdlib.h>
446 #include <string.h>
447 #include <stdio.h>
448 #ifdef HAVE_STDDEF_H
449 #include <stddef.h>
450 #endif
451 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
452 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
453        [tor_cv_null_is_zero=yes],
454        [tor_cv_null_is_zero=no],
455        [tor_cv_null_is_zero=cross])])
457 else
458   # Cross-compiling; let's hope that the target isn't raving mad.
459   AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
460   tor_cv_null_is_zero=yes
463 if test "$tor_cv_null_is_zero" = yes; then
464   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
465             [Define to 1 iff memset(0) sets pointers to NULL])
468 # And what happens when we malloc zero?
470 if test -z "$CROSS_COMPILE"; then
471 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
472 [AC_RUN_IFELSE([AC_LANG_SOURCE(
473 [[#include <stdlib.h>
474 #include <string.h>
475 #include <stdio.h>
476 #ifdef HAVE_STDDEF_H
477 #include <stddef.h>
478 #endif
479 int main () { return malloc(0)?0:1; }]])],
480        [tor_cv_malloc_zero_works=yes],
481        [tor_cv_malloc_zero_works=no],
482        [tor_cv_malloc_zero_works=cross])])
484 else
485   # Cross-compiling; let's hope that the target isn't raving mad.
486   AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
487   tor_cv_malloc_zero_works=no
490 if test "$tor_cv_malloc_zero_works" = yes; then
491   AC_DEFINE([MALLOC_ZERO_WORKS], 1,
492             [Define to 1 iff malloc(0) returns a pointer])
495 # whether we seem to be in a 2s-complement world.
496 if test -z "$CROSS_COMPILE"; then
497 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
498 [AC_RUN_IFELSE([AC_LANG_SOURCE(
499 [[int main () { int problem = ((-99) != (~99)+1);
500 return problem ? 1 : 0; }]])],
501        [tor_cv_twos_complement=yes],
502        [tor_cv_twos_complement=no],
503        [tor_cv_twos_complement=cross])])
505 else
506   # Cross-compiling; let's hope that the target isn't raving mad.
507   AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
508   tor_cv_twos_complement=yes
511 if test "$tor_cv_twos_complement" = yes; then
512   AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
513             [Define to 1 iff we represent negative integers with two's complement])
516 # Whether we should use the dmalloc memory allocation debugging library.
517 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
518 AC_ARG_WITH(dmalloc,
519 [  --with-dmalloc          Use debug memory allocation library. ],
520 [if [[ "$withval" = "yes" ]]; then
521   dmalloc=1
522   AC_MSG_RESULT(yes)
523 else
524   dmalloc=1
525   AC_MSG_RESULT(no)
526 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
529 if [[ $dmalloc -eq 1 ]]; then
530   AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
531   AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
532   AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
533   AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
534   AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup)
537 # Allow user to specify an alternate syslog facility
538 AC_ARG_WITH(syslog-facility,
539 [  --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
540 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
541 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
542 AC_SUBST(LOGFACILITY)
544 # Check for gethostbyname_r in all its glorious incompatible versions.
545 #   (This logic is based on that in Python's configure.in)
546 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
547   [Define this if you have any gethostbyname_r()])
549 AC_CHECK_FUNC(gethostbyname_r, [
550   AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
551   OLD_CFLAGS=$CFLAGS
552   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
553   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([
554 #include <netdb.h>
555   ], [[
556     char *cp1, *cp2;
557     struct hostent *h1, *h2;
558     int i1, i2;
559     (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
560   ]]),[
561     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
562     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
563      [Define this if gethostbyname_r takes 6 arguments])
564     AC_MSG_RESULT(6)
565   ], [
566     AC_TRY_COMPILE([
567 #include <netdb.h>
568     ], [
569       char *cp1, *cp2;
570       struct hostent *h1;
571       int i1, i2;
572       (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
573     ], [
574       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
575       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
576         [Define this if gethostbyname_r takes 5 arguments])
577       AC_MSG_RESULT(5)
578    ], [
579       AC_TRY_COMPILE([
580 #include <netdb.h>
581      ], [
582        char *cp1;
583        struct hostent *h1;
584        struct hostent_data hd;
585        (void) gethostbyname_r(cp1,h1,&hd);
586      ], [
587        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
588        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
589          [Define this if gethostbyname_r takes 3 arguments])
590        AC_MSG_RESULT(3)
591      ], [
592        AC_MSG_RESULT(0)
593      ])
594   ])
595  ])
596  CFLAGS=$OLD_CFLAGS
599 AC_CACHE_CHECK([whether the C compiler supports __func__],
600   tor_cv_have_func_macro,
601   AC_COMPILE_IFELSE([
602 #include <stdio.h>
603 int main(int c, char **v) { puts(__func__); }],
604   tor_cv_have_func_macro=yes,
605   tor_cv_have_func_macro=no))
607 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
608   tor_cv_have_FUNC_macro,
609   AC_COMPILE_IFELSE([
610 #include <stdio.h>
611 int main(int c, char **v) { puts(__FUNC__); }],
612   tor_cv_have_FUNC_macro=yes,
613   tor_cv_have_FUNC_macro=no))
615 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
616   tor_cv_have_FUNCTION_macro,
617   AC_COMPILE_IFELSE([
618 #include <stdio.h>
619 int main(int c, char **v) { puts(__FUNCTION__); }],
620   tor_cv_have_FUNCTION_macro=yes,
621   tor_cv_have_FUNCTION_macro=no))
623 if test "$tor_cv_have_func_macro" = 'yes'; then
624   AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
627 if test "$tor_cv_have_FUNC_macro" = 'yes'; then
628   AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
631 if test "$tor_cv_have_FUNCTION_macro" = 'yes'; then
632   AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
633            [Defined if the compiler supports __FUNCTION__])
636 # $prefix stores the value of the --prefix command line option, or
637 # NONE if the option wasn't set.  In the case that it wasn't set, make
638 # it be the default, so that we can use it to expand directories now.
639 if test "x$prefix" = "xNONE"; then
640   prefix=$ac_default_prefix
643 # and similarly for $exec_prefix
644 if test "x$exec_prefix" = "xNONE"; then
645   exec_prefix=$prefix
648 if test "x$CONFDIR" = "x"; then
649   CONFDIR=`eval echo $sysconfdir/tor`
651 AC_SUBST(CONFDIR)
652 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
653 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
655 BINDIR=`eval echo $bindir`
656 AC_SUBST(BINDIR)
657 LOCALSTATEDIR=`eval echo $localstatedir`
658 AC_SUBST(LOCALSTATEDIR)
660 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
661 # than autoconf's macros like.
662 if test "$ac_cv_c_compiler_gnu" = yes; then
663   CFLAGS="$CFLAGS -Wall -g -O2"
664 else
665   CFLAGS="$CFLAGS -g -O"
666   enable_gcc_warnings=no
669 # Add some more warnings which we use in development but not in the
670 # released versions.  (Some relevant gcc versions can't handle these.)
671 if test x$enable_gcc_warnings = xyes; then
673   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [
674 #if !defined(__GNUC__) || (__GNUC__ < 4)
675 #error
676 #endif]), have_gcc4=yes, have_gcc4=no)
678   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [
679 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
680 #error
681 #endif]), have_gcc42=yes, have_gcc42=no)
683   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"
684   # Disabled, so we can use mallinfo(): -Waggregate-return
686   if test x$have_gcc4 = xyes ; then 
687     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
688     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
689   fi
691   if test x$have_gcc42 = xyes ; then 
692     # These warnings break gcc 4.0.2 and work on gcc 4.2
693     # XXXX020 Use -fstack-protector.
694     # XXXX020 See if any of these work with earlier versions.
695     CFLAGS="$CFLAGS -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=5"
696   fi
698 ##This will break the world on some 64-bit architectures
699 # CFLAGS="$CFLAGS -Winline"
703 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
705 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])
706 AC_OUTPUT
708 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
709   ./contrib/updateVersions.pl