1# gl-openssl.m4 serial 3 2dnl Copyright (C) 2013-2014 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT], 8[ 9 m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1]) 10]) 11gl_SET_CRYPTO_CHECK_DEFAULT([no]) 12 13AC_DEFUN([gl_CRYPTO_CHECK], 14[ 15 dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT() 16 m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT']) 17 18 dnl Only clear once, so crypto routines can be checked for individually 19 m4_divert_once([DEFAULTS], [LIB_CRYPTO=]) 20 21 AC_ARG_WITH([openssl], 22 [AS_HELP_STRING([--with-openssl], 23 [use libcrypto hash routines. Valid ARGs are: 24 'yes', 'no', 'auto' => use if available, 25 'optional' => use if available and warn if not available; 26 default is ']gl_CRYPTO_CHECK_DEFAULT['])], 27 [], 28 [with_openssl=$with_openssl_default]) 29 30 if test "x$1" = xMD5; then 31 ALG_header=md5.h 32 else 33 ALG_header=sha.h 34 fi 35 36 AC_SUBST([LIB_CRYPTO]) 37 if test "x$with_openssl" != xno; then 38 AC_CHECK_LIB([crypto], [$1], 39 [AC_CHECK_HEADERS([openssl/$ALG_header], 40 [LIB_CRYPTO=-lcrypto 41 AC_DEFINE([HAVE_OPENSSL_$1], [1], 42 [Define to 1 if libcrypto is used for $1.])])]) 43 if test "x$LIB_CRYPTO" = x; then 44 if test "x$with_openssl" = xyes; then 45 AC_MSG_ERROR([openssl development library not found for $1]) 46 elif test "x$with_openssl" = xoptional; then 47 AC_MSG_WARN([openssl development library not found for $1]) 48 fi 49 fi 50 fi 51]) 52