configure.in 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. AC_INIT
  2. AM_INIT_AUTOMAKE(tor, 0.0.2pre6)
  3. AM_CONFIG_HEADER(orconfig.h)
  4. CFLAGS="-Wall -O2"
  5. AC_ARG_ENABLE(debug,
  6. [ --enable-debug compiles with debugging info],
  7. [if test x$enableval = xyes; then
  8. CFLAGS="-Wall -g -O2"
  9. fi])
  10. AC_PROG_CC
  11. AC_PROG_MAKE_SET
  12. AC_PROG_RANLIB
  13. dnl AC_DEFINE([HAVE_OPENSSL], 0, [Define if OpenSSL was found.])
  14. # The big search for OpenSSL
  15. # copied from openssh's configure.ac
  16. AC_ARG_WITH(ssl-dir,
  17. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  18. [
  19. if test "x$withval" != "xno" ; then
  20. tryssldir=$withval
  21. fi
  22. ]
  23. )
  24. saved_LIBS="$LIBS"
  25. saved_LDFLAGS="$LDFLAGS"
  26. saved_CPPFLAGS="$CPPFLAGS"
  27. if test "x$prefix" != "xNONE" ; then
  28. tryssldir="$tryssldir $prefix"
  29. fi
  30. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  31. for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
  32. CPPFLAGS="$saved_CPPFLAGS"
  33. LDFLAGS="$saved_LDFLAGS"
  34. LIBS="$saved_LIBS -lcrypto"
  35. # Skip directories if they don't exist
  36. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  37. continue;
  38. fi
  39. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  40. # Try to use $ssldir/lib if it exists, otherwise
  41. # $ssldir
  42. if test -d "$ssldir/lib" ; then
  43. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  44. if test ! -z "$need_dash_r" ; then
  45. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  46. fi
  47. else
  48. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  49. if test ! -z "$need_dash_r" ; then
  50. LDFLAGS="-R$ssldir $LDFLAGS"
  51. fi
  52. fi
  53. # Try to use $ssldir/include if it exists, otherwise
  54. # $ssldir
  55. if test -d "$ssldir/include" ; then
  56. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  57. else
  58. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  59. fi
  60. fi
  61. # Basic test to check for compatible version and correct linking
  62. # *does not* test for RSA - that comes later.
  63. AC_TRY_RUN(
  64. [
  65. #include <string.h>
  66. #include <openssl/rand.h>
  67. int main(void)
  68. {
  69. char a[2048];
  70. memset(a, 0, sizeof(a));
  71. RAND_add(a, sizeof(a), sizeof(a));
  72. return(RAND_status() <= 0);
  73. }
  74. ],
  75. [
  76. found_crypto=1
  77. break;
  78. ], []
  79. )
  80. if test ! -z "$found_crypto" ; then
  81. break;
  82. fi
  83. done
  84. if test -z "$found_crypto" ; then
  85. AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
  86. fi
  87. if test -z "$ssldir" ; then
  88. ssldir="(system)"
  89. fi
  90. ac_cv_openssldir=$ssldir
  91. ])
  92. if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
  93. then
  94. AC_DEFINE(HAVE_OPENSSL)
  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 -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/poll.h sys/types.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h stdint.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
  123. AC_OUTPUT(Makefile src/Makefile src/common/Makefile src/orkeygen/Makefile src/or/Makefile)