configure.in 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. AC_INIT
  2. AM_INIT_AUTOMAKE(tor, 0.0.2pre12)
  3. AM_CONFIG_HEADER(orconfig.h)
  4. CFLAGS="-Wall -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. saved_LIBS="$LIBS"
  24. saved_LDFLAGS="$LDFLAGS"
  25. saved_CPPFLAGS="$CPPFLAGS"
  26. if test "x$prefix" != "xNONE" ; then
  27. tryssldir="$tryssldir $prefix"
  28. fi
  29. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  30. for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
  31. CPPFLAGS="$saved_CPPFLAGS"
  32. LDFLAGS="$saved_LDFLAGS"
  33. LIBS="$saved_LIBS -lcrypto -lssl"
  34. # Skip directories if they don't exist
  35. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  36. continue;
  37. fi
  38. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  39. # Try to use $ssldir/lib if it exists, otherwise
  40. # $ssldir
  41. if test -d "$ssldir/lib" ; then
  42. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  43. if test ! -z "$need_dash_r" ; then
  44. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  45. fi
  46. else
  47. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  48. if test ! -z "$need_dash_r" ; then
  49. LDFLAGS="-R$ssldir $LDFLAGS"
  50. fi
  51. fi
  52. # Try to use $ssldir/include if it exists, otherwise
  53. # $ssldir
  54. if test -d "$ssldir/include" ; then
  55. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  56. else
  57. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  58. fi
  59. fi
  60. # Basic test to check for compatible version and correct linking
  61. # *does not* test for RSA - that comes later.
  62. AC_TRY_RUN(
  63. [
  64. #include <string.h>
  65. #include <openssl/rand.h>
  66. int main(void)
  67. {
  68. char a[2048];
  69. memset(a, 0, sizeof(a));
  70. RAND_add(a, sizeof(a), sizeof(a));
  71. return(RAND_status() <= 0);
  72. }
  73. ],
  74. [
  75. found_crypto=1
  76. break;
  77. ], []
  78. )
  79. if test ! -z "$found_crypto" ; then
  80. break;
  81. fi
  82. done
  83. if test -z "$found_crypto" ; then
  84. AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
  85. fi
  86. if test -z "$ssldir" ; then
  87. ssldir="(system)"
  88. fi
  89. ac_cv_openssldir=$ssldir
  90. ])
  91. if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
  92. then
  93. dnl Need to recover ssldir - test above runs in subshell
  94. ssldir=$ac_cv_openssldir
  95. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  96. # Try to use $ssldir/lib if it exists, otherwise
  97. # $ssldir
  98. if test -d "$ssldir/lib" ; then
  99. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  100. if test ! -z "$need_dash_r" ; then
  101. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  102. fi
  103. else
  104. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  105. if test ! -z "$need_dash_r" ; then
  106. LDFLAGS="-R$ssldir $LDFLAGS"
  107. fi
  108. fi
  109. # Try to use $ssldir/include if it exists, otherwise
  110. # $ssldir
  111. if test -d "$ssldir/include" ; then
  112. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  113. else
  114. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  115. fi
  116. fi
  117. fi
  118. LIBS="$saved_LIBS -lcrypto -lssl"
  119. dnl The warning message here is no longer strictly accurate.
  120. AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.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 time.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
  121. dnl These headers are not essential
  122. AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h netinet/in.h arpa/inet.h)
  123. AC_CHECK_FUNCS(gettimeofday ftime socketpair uname)
  124. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  125. dnl Watch out.
  126. AC_CHECK_SIZEOF(int8_t)
  127. AC_CHECK_SIZEOF(int16_t)
  128. AC_CHECK_SIZEOF(int32_t)
  129. AC_CHECK_SIZEOF(int64_t)
  130. AC_CHECK_SIZEOF(uint8_t)
  131. AC_CHECK_SIZEOF(uint16_t)
  132. AC_CHECK_SIZEOF(uint32_t)
  133. AC_CHECK_SIZEOF(uint64_t)
  134. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t])
  135. AC_CHECK_SIZEOF(char)
  136. AC_CHECK_SIZEOF(short)
  137. AC_CHECK_SIZEOF(int)
  138. AC_CHECK_SIZEOF(long)
  139. AC_CHECK_SIZEOF(long long)
  140. AC_CHECK_SIZEOF(__int64)
  141. AC_OUTPUT(Makefile src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)