configure.in 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. AC_INIT
  2. AM_INIT_AUTOMAKE(tor, 0.0.8pre3-cvs)
  3. AM_CONFIG_HEADER(orconfig.h)
  4. AC_CANONICAL_HOST
  5. CFLAGS="$CFLAGS -Wall -g -O2"
  6. if test -f /etc/redhat-release; then
  7. CFLAGS="$CFLAGS -I/usr/kerberos/include"
  8. fi
  9. AC_ARG_ENABLE(debug,
  10. [ --enable-debug compiles with debugging info],
  11. [if test x$enableval = xyes; then
  12. CFLAGS="$CFLAGS -g"
  13. fi])
  14. AC_PROG_CC
  15. AC_PROG_MAKE_SET
  16. AC_PROG_RANLIB
  17. # The big search for OpenSSL
  18. # copied from openssh's configure.ac
  19. AC_ARG_WITH(ssl-dir,
  20. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  21. [
  22. if test "x$withval" != "xno" ; then
  23. tryssldir=$withval
  24. fi
  25. ]
  26. )
  27. AC_SEARCH_LIBS(socket, [socket])
  28. AC_SEARCH_LIBS(gethostbyname, [nsl])
  29. saved_LIBS="$LIBS"
  30. saved_LDFLAGS="$LDFLAGS"
  31. saved_CPPFLAGS="$CPPFLAGS"
  32. if test "x$prefix" != "xNONE" ; then
  33. tryssldir="$tryssldir $prefix"
  34. fi
  35. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  36. for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
  37. CPPFLAGS="$saved_CPPFLAGS"
  38. LDFLAGS="$saved_LDFLAGS"
  39. LIBS="$saved_LIBS -lssl -lcrypto"
  40. # Skip directories if they don't exist
  41. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  42. continue;
  43. fi
  44. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  45. # Try to use $ssldir/lib if it exists, otherwise
  46. # $ssldir
  47. if test -d "$ssldir/lib" ; then
  48. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  49. if test ! -z "$need_dash_r" ; then
  50. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  51. fi
  52. else
  53. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  54. if test ! -z "$need_dash_r" ; then
  55. LDFLAGS="-R$ssldir $LDFLAGS"
  56. fi
  57. fi
  58. # Try to use $ssldir/include if it exists, otherwise
  59. # $ssldir
  60. if test -d "$ssldir/include" ; then
  61. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  62. else
  63. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  64. fi
  65. fi
  66. # Basic test to check for compatible version and correct linking
  67. # *does not* test for RSA - that comes later.
  68. AC_TRY_RUN(
  69. [
  70. #include <string.h>
  71. #include <openssl/rand.h>
  72. int main(void)
  73. {
  74. char a[2048];
  75. memset(a, 0, sizeof(a));
  76. RAND_add(a, sizeof(a), sizeof(a));
  77. return(RAND_status() <= 0);
  78. }
  79. ],
  80. [
  81. found_crypto=1
  82. break;
  83. ], []
  84. )
  85. if test ! -z "$found_crypto" ; then
  86. break;
  87. fi
  88. done
  89. if test -z "$found_crypto" ; then
  90. AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
  91. fi
  92. if test -z "$ssldir" ; then
  93. ssldir="(system)"
  94. fi
  95. ac_cv_openssldir=$ssldir
  96. ])
  97. if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
  98. then
  99. dnl Need to recover ssldir - test above runs in subshell
  100. ssldir=$ac_cv_openssldir
  101. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  102. # Try to use $ssldir/lib if it exists, otherwise
  103. # $ssldir
  104. if test -d "$ssldir/lib" ; then
  105. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  106. if test ! -z "$need_dash_r" ; then
  107. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  108. fi
  109. else
  110. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  111. if test ! -z "$need_dash_r" ; then
  112. LDFLAGS="-R$ssldir $LDFLAGS"
  113. fi
  114. fi
  115. # Try to use $ssldir/include if it exists, otherwise
  116. # $ssldir
  117. if test -d "$ssldir/include" ; then
  118. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  119. else
  120. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  121. fi
  122. fi
  123. fi
  124. LIBS="$saved_LIBS -lssl -lcrypto"
  125. dnl The warning message here is no longer strictly accurate.
  126. AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.h sys/poll.h sys/types.h fcntl.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h time.h pwd.h grp.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
  127. dnl These headers are not essential
  128. AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h)
  129. AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime)
  130. AC_REPLACE_FUNCS(strlcat strlcpy)
  131. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  132. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  133. dnl Watch out.
  134. AC_CHECK_SIZEOF(int8_t)
  135. AC_CHECK_SIZEOF(int16_t)
  136. AC_CHECK_SIZEOF(int32_t)
  137. AC_CHECK_SIZEOF(int64_t)
  138. AC_CHECK_SIZEOF(uint8_t)
  139. AC_CHECK_SIZEOF(uint16_t)
  140. AC_CHECK_SIZEOF(uint32_t)
  141. AC_CHECK_SIZEOF(uint64_t)
  142. AC_CHECK_SIZEOF(intptr_t)
  143. AC_CHECK_SIZEOF(uintptr_t)
  144. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  145. AC_CHECK_SIZEOF(char)
  146. AC_CHECK_SIZEOF(short)
  147. AC_CHECK_SIZEOF(int)
  148. AC_CHECK_SIZEOF(long)
  149. AC_CHECK_SIZEOF(long long)
  150. AC_CHECK_SIZEOF(__int64)
  151. AC_CHECK_SIZEOF(void *)
  152. # Now, let's see about alignment requirements. On some platforms, we override
  153. # the default.
  154. case $host in
  155. ia64-*-* | arm-*-* )
  156. tor_cv_unaligned_ok=no
  157. ;;
  158. *)
  159. AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
  160. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  161. [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
  162. return *(int*)(&s[1]); }]])],
  163. [tor_cv_unaligned_ok=yes],
  164. [tor_cv_unaligned_ok=no],
  165. [tor_cv_unaligned_ok=cross])])
  166. esac
  167. if test $tor_cv_unaligned_ok = yes; then
  168. AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
  169. [Define to 1 iff unaligned int access is allowed])
  170. fi
  171. # $prefix stores the value of the --prefix command line option, or
  172. # NONE if the option wasn't set. In the case that it wasn't set, make
  173. # it be the default, so that we can use it to expand directories now.
  174. if test "x$prefix" = "xNONE"; then
  175. prefix=$ac_default_prefix
  176. fi
  177. # and similarly for $exec_prefix
  178. if test "x$exec_prefix" = "xNONE"; then
  179. exec_prefix=$prefix
  180. fi
  181. CONFDIR=`eval echo $sysconfdir/tor`
  182. AC_SUBST(CONFDIR)
  183. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  184. AC_DEFINE([CONFDIR], [], [tor's configuration directory])
  185. BINDIR=`eval echo $bindir`
  186. AC_SUBST(BINDIR)
  187. LOCALSTATEDIR=`eval echo $localstatedir`
  188. AC_SUBST(LOCALSTATEDIR)
  189. echo "confdir: $CONFDIR"
  190. AC_OUTPUT(Makefile contrib/tor.sh contrib/torify contrib/Makefile src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile doc/design-paper/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)