build-sys: Implement AX_CHECK_DEFINE and use for OpenSSL #define's

Some of the functions that OpenSSL uses are #define's for which
we need to check using a new AX_CHECK_DEFINE. We need to check for
them also because they were added at different points in time.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2019-06-20 11:56:06 -04:00 committed by Stefan Berger
parent 6ae0d8c52c
commit 763d7a89de
2 changed files with 35 additions and 0 deletions

View File

@ -206,6 +206,10 @@ AS_IF([test "x$enable_use_openssl_functions" != "xno"], [
AC_CHECK_LIB([crypto], [EVP_PKEY_verify_init],, not_found=1)
AC_CHECK_LIB([crypto], [EVP_PKEY_verify],, not_found=1)
AC_CHECK_LIB([crypto], [EVP_get_digestbyname],, not_found=1)
AX_CHECK_DEFINE([<openssl/rsa.h>], [EVP_PKEY_CTX_set0_rsa_oaep_label],, not_found=1)
AX_CHECK_DEFINE([<openssl/rsa.h>], [EVP_PKEY_CTX_set_rsa_padding],, not_found=1)
AX_CHECK_DEFINE([<openssl/rsa.h>], [EVP_PKEY_CTX_set_rsa_oaep_md],, not_found=1)
AX_CHECK_DEFINE([<openssl/evp.h>], [EVP_PKEY_CTX_set_signature_md],, not_found=1)
if test "x$not_found" = "x0"; then
use_openssl_functions_rsa=1
use_openssl_functions_for="${use_openssl_functions_for}RSA "

31
m4/ax_check_define.m4 Normal file
View File

@ -0,0 +1,31 @@
# SYNOPSIS
#
# AX_CHECK_DEFINE(includefile, define, [ACTION-SUCCESS], [ACTION-FAILURE])
#
# DESCRIPTION
#
# Check whether the given #define is available in the given #include file
#
# LICENSE
#
# See the root directory of the libtpms project for the LICENSE
#
AC_DEFUN([AX_CHECK_DEFINE],
[AC_PREREQ(2.64)
AC_MSG_CHECKING(whether $2 is defined in $1)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include $1]],
[[#ifndef $2
#error $2 not defined
#endif]])],
[
AC_MSG_RESULT([yes])
[$3]
],
[
AC_MSG_RESULT([no])
[$4]
]
)
]
)