Blame m4/af_alg.m4

Packit 8f70b4
# af_alg.m4 serial 4
Packit 8f70b4
dnl Copyright 2018 Free Software Foundation, Inc.
Packit 8f70b4
dnl This file is free software; the Free Software Foundation
Packit 8f70b4
dnl gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
dnl with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
dnl From Matteo Croce.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN_ONCE([gl_AF_ALG],
Packit 8f70b4
[
Packit 8f70b4
  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
Packit 8f70b4
  AC_REQUIRE([AC_C_INLINE])
Packit 8f70b4
Packit 8f70b4
  dnl Check whether linux/if_alg.h has needed features.
Packit 8f70b4
  AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
Packit 8f70b4
    [gl_cv_header_linux_if_alg_salg],
Packit 8f70b4
    [AC_COMPILE_IFELSE(
Packit 8f70b4
       [AC_LANG_PROGRAM([[#include <sys/socket.h>
Packit 8f70b4
                          #include <linux/if_alg.h>
Packit 8f70b4
                          struct sockaddr_alg salg = {
Packit 8f70b4
                            .salg_family = AF_ALG,
Packit 8f70b4
                            .salg_type = "hash",
Packit 8f70b4
                            .salg_name = "sha1",
Packit 8f70b4
                          };]])],
Packit 8f70b4
       [gl_cv_header_linux_if_alg_salg=yes],
Packit 8f70b4
       [gl_cv_header_linux_if_alg_salg=no])])
Packit 8f70b4
  if test "$gl_cv_header_linux_if_alg_salg" = yes; then
Packit 8f70b4
    AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
Packit 8f70b4
      [Define to 1 if you have 'struct sockaddr_alg' defined.])
Packit 8f70b4
  fi
Packit 8f70b4
Packit 8f70b4
  dnl The default is to not use AF_ALG if available,
Packit 8f70b4
  dnl as it's system dependent as to whether the kernel
Packit 8f70b4
  dnl routines are faster than libcrypto for example.
Packit 8f70b4
  use_af_alg=no
Packit 8f70b4
  AC_ARG_WITH([linux-crypto],
Packit 8f70b4
    [AS_HELP_STRING([[--with-linux-crypto]],
Packit 8f70b4
       [use Linux kernel cryptographic API (if available)])],
Packit 8f70b4
    [use_af_alg=$withval],
Packit 8f70b4
    [use_af_alg=no])
Packit 8f70b4
  dnl We cannot use it if it is not available.
Packit 8f70b4
  if test "$gl_cv_header_linux_if_alg_salg" != yes; then
Packit 8f70b4
    if test "$use_af_alg" != no; then
Packit 8f70b4
      AC_MSG_WARN([Linux kernel cryptographic API not found])
Packit 8f70b4
    fi
Packit 8f70b4
    use_af_alg=no
Packit 8f70b4
  fi
Packit 8f70b4
Packit 8f70b4
  if test "$use_af_alg" != no; then
Packit 8f70b4
    USE_AF_ALG=1
Packit 8f70b4
  else
Packit 8f70b4
    USE_AF_ALG=0
Packit 8f70b4
  fi
Packit 8f70b4
  AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
Packit 8f70b4
    [Define to 1 if you want to use the Linux kernel cryptographic API.])
Packit 8f70b4
])