Blame m4/af_alg.m4

Packit Service a2489d
# af_alg.m4 serial 4
Packit Service a2489d
dnl Copyright 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
dnl From Matteo Croce.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN_ONCE([gl_AF_ALG],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
Packit Service a2489d
  AC_REQUIRE([AC_C_INLINE])
Packit Service a2489d
Packit Service a2489d
  dnl Check whether linux/if_alg.h has needed features.
Packit Service a2489d
  AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
Packit Service a2489d
    [gl_cv_header_linux_if_alg_salg],
Packit Service a2489d
    [AC_COMPILE_IFELSE(
Packit Service a2489d
       [AC_LANG_PROGRAM([[#include <sys/socket.h>
Packit Service a2489d
                          #include <linux/if_alg.h>
Packit Service a2489d
                          struct sockaddr_alg salg = {
Packit Service a2489d
                            .salg_family = AF_ALG,
Packit Service a2489d
                            .salg_type = "hash",
Packit Service a2489d
                            .salg_name = "sha1",
Packit Service a2489d
                          };]])],
Packit Service a2489d
       [gl_cv_header_linux_if_alg_salg=yes],
Packit Service a2489d
       [gl_cv_header_linux_if_alg_salg=no])])
Packit Service a2489d
  if test "$gl_cv_header_linux_if_alg_salg" = yes; then
Packit Service a2489d
    AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
Packit Service a2489d
      [Define to 1 if you have 'struct sockaddr_alg' defined.])
Packit Service a2489d
  fi
Packit Service a2489d
Packit Service a2489d
  dnl The default is to not use AF_ALG if available,
Packit Service a2489d
  dnl as it's system dependent as to whether the kernel
Packit Service a2489d
  dnl routines are faster than libcrypto for example.
Packit Service a2489d
  use_af_alg=no
Packit Service a2489d
  AC_ARG_WITH([linux-crypto],
Packit Service a2489d
    [AS_HELP_STRING([[--with-linux-crypto]],
Packit Service a2489d
       [use Linux kernel cryptographic API (if available)])],
Packit Service a2489d
    [use_af_alg=$withval],
Packit Service a2489d
    [use_af_alg=no])
Packit Service a2489d
  dnl We cannot use it if it is not available.
Packit Service a2489d
  if test "$gl_cv_header_linux_if_alg_salg" != yes; then
Packit Service a2489d
    if test "$use_af_alg" != no; then
Packit Service a2489d
      AC_MSG_WARN([Linux kernel cryptographic API not found])
Packit Service a2489d
    fi
Packit Service a2489d
    use_af_alg=no
Packit Service a2489d
  fi
Packit Service a2489d
Packit Service a2489d
  if test "$use_af_alg" != no; then
Packit Service a2489d
    USE_AF_ALG=1
Packit Service a2489d
  else
Packit Service a2489d
    USE_AF_ALG=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
Packit Service a2489d
    [Define to 1 if you want to use the Linux kernel cryptographic API.])
Packit Service a2489d
])