From 7d069378921bfa0d7c7198ea177aac0a2440016f Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Wed, 1 Jan 2020 17:36:20 +0000 Subject: [PATCH] md5, sha1, sha256, sha512: support --with-openssl=auto-gpl-compat * m4/gl-openssl.m4: Add a new "auto-gpl-compat" mode, which will auto enable use of openssl, only for >= version 3, which is newly licensed under the Apache Software License. This will be used from coreutils for example by adding gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat]) to configure.ac. Even though "auto-gpl-compat" is less aggressive than "auto", we leave the default at "no" so projects can opt in to the extra dependency. --- ChangeLog | 7 +++++++ m4/gl-openssl.m4 | 32 +++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8db5b3890b..c1fcf1bbfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-01-01 Pádraig Brady + + md5, sha1, sha256, sha512: support --with-openssl=auto-gpl-compat + * m4/gl-openssl.m4: Add a new "auto-gpl-compat" mode, + which will auto enable use of openssl, only for >= version 3, + which is newly licensed under the Apache Software License. + 2020-01-01 Bruno Haible mbrtowc: Include function name in macro names. diff --git a/m4/gl-openssl.m4 b/m4/gl-openssl.m4 index 019520247f..6abc025efc 100644 --- a/m4/gl-openssl.m4 +++ b/m4/gl-openssl.m4 @@ -1,4 +1,4 @@ -# gl-openssl.m4 serial 3 +# gl-openssl.m4 serial 4 dnl Copyright (C) 2013-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,7 +21,9 @@ AC_DEFUN([gl_CRYPTO_CHECK], AC_ARG_WITH([openssl], [AS_HELP_STRING([--with-openssl], [use libcrypto hash routines. Valid ARGs are: - 'yes', 'no', 'auto' => use if available, + 'yes', 'no', + 'auto' => use if any version available, + 'auto-gpl-compat' => use if gpl compatible version available, 'optional' => use if available and warn if not available; default is ']gl_CRYPTO_CHECK_DEFAULT['. Note also --with-linux-crypto, which will enable @@ -37,11 +39,27 @@ AC_DEFUN([gl_CRYPTO_CHECK], AC_SUBST([LIB_CRYPTO]) if test "x$with_openssl" != xno; then - AC_CHECK_LIB([crypto], [$1], - [AC_CHECK_HEADERS([openssl/$ALG_header], - [LIB_CRYPTO=-lcrypto - AC_DEFINE([HAVE_OPENSSL_$1], [1], - [Define to 1 if libcrypto is used for $1.])])]) + if test "x$with_openssl" = xauto-gpl-compat; then + AC_CACHE_CHECK([whether openssl is GPL compatible], + [gl_cv_openssl_gpl_compat], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + #if OPENSSL_VERSION_MAJOR < 3 + #error "openssl >= version 3 not found" + #endif + ]])], + [gl_cv_openssl_gpl_compat=yes], + [gl_cv_openssl_gpl_compat=no])]) + fi + if test "x$with_openssl" != xauto-gpl-compat || + test "x$gl_cv_openssl_gpl_compat" = xyes; then + AC_CHECK_LIB([crypto], [$1], + [AC_CHECK_HEADERS([openssl/$ALG_header], + [LIB_CRYPTO=-lcrypto + AC_DEFINE([HAVE_OPENSSL_$1], [1], + [Define to 1 if libcrypto is used for $1.])])]) + fi if test "x$LIB_CRYPTO" = x; then if test "x$with_openssl" = xyes; then AC_MSG_ERROR([openssl development library not found for $1]) -- 2.39.5