Blame m4/gl-openssl.m4

Packit Service a2489d
# gl-openssl.m4 serial 3
Packit Service a2489d
dnl Copyright (C) 2013-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
Packit Service a2489d
[
Packit Service a2489d
  m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1])
Packit Service a2489d
])
Packit Service a2489d
gl_SET_CRYPTO_CHECK_DEFAULT([no])
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_CRYPTO_CHECK],
Packit Service a2489d
[
Packit Service a2489d
  dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT()
Packit Service a2489d
  m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT'])
Packit Service a2489d
Packit Service a2489d
  dnl Only clear once, so crypto routines can be checked for individually
Packit Service a2489d
  m4_divert_once([DEFAULTS], [LIB_CRYPTO=])
Packit Service a2489d
Packit Service a2489d
  AC_ARG_WITH([openssl],
Packit Service a2489d
    [AS_HELP_STRING([--with-openssl],
Packit Service a2489d
      [use libcrypto hash routines. Valid ARGs are:
Packit Service a2489d
       'yes', 'no', 'auto' => use if available,
Packit Service a2489d
       'optional' => use if available and warn if not available;
Packit Service a2489d
       default is ']gl_CRYPTO_CHECK_DEFAULT['.
Packit Service a2489d
       Note also --with-linux-crypto, which will enable
Packit Service a2489d
       use of kernel crypto routines, which have precedence])],
Packit Service a2489d
    [],
Packit Service a2489d
    [with_openssl=$with_openssl_default])
Packit Service a2489d
Packit Service a2489d
  if test "x$1" = xMD5; then
Packit Service a2489d
    ALG_header=md5.h
Packit Service a2489d
  else
Packit Service a2489d
    ALG_header=sha.h
Packit Service a2489d
  fi
Packit Service a2489d
Packit Service a2489d
  AC_SUBST([LIB_CRYPTO])
Packit Service a2489d
  if test "x$with_openssl" != xno; then
Packit Service a2489d
    AC_CHECK_LIB([crypto], [$1],
Packit Service a2489d
      [AC_CHECK_HEADERS([openssl/$ALG_header],
Packit Service a2489d
         [LIB_CRYPTO=-lcrypto
Packit Service a2489d
          AC_DEFINE([HAVE_OPENSSL_$1], [1],
Packit Service a2489d
            [Define to 1 if libcrypto is used for $1.])])])
Packit Service a2489d
    if test "x$LIB_CRYPTO" = x; then
Packit Service a2489d
      if test "x$with_openssl" = xyes; then
Packit Service a2489d
        AC_MSG_ERROR([openssl development library not found for $1])
Packit Service a2489d
      elif test "x$with_openssl" = xoptional; then
Packit Service a2489d
        AC_MSG_WARN([openssl development library not found for $1])
Packit Service a2489d
      fi
Packit Service a2489d
    fi
Packit Service a2489d
  fi
Packit Service a2489d
])