diff options
Diffstat (limited to 'gl/m4/af_alg.m4')
-rw-r--r-- | gl/m4/af_alg.m4 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4 new file mode 100644 index 00000000..601cf674 --- /dev/null +++ b/gl/m4/af_alg.m4 | |||
@@ -0,0 +1,57 @@ | |||
1 | # af_alg.m4 serial 6 | ||
2 | dnl Copyright 2018-2021 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl From Matteo Croce. | ||
8 | |||
9 | AC_DEFUN_ONCE([gl_AF_ALG], | ||
10 | [ | ||
11 | AC_REQUIRE([gl_SYS_SOCKET_H]) | ||
12 | AC_REQUIRE([AC_C_INLINE]) | ||
13 | |||
14 | dnl Check whether linux/if_alg.h has needed features. | ||
15 | AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.], | ||
16 | [gl_cv_header_linux_if_alg_salg], | ||
17 | [AC_COMPILE_IFELSE( | ||
18 | [AC_LANG_PROGRAM([[#include <sys/socket.h> | ||
19 | #include <linux/if_alg.h> | ||
20 | struct sockaddr_alg salg = { | ||
21 | .salg_family = AF_ALG, | ||
22 | .salg_type = "hash", | ||
23 | .salg_name = "sha1", | ||
24 | };]])], | ||
25 | [gl_cv_header_linux_if_alg_salg=yes], | ||
26 | [gl_cv_header_linux_if_alg_salg=no])]) | ||
27 | if test "$gl_cv_header_linux_if_alg_salg" = yes; then | ||
28 | AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1], | ||
29 | [Define to 1 if you have 'struct sockaddr_alg' defined.]) | ||
30 | fi | ||
31 | |||
32 | dnl The default is to not use AF_ALG if available, | ||
33 | dnl as it's system dependent as to whether the kernel | ||
34 | dnl routines are faster than libcrypto for example. | ||
35 | use_af_alg=no | ||
36 | AC_ARG_WITH([linux-crypto], | ||
37 | [AS_HELP_STRING([[--with-linux-crypto]], | ||
38 | [use Linux kernel cryptographic API (if available) for the hash functions | ||
39 | MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])], | ||
40 | [use_af_alg=$withval], | ||
41 | [use_af_alg=no]) | ||
42 | dnl We cannot use it if it is not available. | ||
43 | if test "$gl_cv_header_linux_if_alg_salg" != yes; then | ||
44 | if test "$use_af_alg" != no; then | ||
45 | AC_MSG_WARN([Linux kernel cryptographic API not found]) | ||
46 | fi | ||
47 | use_af_alg=no | ||
48 | fi | ||
49 | |||
50 | if test "$use_af_alg" != no; then | ||
51 | USE_AF_ALG=1 | ||
52 | else | ||
53 | USE_AF_ALG=0 | ||
54 | fi | ||
55 | AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG], | ||
56 | [Define to 1 if you want to use the Linux kernel cryptographic API.]) | ||
57 | ]) | ||