configure.in 7.0 KB

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