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
7 AM_INIT_AUTOMAKE(tor, 0.1.2.14)
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.])
55 # This was an inadvertant default up through 0.1.2.14; in 0.2.0.x,
56 # it's getting some testing, but for now, best leave threads off
57 # unless the user urns them on.
58 AC_MSG_NOTICE([You are running OpenBSD or NetBSD; Tor 0.1.2.x hasn't
59 been tested with threads on these platforms, so I'm turning them off. You
60 can enable threads by passing --enable-threads to the configure script.])
64 # Don't try multithreading on solaris -- cpuworkers seem to lock.
65 AC_MSG_NOTICE([You are running Solaris; Sometimes threading makes
66 cpu workers lock up here, so I will disable threads.])
69 enable_threads="yes";;
73 if test $enable_threads = "yes"; then
74 AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
79 AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
83 AC_ARG_ENABLE(gcc-warnings,
84 AC_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
90 # The big search for OpenSSL
91 # copied from openssh's configure.ac
94 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
96 if test "x$withval" != "xno" ; then
103 AC_ARG_WITH(libevent-dir,
104 [ --with-libevent-dir=PATH Specify path to Libevent installation ],
106 if test "x$withval" != "xno" ; then
107 trylibeventdir=$withval
113 AC_ARG_WITH(tor-user,
114 [ --with-tor-user=NAME Specify username for tor daemon ],
122 AC_ARG_WITH(tor-group,
123 [ --with-tor-group=NAME Specify group name for tor daemon ],
131 dnl If WIN32 is defined and non-zero, we are building for win32
132 AC_MSG_CHECKING([for win32])
134 int main(int c, char **v) {
145 bwin32=true; AC_MSG_RESULT([yes]),
146 bwin32=false; AC_MSG_RESULT([no]),
147 bwin32=cross; AC_MSG_RESULT([cross])
150 if test $bwin32 = cross; then
151 AC_MSG_CHECKING([for win32 (cross)])
154 int main(int c, char **v) {return 0;}
157 int main(int c, char **v) {return x(y);}
160 bwin32=true; AC_MSG_RESULT([yes]),
161 bwin32=false; AC_MSG_RESULT([no]))
164 if test $bwin32 = true; then
165 AC_DEFINE(MS_WINDOWS, 1, [Define to 1 if we are building for Windows.])
168 dnl Enable C99 when compiling with MIPSpro
169 AC_MSG_CHECKING([for MIPSpro compiler])
171 #if (defined(__sgi) && defined(_COMPILER_VERSION))
176 bmipspro=false; AC_MSG_RESULT([no]),
177 bmipspro=true; AC_MSG_RESULT([yes]))
179 if test $bmipspro = true; then
180 CFLAGS="$CFLAGS -c99"
183 AC_SEARCH_LIBS(socket, [socket])
184 AC_SEARCH_LIBS(gethostbyname, [nsl])
185 AC_SEARCH_LIBS(dlopen, [dl])
186 AC_SEARCH_LIBS(inet_aton, [resolv])
188 if test $enable_threads = "yes"; then
189 AC_SEARCH_LIBS(pthread_create, [pthread])
190 AC_SEARCH_LIBS(pthread_detach, [pthread])
193 dnl -------------------------------------------------------------------
194 dnl Check for functions before libevent, since libevent-1.2 apparently
195 dnl exports strlcpy without defining it in a header.
197 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull ftello getaddrinfo localtime_r gmtime_r memmem strtok_r)
199 if test $enable_threads = "yes"; then
200 AC_CHECK_HEADERS(pthread.h)
201 AC_CHECK_FUNCS(pthread_create)
204 dnl ------------------------------------------------------
205 dnl Where do you live, libevent? And how do we call you?
207 dnl This is a disgusting hack so we safely include recent libevent headers.
208 AC_CHECK_TYPE(u_int64_t, unsigned long long)
209 AC_CHECK_TYPE(u_int32_t, unsigned long)
210 AC_CHECK_TYPE(u_int16_t, unsigned short)
211 AC_CHECK_TYPE(u_int8_t, unsigned char)
213 AC_CACHE_CHECK([for libevent directory], tor_cv_libevent_dir, [
215 saved_LDFLAGS="$LDFLAGS"
216 saved_CPPFLAGS="$CPPFLAGS"
218 for ledir in $trylibeventdir "" $prefix /usr/local /usr/pkg ; do
219 LDFLAGS="$saved_LDFLAGS"
221 if test $bwin32 = true; then
222 LIBS="$saved_LIBS -levent -lws2_32"
224 LIBS="$saved_LIBS -levent"
227 # Skip the directory if it isn't there.
228 if test ! -z "$ledir" -a ! -d "$ledir" ; then
231 if test ! -z "$ledir" ; then
232 if test -d "$ledir/lib" ; then
233 LDFLAGS="-L$ledir/lib $LDFLAGS"
235 LDFLAGS="-L$ledir $LDFLAGS"
237 if test -d "$ledir/include" ; then
238 CPPFLAGS="-I$ledir/include $CPPFLAGS"
240 CPPFLAGS="-I$ledir $CPPFLAGS"
243 # Can I compile and link it?
244 AC_TRY_LINK([#include <sys/time.h>
245 #include <sys/types.h>
246 #include <event.h>], [ event_init(); ],
247 [ libevent_linked=yes ], [ libevent_linked=no ])
248 if test $libevent_linked = yes; then
249 if test ! -z "$ledir" ; then
250 tor_cv_libevent_dir=$ledir
252 tor_cv_libevent_dir="(system)"
259 LDFLAGS="$saved_LDFLAGS"
260 CPPFLAGS="$saved_CPPFLAGS"
261 if test $le_found = no ; then
262 AC_MSG_ERROR([Could not find a linkable libevent. You can specify an explicit path using --with-libevent-dir])
266 if test $bwin32 = true; then
267 LIBS="$LIBS -levent -lws2_32"
271 if test $tor_cv_libevent_dir != "(system)"; then
272 if test -d "$tor_cv_libevent_dir/lib" ; then
273 LDFLAGS="-L$tor_cv_libevent_dir/lib $LDFLAGS"
274 le_libdir="$tor_cv_libevent_dir/lib"
276 LDFLAGS="-L$tor_cv_libevent_dir $LDFLAGS"
277 le_libdir="$tor_cv_libevent_dir"
279 if test -d "$tor_cv_libevent_dir/include" ; then
280 CPPFLAGS="-I$tor_cv_libevent_dir/include $CPPFLAGS"
282 CPPFLAGS="-I$tor_cv_libevent_dir $CPPFLAGS"
286 if test -z "$CROSS_COMPILE"; then
287 AC_CACHE_CHECK([whether we need extra options to link libevent],
288 tor_cv_libevent_linker_option, [
289 saved_LDFLAGS="$LDFLAGS"
292 for le_extra in "" "-Wl,-R$le_libdir" "-R$le_libdir" "-Wl,-rpath,$le_libdir" ; do
293 LDFLAGS="$le_extra $saved_LDFLAGS"
294 AC_TRY_RUN([void *event_init(void);
295 int main(int c, char **v) {
296 event_init(); return 0;
298 libevent_runs=yes, libevent_runs=no, libevent_runs=cross)
299 if test $libevent_runs != no ; then
300 if test -z "$le_extra" ; then
301 tor_cv_libevent_linker_option='(none)'
303 tor_cv_libevent_linker_option=$le_extra
309 if test $le_runs = no ; then
310 AC_MSG_ERROR([Found linkable libevent in $tor_cv_libevent_dir, but it doesn't run, even with -R. Maybe specify another using --with-libevent-dir?])
312 LDFLAGS="$saved_LDFLAGS"
315 if test $tor_cv_libevent_linker_option != '(none)' ; then
316 LDFLAGS="$tor_cv_libevent_linker_option $LDFLAGS"
320 dnl Now check for particular libevent functions.
321 AC_CHECK_FUNCS(event_get_version event_get_method event_set_log_callback)
323 dnl ------------------------------------------------------
324 dnl Where do you live, openssl? And how do we call you?
326 AC_CACHE_CHECK([for OpenSSL directory], tor_cv_openssl_dir, [
328 saved_LDFLAGS="$LDFLAGS"
329 saved_CPPFLAGS="$CPPFLAGS"
331 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
332 LDFLAGS="$saved_LDFLAGS"
334 if test $bwin32 = true; then
335 LIBS="$saved_LIBS -lssl -lcrypto -lws2_32 -lgdi32"
337 LIBS="$saved_LIBS -lssl -lcrypto"
340 # Skip the directory if it isn't there.
341 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
344 if test ! -z "$ssldir" ; then
345 if test -d "$ssldir/lib" ; then
346 LDFLAGS="-L$ssldir/lib $LDFLAGS"
348 LDFLAGS="-L$ssldir $LDFLAGS"
350 if test -d "$ssldir/include" ; then
351 CPPFLAGS="-I$ssldir/include $CPPFLAGS"
353 CPPFLAGS="-I$ssldir $CPPFLAGS"
357 AC_TRY_LINK([#include <openssl/rand.h>],
358 [ RAND_add((void*)0,0,0); ],
359 [ openssl_linked=yes ], [ openssl_linked=no ])
360 if test $openssl_linked = yes; then
361 if test ! -z "$ssldir" ; then
362 tor_cv_openssl_dir=$ssldir
364 tor_cv_openssl_dir="(system)"
371 LDFLAGS="$saved_LDFLAGS"
372 CPPFLAGS="$saved_CPPFLAGS"
373 if test $ssl_found = no ; then
374 AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
378 if test $bwin32 = true; then
379 LIBS="$LIBS -lssl -lcrypto -lws2_32 -lgdi32"
381 LIBS="$LIBS -lssl -lcrypto"
384 if test "$tor_cv_openssl_dir" != "(system)"; then
385 if test -d "$tor_cv_openssl_dir/lib" ; then
386 LDFLAGS="-L$tor_cv_openssl_dir/lib $LDFLAGS"
387 ssl_libdir="$tor_cv_openssl_dir/lib"
389 LDFLAGS="-L$tor_cv_openssl_dir $LDFLAGS"
390 ssl_libdir="$tor_cv_openssl_dir"
392 if test -d "$tor_cv_openssl_dir/include" ; then
393 CPPFLAGS="-I$tor_cv_openssl_dir/include $CPPFLAGS"
395 CPPFLAGS="-I$tor_cv_openssl_dir $CPPFLAGS"
399 if test -z "$CROSS_COMPILE"
401 AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
402 tor_cv_openssl_linker_option, [
403 saved_LDFLAGS="$LDFLAGS"
406 for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
407 LDFLAGS="$ssl_extra $saved_LDFLAGS"
410 #include <openssl/rand.h>
414 memset(a, 0, sizeof(a));
415 RAND_add(a, sizeof(a), sizeof(a));
416 return(RAND_status() <= 0);
419 openssl_runs=yes, openssl_runs=no, openssl_runs=cross)
420 if test $openssl_runs != no ; then
421 if test "$linked_with" = nothing; then
422 linked_with="$ssl_extra"
425 #include <openssl/opensslv.h>
426 #include <openssl/crypto.h>
428 return (OPENSSL_VERSION_NUMBER == SSLeay()) == 0;
430 right_version=yes, right_version=no)
431 if test "$right_version" = yes; then
432 if test -z "$ssl_extra" ; then
433 tor_cv_openssl_linker_option='(none)'
435 tor_cv_openssl_linker_option=$ssl_extra
442 if test $ssl_runs = no ; then
443 if test "$linked_with" = 'nothing' ; then
444 AC_MSG_ERROR([Found linkable OpenSSL in $tor_cv_openssl_dir, but it doesn't run, even with -R. Maybe specify another using --with-ssl-dir?])
446 if test -z "$linked_with" ; then
447 tor_cv_openssl_linker_option='(none)'
449 tor_cv_openssl_linker_option=$linked_with
451 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.])
454 LDFLAGS="$saved_LDFLAGS"
457 if test "$tor_cv_openssl_linker_option" != '(none)' ; then
458 LDFLAGS="$tor_cv_openssl_linker_option $LDFLAGS"
462 dnl Make sure to enable support for large off_t if avalable.
466 dnl The warning message here is no longer strictly accurate.
468 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))
470 AC_CHECK_HEADERS(netdb.h sys/ioctl.h sys/socket.h arpa/inet.h netinet/in.h pwd.h grp.h)
472 AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.),
473 [#ifdef HAVE_SYS_TYPES_H
474 #include <sys/types.h>
476 #ifdef HAVE_SYS_TIME_H
477 #include <sys/time.h>
485 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.))
487 dnl These headers are not essential
489 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)
491 AC_CHECK_HEADERS(net/if.h, [net_if_found=1], [net_if_found=0],
492 [#ifdef HAVE_SYS_TYPES_H
493 #include <sys/types.h>
495 #ifdef HAVE_SYS_SOCKET_H
496 #include <sys/socket.h>
498 AC_CHECK_HEADERS(net/pfvar.h, [net_pfvar_found=1], [net_pfvar_found=0],
499 [#ifdef HAVE_SYS_TYPES_H
500 #include <sys/types.h>
502 #ifdef HAVE_SYS_SOCKET_H
503 #include <sys/socket.h>
508 AC_CHECK_HEADERS(linux/netfilter_ipv4.h,
509 [linux_netfilter_ipv4=1], [linux_netfilter_ipv4=0],
510 [#ifdef HAVE_SYS_TYPES_H
511 #include <sys/types.h>
513 #ifdef HAVE_SYS_SOCKET_H
514 #include <sys/socket.h>
517 if test x$transparent = xtrue ; then
519 if test x$net_if_found = x1 -a x$net_pfvar_found = x1 ; then
522 if test x$linux_netfilter_ipv4 = x1 ; then
525 if test x$transparent_ok = x1 ; then
526 AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
529 AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
532 AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
538 AC_CHECK_MEMBERS([struct timeval.tv_sec], , ,
539 [#ifdef HAVE_SYS_TYPES_H
540 #include <sys/types.h>
542 #ifdef HAVE_SYS_TIME_H
543 #include <sys/time.h>
546 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
549 AC_CHECK_SIZEOF(int8_t)
550 AC_CHECK_SIZEOF(int16_t)
551 AC_CHECK_SIZEOF(int32_t)
552 AC_CHECK_SIZEOF(int64_t)
553 AC_CHECK_SIZEOF(uint8_t)
554 AC_CHECK_SIZEOF(uint16_t)
555 AC_CHECK_SIZEOF(uint32_t)
556 AC_CHECK_SIZEOF(uint64_t)
557 AC_CHECK_SIZEOF(intptr_t)
558 AC_CHECK_SIZEOF(uintptr_t)
560 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
562 AC_CHECK_SIZEOF(char)
563 AC_CHECK_SIZEOF(short)
565 AC_CHECK_SIZEOF(long)
566 AC_CHECK_SIZEOF(long long)
567 AC_CHECK_SIZEOF(__int64)
568 AC_CHECK_SIZEOF(void *)
569 AC_CHECK_SIZEOF(time_t)
570 AC_CHECK_SIZEOF(size_t)
572 AC_CHECK_TYPES([uint, u_char])
574 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_storage], , ,
575 [#ifdef HAVE_SYS_TYPES_H
576 #include <sys/types.h>
578 #ifdef HAVE_NETINET_IN_H
579 #include <netinet/in.h>
581 #ifdef HAVE_NETINET_IN6_H
582 #include <netinet/in6.h>
584 #ifdef HAVE_SYS_SOCKET_H
585 #include <sys/socket.h>
588 if test -z "$CROSS_COMPILE"; then
589 AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
591 #ifdef HAVE_SYS_TYPES_H
592 #include <sys/types.h>
594 #ifdef HAVE_SYS_TIME_H
595 #include <sys/time.h>
600 int main(int c, char**v) { if (((time_t)-1)<0) return 1; else return 0; }],
601 tor_cv_time_t_signed=no, tor_cv_time_t_signed=yes)
604 # Cross-compiling; let's hope the target platform isn't loony.
605 AC_MSG_NOTICE([Cross compiling: assuming that time_t is signed.])
606 tor_cv_time_t_signed=yes
609 if test $tor_cv_time_t_signed = yes; then
610 AC_DEFINE([TIME_T_IS_SIGNED], 1,
611 [Define to 1 iff time_t is signed])
614 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
615 #ifdef HAVE_SYS_SOCKET_H
616 #include <sys/socket.h>
620 # We want to make sure that we _don't_ have a cell_t defined, like IRIX does.
622 AC_CHECK_SIZEOF(cell_t)
624 # Now make sure that NULL can be represented as zero bytes.
625 if test -z "$CROSS_COMPILE"; then
626 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
627 [AC_RUN_IFELSE([AC_LANG_SOURCE(
628 [[#include <stdlib.h>
634 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
635 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
636 [tor_cv_null_is_zero=yes],
637 [tor_cv_null_is_zero=no],
638 [tor_cv_null_is_zero=cross])])
641 # Cross-compiling; let's hope that the target isn't raving mad.
642 AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
643 tor_cv_null_is_zero=yes
646 if test $tor_cv_null_is_zero = yes; then
647 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
648 [Define to 1 iff memset(0) sets pointers to NULL])
651 # And what happens when we malloc zero?
653 if test -z "$CROSS_COMPILE"; then
654 AC_CACHE_CHECK([whether we can malloc(0) safely.], tor_cv_malloc_zero_works,
655 [AC_RUN_IFELSE([AC_LANG_SOURCE(
656 [[#include <stdlib.h>
662 int main () { return malloc(0)?0:1; }]])],
663 [tor_cv_malloc_zero_works=yes],
664 [tor_cv_malloc_zero_works=no],
665 [tor_cv_malloc_zero_works=cross])])
668 # Cross-compiling; let's hope that the target isn't raving mad.
669 AC_MSG_NOTICE([Cross-compiling: we'll assume that we need to check malloc() arguments for 0.])
670 tor_cv_malloc_zero_works=no
673 if test $tor_cv_malloc_zero_works = yes; then
674 AC_DEFINE([MALLOC_ZERO_WORKS], 1,
675 [Define to 1 iff malloc(0) returns a pointer])
678 # whether we seem to be in a 2s-complement world.
679 if test -z "$CROSS_COMPILE"; then
680 AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
681 [AC_RUN_IFELSE([AC_LANG_SOURCE(
682 [[int main () { int problem = ((-99) != (~99)+1);
683 return problem ? 1 : 0; }]])],
684 [tor_cv_twos_complement=yes],
685 [tor_cv_twos_complement=no],
686 [tor_cv_twos_complement=cross])])
689 # Cross-compiling; let's hope that the target isn't raving mad.
690 AC_MSG_NOTICE([Cross-compiling: we'll assume that negative integers are represented with two's complement.])
691 tor_cv_twos_complement=yes
694 if test $tor_cv_twos_complement = yes; then
695 AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
696 [Define to 1 iff we represent negative integers with two's complement])
699 # Whether we should use the dmalloc memory allocation debugging library.
700 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
702 [ --with-dmalloc Use debug memory allocation library. ],
703 [if [[ "$withval" = "yes" ]]; then
709 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
712 if [[ $dmalloc -eq 1 ]]; then
713 AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
714 AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
715 AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
716 AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
719 # Allow user to specify an alternate syslog facility
720 AC_ARG_WITH(syslog-facility,
721 [ --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
722 syslog_facility="$withval", syslog_facility="LOG_DAEMON")
723 AC_DEFINE_UNQUOTED(LOGFACILITY,$syslog_facility,[name of the syslog facility])
724 AC_SUBST(LOGFACILITY)
726 # Check for gethostbyname_r in all its glorious incompatible versions.
727 # (This logic is based on that in Python's configure.in)
728 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
729 [Define this if you have any gethostbyname_r()])
731 AC_CHECK_FUNC(gethostbyname_r, [
732 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
734 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
739 struct hostent *h1, *h2;
741 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
743 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
744 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
745 [Define this if gethostbyname_r takes 6 arguments])
754 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
756 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
757 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
758 [Define this if gethostbyname_r takes 5 arguments])
766 struct hostent_data hd;
767 (void) gethostbyname_r(cp1,h1,&hd);
769 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
770 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
771 [Define this if gethostbyname_r takes 3 arguments])
781 AC_CACHE_CHECK([whether the C compiler supports __func__],
782 tor_cv_have_func_macro,
785 int main(int c, char **v) { puts(__func__); }],
786 tor_cv_have_func_macro=yes,
787 tor_cv_have_func_macro=no))
789 AC_CACHE_CHECK([whether the C compiler supports __FUNC__],
790 tor_cv_have_FUNC_macro,
793 int main(int c, char **v) { puts(__FUNC__); }],
794 tor_cv_have_FUNC_macro=yes,
795 tor_cv_have_FUNC_macro=no))
797 AC_CACHE_CHECK([whether the C compiler supports __FUNCTION__],
798 tor_cv_have_FUNCTION_macro,
801 int main(int c, char **v) { puts(__FUNCTION__); }],
802 tor_cv_have_FUNCTION_macro=yes,
803 tor_cv_have_FUNCTION_macro=no))
805 if test $tor_cv_have_func_macro = 'yes'; then
806 AC_DEFINE(HAVE_MACRO__func__, 1, [Defined if the compiler supports __func__])
809 if test $tor_cv_have_FUNC_macro = 'yes'; then
810 AC_DEFINE(HAVE_MACRO__FUNC__, 1, [Defined if the compiler supports __FUNC__])
813 if test $tor_cv_have_FUNCTION_macro = 'yes'; then
814 AC_DEFINE(HAVE_MACRO__FUNCTION__, 1,
815 [Defined if the compiler supports __FUNCTION__])
818 # $prefix stores the value of the --prefix command line option, or
819 # NONE if the option wasn't set. In the case that it wasn't set, make
820 # it be the default, so that we can use it to expand directories now.
821 if test "x$prefix" = "xNONE"; then
822 prefix=$ac_default_prefix
825 # and similarly for $exec_prefix
826 if test "x$exec_prefix" = "xNONE"; then
830 if test "x$CONFDIR" = "x"; then
831 CONFDIR=`eval echo $sysconfdir/tor`
834 AH_TEMPLATE([CONFDIR],[tor's configuration directory])
835 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
837 BINDIR=`eval echo $bindir`
840 LOCALSTATEDIR=`eval echo $localstatedir`
841 AC_SUBST(LOCALSTATEDIR)
842 AH_TEMPLATE([LOCALSTATEDIR], [Default location to store state files.])
843 AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
845 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
846 # than autoconf's macros like.
847 if test $ac_cv_c_compiler_gnu = yes; then
848 CFLAGS="$CFLAGS -Wall -g -O2"
850 CFLAGS="$CFLAGS -g -O"
851 enable_gcc_warnings=no
854 # Add some more warnings which we use in the cvs version but not in the
855 # released versions. (Some relevant gcc versions can't handle these.)
856 if test x$enable_gcc_warnings = xyes; then
859 #if !defined(__GNUC__) || (__GNUC__ < 4)
861 #endif], have_gcc4=yes, have_gcc4=no)
863 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"
865 if test x$have_gcc4 = xyes ; then
866 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
867 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
870 ##This will break the world on some 64-bit architectures
871 # CFLAGS="$CFLAGS -Winline"
875 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 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)
877 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
878 ./contrib/updateVersions.pl