configure.in 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. AC_INIT
  2. AM_INIT_AUTOMAKE(or, 0.0.0)
  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 -ggdb -O2"
  9. fi])
  10. AC_PROG_CC
  11. AC_PROG_MAKE_SET
  12. AC_PROG_RANLIB
  13. AC_DEFINE([HAVE_OPENSSL], 0, [Define if OpenSSL was found.])
  14. AC_DEFINE([HAVE_POPT], 0, [Define if popt was found.])
  15. AC_CHECK_LIB(popt,poptParseArgvString,
  16. AC_DEFINE(HAVE_POPT),
  17. AC_MSG_ERROR(required library not found: popt)
  18. )
  19. LIBS="$LIBS -lpopt"
  20. # The big search for OpenSSL
  21. # copied from openssh's configure.ac
  22. AC_ARG_WITH(ssl-dir,
  23. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  24. [
  25. if test "x$withval" != "xno" ; then
  26. tryssldir=$withval
  27. fi
  28. ]
  29. )
  30. saved_LIBS="$LIBS"
  31. saved_LDFLAGS="$LDFLAGS"
  32. saved_CPPFLAGS="$CPPFLAGS"
  33. if test "x$prefix" != "xNONE" ; then
  34. tryssldir="$tryssldir $prefix"
  35. fi
  36. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  37. for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
  38. CPPFLAGS="$saved_CPPFLAGS"
  39. LDFLAGS="$saved_LDFLAGS"
  40. LIBS="$saved_LIBS -lcrypto"
  41. # Skip directories if they don't exist
  42. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  43. continue;
  44. fi
  45. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  46. # Try to use $ssldir/lib if it exists, otherwise
  47. # $ssldir
  48. if test -d "$ssldir/lib" ; then
  49. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  50. if test ! -z "$need_dash_r" ; then
  51. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  52. fi
  53. else
  54. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  55. if test ! -z "$need_dash_r" ; then
  56. LDFLAGS="-R$ssldir $LDFLAGS"
  57. fi
  58. fi
  59. # Try to use $ssldir/include if it exists, otherwise
  60. # $ssldir
  61. if test -d "$ssldir/include" ; then
  62. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  63. else
  64. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  65. fi
  66. fi
  67. # Basic test to check for compatible version and correct linking
  68. # *does not* test for RSA - that comes later.
  69. AC_TRY_RUN(
  70. [
  71. #include <string.h>
  72. #include <openssl/rand.h>
  73. int main(void)
  74. {
  75. char a[2048];
  76. memset(a, 0, sizeof(a));
  77. RAND_add(a, sizeof(a), sizeof(a));
  78. return(RAND_status() <= 0);
  79. }
  80. ],
  81. [
  82. found_crypto=1
  83. break;
  84. ], []
  85. )
  86. if test ! -z "$found_crypto" ; then
  87. break;
  88. fi
  89. done
  90. if test -z "$found_crypto" ; then
  91. AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
  92. fi
  93. if test -z "$ssldir" ; then
  94. ssldir="(system)"
  95. fi
  96. ac_cv_openssldir=$ssldir
  97. ])
  98. if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
  99. then
  100. AC_DEFINE(HAVE_OPENSSL)
  101. dnl Need to recover ssldir - test above runs in subshell
  102. ssldir=$ac_cv_openssldir
  103. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  104. # Try to use $ssldir/lib if it exists, otherwise
  105. # $ssldir
  106. if test -d "$ssldir/lib" ; then
  107. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  108. if test ! -z "$need_dash_r" ; then
  109. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  110. fi
  111. else
  112. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  113. if test ! -z "$need_dash_r" ; then
  114. LDFLAGS="-R$ssldir $LDFLAGS"
  115. fi
  116. fi
  117. # Try to use $ssldir/include if it exists, otherwise
  118. # $ssldir
  119. if test -d "$ssldir/include" ; then
  120. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  121. else
  122. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  123. fi
  124. fi
  125. fi
  126. LIBS="$saved_LIBS -lcrypto"
  127. AC_OUTPUT(Makefile src/Makefile src/common/Makefile src/smtpap/Makefile src/orkeygen/Makefile src/httpap/Makefile src/op/Makefile src/or/Makefile)