x_ac_slurm_ssl.m4 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Mark Grondona <mgrondona@llnl.gov>
  4. # (Mostly taken from OpenSSH configure.ac)
  5. #
  6. # SYNOPSIS:
  7. # X_AC_SLURM_WITH_SSL
  8. #
  9. # DESCRIPTION:
  10. # Process --with-ssl configure flag and search for OpenSSL support.
  11. #
  12. ##*****************************************************************************
  13. AC_DEFUN([X_AC_SLURM_WITH_SSL], [
  14. ssl_default_dirs="/usr/local/openssl64 /usr/local/openssl /usr/lib/openssl \
  15. /usr/local/ssl /usr/lib/ssl /usr/local \
  16. /usr/pkg /opt /opt/openssl /usr"
  17. AC_SUBST(SSL_LDFLAGS)
  18. AC_SUBST(SSL_LIBS)
  19. AC_SUBST(SSL_CPPFLAGS)
  20. SSL_LIB_TEST="-lcrypto"
  21. AC_ARG_WITH(ssl,
  22. AS_HELP_STRING(--with-ssl=PATH,Specify path to OpenSSL installation),
  23. [
  24. tryssldir=$withval
  25. # Hack around a libtool bug on AIX.
  26. # libcrypto is in a non-standard library path on AIX (/opt/freeware
  27. # which is specified with --with-ssl), and libtool is not setting
  28. # the correct runtime library path in the binaries.
  29. if test "x$ac_have_aix" = "xyes"; then
  30. SSL_LIB_TEST="-lcrypto-static"
  31. elif test "x$ac_have_nrt" = "xyes"; then
  32. # it appears on p7 machines the openssl doesn't
  33. # link correctly so we need to add -ldl
  34. SSL_LIB_TEST="$SSL_LIB_TEST -ldl"
  35. fi
  36. ])
  37. saved_LIBS="$LIBS"
  38. saved_LDFLAGS="$LDFLAGS"
  39. saved_CPPFLAGS="$CPPFLAGS"
  40. if test "x$prefix" != "xNONE" ; then
  41. tryssldir="$tryssldir $prefix"
  42. fi
  43. if test "x$tryssldir" != "xno" ; then
  44. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  45. for ssldir in $tryssldir "" $ssl_default_dirs; do
  46. CPPFLAGS="$saved_CPPFLAGS"
  47. LDFLAGS="$saved_LDFLAGS"
  48. LIBS="$saved_LIBS $SSL_LIB_TEST"
  49. # Skip directories if they don't exist
  50. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  51. continue;
  52. fi
  53. sslincludedir="$ssldir"
  54. if test ! -z "$ssldir"; then
  55. # Try to use $ssldir/lib if it exists, otherwise
  56. # $ssldir
  57. if test -d "$ssldir/lib" ; then
  58. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  59. if test ! -z "$need_dash_r" ; then
  60. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  61. fi
  62. else
  63. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  64. if test ! -z "$need_dash_r" ; then
  65. LDFLAGS="-R$ssldir $LDFLAGS"
  66. fi
  67. fi
  68. # Try to use $ssldir/include if it exists, otherwise
  69. # $ssldir
  70. if test -d "$ssldir/include" ; then
  71. sslincludedir="$ssldir/include"
  72. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  73. else
  74. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  75. fi
  76. fi
  77. test -f "$sslincludedir/openssl/rand.h" || continue
  78. test -f "$sslincludedir/openssl/hmac.h" || continue
  79. test -f "$sslincludedir/openssl/sha.h" || continue
  80. # Basic test to check for compatible version and correct linking
  81. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  82. #include <stdlib.h>
  83. #include <openssl/rand.h>
  84. #include <openssl/hmac.h>
  85. #include <openssl/sha.h>
  86. #define SIZE 8
  87. int main(void)
  88. {
  89. int a[SIZE], i;
  90. for (i=0; i<SIZE; i++)
  91. a[i] = rand();
  92. RAND_add(a, sizeof(a), sizeof(a));
  93. return(RAND_status() <= 0);
  94. }
  95. ]])],[
  96. ac_have_openssl="yes"
  97. break;
  98. ],[
  99. ],[])
  100. if test ! -z "$ac_have_openssl" ; then
  101. break;
  102. fi
  103. done
  104. if test ! -z "$ac_have_openssl" ; then
  105. ac_cv_openssldir=$ssldir
  106. fi
  107. ])
  108. fi
  109. if test ! -z "$ac_have_openssl" ; then
  110. SSL_LIBS="$SSL_LIB_TEST"
  111. AC_DEFINE(HAVE_OPENSSL, 1, [define if you have openssl.])
  112. if (test ! -z "$ac_cv_openssldir") ; then
  113. dnl Need to recover ssldir - test above runs in subshell
  114. ssldir=$ac_cv_openssldir
  115. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  116. # Try to use $ssldir/lib if it exists, otherwise
  117. # $ssldir
  118. if test -d "$ssldir/lib" ; then
  119. SSL_LDFLAGS="-L$ssldir/lib"
  120. else
  121. SSL_LDFLAGS="-L$ssldir"
  122. fi
  123. # Try to use $ssldir/include if it exists, otherwise
  124. # $ssldir
  125. if test -d "$ssldir/include" ; then
  126. SSL_CPPFLAGS="-I$ssldir/include"
  127. else
  128. SSL_CPPFLAGS="-I$ssldir"
  129. fi
  130. fi
  131. fi
  132. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/evp.h>]], [[EVP_MD_CTX_cleanup(NULL);]])],[AC_DEFINE(HAVE_EVP_MD_CTX_CLEANUP, 1,
  133. [Define to 1 if function EVP_MD_CTX_cleanup exists.])],[])
  134. else
  135. SSL_LIBS=""
  136. AC_MSG_WARN([could not find working OpenSSL library])
  137. fi
  138. LIBS="$saved_LIBS"
  139. CPPFLAGS="$saved_CPPFLAGS"
  140. LDFLAGS="$saved_LDFLAGS"
  141. ])dnl AC_SLURM_WITH_SSL