2 dnl Copyright (c) 2001-2004, Roger Dingledine
3 dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
4 dnl See LICENSE for licensing information
7 AM_INIT_AUTOMAKE(tor, 0.1.2.6-alpha-dev)
8 AM_CONFIG_HEADER(orconfig.h)
12 if test -f /etc/redhat-release; then
13 CFLAGS="$CFLAGS -I/usr/kerberos/include"
17 AC_HELP_STRING(--enable-debug, compile with debugging info),
18 [if test x$enableval = xyes; then
22 AC_ARG_ENABLE(eventdns,
23 AC_HELP_STRING(--enable-eventdns, enable asynchronous dns module),
24 [case "${enableval}" in
27 *) AC_MSG_ERROR(bad value for --enable-eventdns) ;;
28 esac], [eventdns=true])
29 AM_CONDITIONAL(EVENTDNS, test x$eventdns = xtrue)
30 if test x$eventdns = xtrue; then
31 AC_DEFINE([USE_EVENTDNS], 1, "Define to 1 if we'll be using eventdns.c")
34 AC_ARG_ENABLE(transparent,
35 AC_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 AC_HELP_STRING(--disable-threads, disable multi-threading support))
45 if test x$enable_threads = x; then
47 *-*-netbsd* | *-*-openbsd* )
48 # Don't try multithreading on netbsd -- there is no threadsafe DNS
49 # lookup function there.
50 if test x$eventdns != xtrue; then
51 AC_MSG_NOTICE([You are running OpenBSD or NetBSD; I am assuming that
52 getaddrinfo is not threadsafe here, so I will disable threads.])
56 # Don't try multithreading on solaris -- cpuworkers seem to lock.
57 AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
58 cpu workers lock up here, so I will disable threads.])
61 enable_threads="yes";;
65 if test $enable_threads = "yes"; then
66 AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
71 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
75 AC_ARG_ENABLE(gcc-warnings,
76 AC_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
82 # The big search for OpenSSL
83 # copied from openssh's configure.ac
86 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
88 if test "x$withval" != "xno" ; then
95 AC_ARG_WITH(libevent-dir,
96 [ --with-libevent-dir=PATH Specify path to Libevent installation ],
98 if test "x$withval" != "xno" ; then
99 trylibeventdir=$withval
105 AC_ARG_WITH(tor-user,
106 [ --with-tor-user=NAME Specify username for tor daemon ],
114 AC_ARG_WITH(tor-group,
115 [ --with-tor-group=NAME Specify group name for tor daemon ],
123 dnl If WIN32 is defined and non-zero, we are building for win32
124 AC_MSG_CHECKING([for win32])
126 int main(int c, char **v) {
137 bwin32=true; AC_MSG_RESULT([yes]),
138 bwin32=false; AC_MSG_RESULT([no]),
139 bwin32=cross; AC_MSG_RESULT([cross])
142 if test $bwin32 = cross; then
143 AC_MSG_CHECKING([for win32 (cross)])
146 int main(int c, char **v) {return 0;}
149 int main(int c, char **v) {return x(y);}
152 bwin32=true; AC_MSG_RESULT([yes]),
153 bwin32=false; AC_MSG_RESULT([no]))
156 if test $bwin32 = true; then
157 AC_DEFINE(MS_WINDOWS, 1, [Define to 1 if we are building for Windows.])
160 dnl Enable C99 when compiling with MIPSpro
161 AC_MSG_CHECKING([for MIPSpro compiler])
163 #if (defined(__sgi) && defined(_COMPILER_VERSION))
168 bmipspro=false; AC_MSG_RESULT([no]),
169 bmipspro=true; AC_MSG_RESULT([yes]))
171 if test $bmipspro = true; then
172 CFLAGS="$CFLAGS -c99"
175 AC_SEARCH_LIBS(socket, [socket])
176 AC_SEARCH_LIBS(gethostbyname, [nsl])
177 AC_SEARCH_LIBS(dlopen, [dl])
178 AC_SEARCH_LIBS(inet_aton, [resolv])
180 if test $enable_threads = "yes"; then
181 AC_SEARCH_LIBS(pthread_create, [pthread])
182 AC_SEARCH_LIBS(pthread_detach, [pthread])
185 dnl -------------------------------------------------------------------
186 dnl Check for functions before libevent, since libevent-1.2 apparently
187 dnl exports strlcpy without defining it in a header.
189 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull ftello getaddrinfo localtime_r gmtime_r memmem strtok_r)
191 if test $enable_threads = "yes"; then
192 AC_CHECK_HEADERS(pthread.h)
193 AC_CHECK_FUNCS(pthread_create)
196 dnl ------------------------------------------------------
197 dnl Where do you live, libevent? And how do we call you?
199 AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
201 saved_LDFLAGS="$LDFLAGS"
202 saved_CPPFLAGS="$CPPFLAGS"
204 for ledir in $trylibeventdir "" $prefix /usr/local /usr/pkg ; do
205 LDFLAGS="$saved_LDFLAGS"
207 if test $bwin32 = true; then
208 LIBS="$saved_LIBS -levent -lws2_32"
210 LIBS="$saved_LIBS -levent"
213 # Skip the directory if it isn't there.
214 if test ! -z "$ledir" -a ! -d "$ledir" ; then
217 if test ! -z "$ledir" ; then
218 if test -d "$ledir/lib" ; then
219 LDFLAGS="-L$ledir/lib $LDFLAGS"
221 LDFLAGS="-L$ledir $LDFLAGS"
223 if test -d "$ledir/include" ; then
224 CPPFLAGS="-I$ledir/include $CPPFLAGS"
226 CPPFLAGS="-I$ledir $CPPFLAGS"
229 # Can I compile and link it?
230 AC_TRY_LINK([#include <sys/time.h>
231 #include <sys/types.h>
232 #include <event.h>], [ event_init(); ],
233 [ libevent_linked=yes ], [ libevent_linked=no ])
234 if test $libevent_linked = yes; then
235 if test ! -z "$ledir" ; then
236 ac_cv_libevent_dir=$ledir
238 ac_cv_libevent_dir="(system)"
245 LDFLAGS="$saved_LDFLAGS"
246 CPPFLAGS="$saved_CPPFLAGS"
247 if test $le_found = no ; then
248 AC_MSG_ERROR([Could not find a linkable libevent. You can specify an explicit path using --with-libevent-dir])
252 if test $bwin32 = true; then
253 LIBS="$LIBS -levent -lws2_32"
257 if test $ac_cv_libevent_dir != "(system)"; then
258 if test -d "$ac_cv_libevent_dir/lib" ; then
259 LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS"
260 le_libdir="$ac_cv_libevent_dir/lib"
262 LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS"
263 le_libdir="$ac_cv_libevent_dir"
265 if test -d "$ac_cv_libevent_dir/include" ; then
266 CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS"
268 CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS"
272 if test -z "$CROSS_COMPILE"; then
273 AC_CACHE_CHECK([whether we need extra options to link libevent],
274 ac_cv_libevent_linker_option, [
275 saved_LDFLAGS="$LDFLAGS"
278 for le_extra in "" "-Wl,-R$le_libdir" "-R$le_libdir" "-Wl,-rpath,$le_libdir" ; do
279 LDFLAGS="$le_extra $saved_LDFLAGS"
280 AC_TRY_RUN([void *event_init(void);
281 int main(int c, char **v) {
282 event_init(); return 0;
284 libevent_runs=yes, libevent_runs=no, libevent_runs=cross)
285 if test $libevent_runs != no ; then
286 if test -z "$le_extra" ; then
287 ac_cv_libevent_linker_option='(none)'
289 ac_cv_libevent_linker_option=$le_extra
295 if test $le_runs = no ; then
296 AC_MSG_ERROR([Found linkable libevent in $ac_cv_libevent_dir, but it doesn't run, even with -R. Maybe specify another using --with-libevent-dir?])
298 LDFLAGS="$saved_LDFLAGS"
301 if test $ac_cv_libevent_linker_option != '(none)' ; then
302 LDFLAGS="$ac_cv_libevent_linker_option $LDFLAGS"
306 dnl Now check for particular libevent functions.
307 AC_CHECK_FUNCS(event_get_version event_get_method event_set_log_callback)
309 dnl ------------------------------------------------------
310 dnl Where do you live, openssl? And how do we call you?
312 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
314 saved_LDFLAGS="$LDFLAGS"
315 saved_CPPFLAGS="$CPPFLAGS"
317 for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
318 LDFLAGS="$saved_LDFLAGS"
320 if test $bwin32 = true; then
321 LIBS="$saved_LIBS -lssl -lcrypto -lws2_32 -lgdi32"
323 LIBS="$saved_LIBS -lssl -lcrypto"
326 # Skip the directory if it isn't there.
327 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
330 if test ! -z "$ssldir" ; then
331 if test -d "$ssldir/lib" ; then
332 LDFLAGS="-L$ssldir/lib $LDFLAGS"
334 LDFLAGS="-L$ssldir $LDFLAGS"
336 if test -d "$ssldir/include" ; then
337 CPPFLAGS="-I$ssldir/include $CPPFLAGS"
339 CPPFLAGS="-I$ssldir $CPPFLAGS"
343 AC_TRY_LINK([#include <openssl/rand.h>],
344 [ RAND_add((void*)0,0,0); ],
345 [ openssl_linked=yes ], [ openssl_linked=no ])
346 if test $openssl_linked = yes; then
347 if test ! -z "$ssldir" ; then
348 ac_cv_openssl_dir=$ssldir
350 ac_cv_openssl_dir="(system)"
357 LDFLAGS="$saved_LDFLAGS"
358 CPPFLAGS="$saved_CPPFLAGS"
359 if test $ssl_found = no ; then
360 AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
364 if test $bwin32 = true; then
365 LIBS="$LIBS -lssl -lcrypto -lws2_32 -lgdi32"
367 LIBS="$LIBS -lssl -lcrypto"
370 if test "$ac_cv_openssl_dir" != "(system)"; then
371 if test -d "$ac_cv_openssl_dir/lib" ; then
372 LDFLAGS="-L$ac_cv_openssl_dir/lib $LDFLAGS"
373 ssl_libdir="$ac_cv_openssl_dir/lib"
375 LDFLAGS="-L$ac_cv_openssl_dir $LDFLAGS"
376 ssl_libdir="$ac_cv_openssl_dir"
378 if test -d "$ac_cv_openssl_dir/include" ; then
379 CPPFLAGS="-I$ac_cv_openssl_dir/include $CPPFLAGS"
381 CPPFLAGS="-I$ac_cv_openssl_dir $CPPFLAGS"
385 if test -z "$CROSS_COMPILE"
387 AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
388 ac_cv_openssl_linker_option, [
389 saved_LDFLAGS="$LDFLAGS"
392 for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
393 LDFLAGS="$ssl_extra $saved_LDFLAGS"
396 #include <openssl/rand.h>
400 memset(a, 0, sizeof(a));
401 RAND_add(a, sizeof(a), sizeof(a));
402 return(RAND_status() <= 0);
405 openssl_runs=yes, openssl_runs=no, openssl_runs=cross)
406 if test $openssl_runs != no ; then
407 if test "$linked_with" = nothing; then
408 linked_with="$ssl_extra"
411 #include <openssl/opensslv.h>
412 #include <openssl/crypto.h>
414 return (OPENSSL_VERSION_NUMBER == SSLeay()) == 0;
416 right_version=yes, right_version=no)
417 if test "$right_version" = yes; then
418 if test -z "$ssl_extra" ; then
419 ac_cv_openssl_linker_option='(none)'
421 ac_cv_openssl_linker_option=$ssl_extra
428 if test $ssl_runs = no ; then
429 if test "$linked_with" = 'nothing' ; then
430 AC_MSG_ERROR([Found linkable OpenSSL in $ac_cv_openssl_dir, but it doesn't run, even with -R. Maybe specify another using --with-ssl-dir?])
432 if test -z "$linked_with" ; then
433 ac_cv_openssl_linker_option='(none)'
435 ac_cv_openssl_linker_option=$linked_with
437 AC_MSG_WARN([I managed to make OpenSSL link and run, but I couldn't make it link against the same version I found header files for.])
440 LDFLAGS="$saved_LDFLAGS"
443 if test "$ac_cv_openssl_linker_option" != '(none)' ; then
444 LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
448 dnl Make sure to enable support for large off_t if avalable.
452 dnl The warning message here is no longer strictly accurate.
454 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))
456 AC_CHECK_HEADERS(netdb.h sys/ioctl.h sys/socket.h arpa/inet.h netinet/in.h pwd.h grp.h)
458 AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.),
459 [#ifdef HAVE_SYS_TYPES_H
460 #include <sys/types.h>
462 #ifdef HAVE_SYS_TIME_H
463 #include <sys/time.h>
471 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.))
473 dnl These headers are not essential
475 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)
477 AC_CHECK_HEADERS(net/if.h, [net_if_found=1], [net_if_found=0],
478 [#ifdef HAVE_SYS_TYPES_H
479 #include <sys/types.h>
481 #ifdef HAVE_SYS_SOCKET_H
482 #include <sys/socket.h>
484 AC_CHECK_HEADERS(net/pfvar.h, [net_pfvar_found=1], [net_pfvar_found=0],
485 [#ifdef HAVE_SYS_TYPES_H
486 #include <sys/types.h>
488 #ifdef HAVE_SYS_SOCKET_H
489 #include <sys/socket.h>
494 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
495 [linux_netfilter_ipv4=1], [linux_netfilter_ipv4=0],
496 [#ifdef HAVE_SYS_TYPES_H
497 #include <sys/types.h>
499 #ifdef HAVE_SYS_SOCKET_H
500 #include <sys/socket.h>
503 if test x$transparent = xtrue ; then
505 if test x$net_if_found = x1 -a x$net_pfvar_found = x1 ; then
508 if test x$linux_netfilter_ipv4 = x1 ; then
511 if test x$transparent_ok = x1 ; then
512 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
515 AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
518 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
524 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
525 [#ifdef HAVE_SYS_TYPES_H
526 #include <sys/types.h>
528 #ifdef HAVE_SYS_TIME_H
529 #include <sys/time.h>
532 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
535 AC_CHECK_SIZEOF(int8_t)
536 AC_CHECK_SIZEOF(int16_t)
537 AC_CHECK_SIZEOF(int32_t)
538 AC_CHECK_SIZEOF(int64_t)
539 AC_CHECK_SIZEOF(uint8_t)
540 AC_CHECK_SIZEOF(uint16_t)
541 AC_CHECK_SIZEOF(uint32_t)
542 AC_CHECK_SIZEOF(uint64_t)
543 AC_CHECK_SIZEOF(intptr_t)
544 AC_CHECK_SIZEOF(uintptr_t)
546 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
548 AC_CHECK_SIZEOF(char)
549 AC_CHECK_SIZEOF(short)
551 AC_CHECK_SIZEOF(long)
552 AC_CHECK_SIZEOF(long long)
553 AC_CHECK_SIZEOF(__int64)
554 AC_CHECK_SIZEOF(void *)
555 AC_CHECK_SIZEOF(time_t)
556 AC_CHECK_SIZEOF(size_t)
558 AC_CHECK_TYPES([uint, u_char])
560 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_storage], , ,
561 [#ifdef HAVE_SYS_TYPES_H
562 #include <sys/types.h>
564 #ifdef HAVE_NETINET_IN_H
565 #include <netinet/in.h>
567 #ifdef HAVE_NETINET_IN6_H
568 #include <netinet/in6.h>
570 #ifdef HAVE_SYS_SOCKET_H
571 #include <sys/socket.h>
574 if test -z "$CROSS_COMPILE"; then
575 AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
577 #ifdef HAVE_SYS_TYPES_H
578 #include <sys/types.h>
580 #ifdef HAVE_SYS_TIME_H
581 #include <sys/time.h>
586 int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }],
587 tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
590 # Cross-compiling; let's hope the target platform isn't loony.
591 AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
592 tor_cv_time_t_signed=yes
595 if test $tor_cv_time_t_signed = yes; then
596 AC_DEFINE([TIME_T_IS_SIGNED], 1,
597 [Define to 1 iff time_t is signed])
600 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
601 #ifdef HAVE_SYS_SOCKET_H
602 #include <sys/socket.h>
606 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
608 AC_CHECK_SIZEOF(cell_t)
610 # Now make sure that NULL can be represented as zero bytes.
611 if test -z "$CROSS_COMPILE"; then
612 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
613 [AC_RUN_IFELSE([AC_LANG_SOURCE(
614 [[#include <stdlib.h>
620 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
621 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
622 [tor_cv_null_is_zero=yes],
623 [tor_cv_null_is_zero=no],
624 [tor_cv_null_is_zero=cross])])
627 # Cross-compiling; let's hope that the target isn't raving mad.
628 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
629 tor_cv_null_is_zero=yes
632 if test $tor_cv_null_is_zero = yes; then
633 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
634 [Define to 1 iff memset(0) sets pointers to NULL])
637 # And what happens when we malloc zero?
639 if test -z "$CROSS_COMPILE"; then
640 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
641 [AC_RUN_IFELSE([AC_LANG_SOURCE(
642 [[#include <stdlib.h>
648 int main () { return malloc(0)?0:1; }]])],
649 [tor_cv_malloc_zero_works=yes],
650 [tor_cv_malloc_zero_works=no],
651 [tor_cv_malloc_zero_works=cross])])
654 # Cross-compiling; let's hope that the target isn't raving mad.
655 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
656 tor_cv_malloc_zero_works=no
659 if test $tor_cv_malloc_zero_works = yes; then
660 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
661 [Define to 1 iff malloc(0) returns a pointer])
664 # whether we seem to be in a 2s-complement world.
665 if test -z "$CROSS_COMPILE"; then
666 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
667 [AC_RUN_IFELSE([AC_LANG_SOURCE(
668 [[int main () { int problem = ((-99) != (~99)+1);
669 return problem ? 1 : 0; }]])],
670 [tor_cv_twos_complement=yes],
671 [tor_cv_twos_complement=no],
672 [tor_cv_twos_complement=cross])])
675 # Cross-compiling; let's hope that the target isn't raving mad.
676 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
677 tor_cv_twos_complement=yes
680 if test $tor_cv_twos_complement = yes; then
681 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
682 [Define to 1 iff we represent negative integers with two's complement])
685 # Whether we should use the dmalloc memory allocation debugging library.
686 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
688 [ --with-dmalloc Use debug memory allocation library. ],
689 [if [[ "$withval" = "yes" ]]; then
695 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
698 if [[ $dmalloc -eq 1 ]]; then
699 AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
700 AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
701 AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
702 AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
705 # Allow user to specify an alternate syslog facility
706 AC_ARG_WITH(syslog-facility,
707 [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
708 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
709 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
710 AC_SUBST(LOGFACILITY)
712 # Check for gethostbyname_r in all its glorious incompatible versions.
713 # (This logic is based on that in Python's configure.in)
714 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
715 [Define this if you have any gethostbyname_r()])
717 AC_CHECK_FUNC(gethostbyname_r, [
718 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
720 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
725 struct hostent *h1, *h2;
727 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
729 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
730 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
731 [Define this if gethostbyname_r takes 6 arguments])
740 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
742 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
743 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
744 [Define this if gethostbyname_r takes 5 arguments])
752 struct hostent_data hd;
753 (void) gethostbyname_r(cp1,h1,&hd);
755 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
756 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
757 [Define this if gethostbyname_r takes 3 arguments])
767 AC_CACHE_CHECK([whether the C compiler supports __func__],
768 ac_cv_have_func_macro,
771 int main(int c, char **v) { puts(__func__); }],
772 ac_cv_have_func_macro=yes,
773 ac_cv_have_func_macro=no))
775 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
776 ac_cv_have_FUNC_macro,
779 int main(int c, char **v) { puts(__FUNC__); }],
780 ac_cv_have_FUNC_macro=yes,
781 ac_cv_have_FUNC_macro=no))
783 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
784 ac_cv_have_FUNCTION_macro,
787 int main(int c, char **v) { puts(__FUNCTION__); }],
788 ac_cv_have_FUNCTION_macro=yes,
789 ac_cv_have_FUNCTION_macro=no))
791 if test $ac_cv_have_func_macro = 'yes'; then
792 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
795 if test $ac_cv_have_FUNC_macro = 'yes'; then
796 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
799 if test $ac_cv_have_FUNCTION_macro = 'yes'; then
800 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
801 [Defined if the compiler supports __FUNCTION__])
804 # $prefix stores the value of the --prefix command line option, or
805 # NONE if the option wasn't set. In the case that it wasn't set, make
806 # it be the default, so that we can use it to expand directories now.
807 if test "x$prefix" = "xNONE"; then
808 prefix=$ac_default_prefix
811 # and similarly for $exec_prefix
812 if test "x$exec_prefix" = "xNONE"; then
816 if test "x$CONFDIR" = "x"; then
817 CONFDIR=`eval echo $sysconfdir/tor`
820 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
821 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
823 BINDIR=`eval echo $bindir`
826 LOCALSTATEDIR=`eval echo $localstatedir`
827 AC_SUBST(LOCALSTATEDIR)
828 AH_TEMPLATE([LOCALSTATEDIR], [Default location to store state files.])
829 AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
831 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
832 # than autoconf's macros like.
833 if test $ac_cv_c_compiler_gnu = yes; then
834 CFLAGS="$CFLAGS -Wall -g -O2"
836 CFLAGS="$CFLAGS -g -O"
837 enable_gcc_warnings=no
840 # Add some more warnings which we use in the cvs version but not in the
841 # released versions. (Some relevant gcc versions can't handle these.)
842 if test x$enable_gcc_warnings = xyes; then
845 #if !defined(__GNUC__) || (__GNUC__ < 4)
847 #endif], have_gcc4=yes, have_gcc4=no)
849 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Waggregate-return -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum -Werror"
851 if test x$have_gcc4 = xyes ; then
852 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
853 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
856 ##This will break the world on some 64-bit architectures
857 # CFLAGS="$CFLAGS -Winline"
861 AC_OUTPUT(Makefile tor.spec 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 src/config/Makefile src/common/Makefile src/or/Makefile src/win32/Makefile src/tools/Makefile contrib/suse/Makefile contrib/suse/tor.sh)
863 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
864 ./contrib/updateVersions.pl