From f0fe04fef2f9dde46052eb766d3582c936db14dd Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 10 Nov 2014 09:24:35 +0000 Subject: [PATCH] enhanced configure.ac for better ssl detection --- qse/cmd/http/httpd.c | 12 ++++++++++-- qse/configure | 35 +++++++++++++++++++++++++++++++++-- qse/configure.ac | 12 ++++++++++-- qse/include/qse/config.h.in | 12 ++++++++++++ qse/lib/awk/std.h | 1 - qse/lib/http/httpd-std.c | 8 ++++++-- 6 files changed, 71 insertions(+), 9 deletions(-) diff --git a/qse/cmd/http/httpd.c b/qse/cmd/http/httpd.c index c2cc81cd..6b4e43f0 100644 --- a/qse/cmd/http/httpd.c +++ b/qse/cmd/http/httpd.c @@ -38,8 +38,12 @@ #if defined(HAVE_SSL) # include -# include -# include +# if defined(HAVE_OPENSSL_ERR_H) +# include +# endif +# if defined(HAVE_OPENSSL_ENGINE_H) +# include +# endif #endif #if defined(HAVE_SYS_PRCTL_H) @@ -2794,10 +2798,14 @@ int qse_main (int argc, qse_achar_t* argv[]) #if defined(HAVE_SSL) /* ERR_remove_state() should be called for each thread if the application is thread */ ERR_remove_state (0); + #if defined(HAVE_ENGINE_CLEANUP) ENGINE_cleanup (); + #endif ERR_free_strings (); EVP_cleanup (); + #if defined(HAVE_CRYPTO_CLEANUP_ALL_EX_DATA) CRYPTO_cleanup_all_ex_data (); + #endif #endif #if defined(_WIN32) diff --git a/qse/configure b/qse/configure index ba7ac523..fffa38c7 100755 --- a/qse/configure +++ b/qse/configure @@ -18117,8 +18117,22 @@ else enable_ssl_is=yes fi -if test "$enable_ssl_is" = "yes" +if test "x$enable_ssl_is" = "xyes" then + for ac_header in openssl/err.h openssl/engine.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + for ac_func in SSL_library_init do : ac_fn_c_check_func "$LINENO" "SSL_library_init" "ac_cv_func_SSL_library_init" @@ -18130,7 +18144,8 @@ _ACEOF fi done - if test "$ac_cv_func_SSL_library_init" = "yes" + + if test "x$ac_cv_func_SSL_library_init" = "xyes" then $as_echo "#define HAVE_SSL 1" >>confdefs.h @@ -18228,6 +18243,22 @@ fi fi fi + + OLDLIBS="$LIBS" + LIBS="$SSL_LIBS $LIBS" + for ac_func in ENGINE_cleanup CRYPTO_cleanup_all_ex_data +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + LIBS="$OLDLIBS" fi diff --git a/qse/configure.ac b/qse/configure.ac index 73aa9402..a2058a60 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -247,11 +247,14 @@ AC_SUBST(UNICOWS_LIBS) AC_ARG_ENABLE([ssl], [AS_HELP_STRING([--enable-ssl],[build the library in the ssl mode (default. yes)])], enable_ssl_is=$enableval,enable_ssl_is=yes) -if test "$enable_ssl_is" = "yes" +if test "x$enable_ssl_is" = "xyes" then + AC_CHECK_HEADERS([openssl/err.h openssl/engine.h]) + dnl check for an SSL library AC_CHECK_FUNCS([SSL_library_init]) - if test "$ac_cv_func_SSL_library_init" = "yes" + + if test "x$ac_cv_func_SSL_library_init" = "xyes" then AC_DEFINE(HAVE_SSL, 1, [ssl support]) else @@ -268,6 +271,11 @@ then AC_DEFINE(HAVE_SSL_LIBRARY_INIT, 1) ]) fi + + OLDLIBS="$LIBS" + LIBS="$SSL_LIBS $LIBS" + AC_CHECK_FUNCS([ENGINE_cleanup CRYPTO_cleanup_all_ex_data]) + LIBS="$OLDLIBS" fi AC_SUBST(SSL_LIBS) diff --git a/qse/include/qse/config.h.in b/qse/include/qse/config.h.in index b2ff9178..25da7e56 100644 --- a/qse/include/qse/config.h.in +++ b/qse/include/qse/config.h.in @@ -126,6 +126,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_CRT_EXTERNS_H +/* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */ +#undef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA + /* Define if c++ supports namespace std. */ #undef HAVE_CXX_NAMESPACE_STD @@ -164,6 +167,9 @@ /* Define if you have the _dyld_func_lookup function. */ #undef HAVE_DYLD +/* Define to 1 if you have the `ENGINE_cleanup' function. */ +#undef HAVE_ENGINE_CLEANUP + /* epoll support */ #undef HAVE_EPOLL @@ -371,6 +377,12 @@ /* Define to 1 if you have the `opendir' function. */ #undef HAVE_OPENDIR +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_ENGINE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_ERR_H + /* Define to 1 if you have the `posix_spawn' function. */ #undef HAVE_POSIX_SPAWN diff --git a/qse/lib/awk/std.h b/qse/lib/awk/std.h index ad07f3c5..902282ff 100644 --- a/qse/lib/awk/std.h +++ b/qse/lib/awk/std.h @@ -37,7 +37,6 @@ QSE_EXPORT void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* s QSE_EXPORT void qse_awk_stdmodclose (qse_awk_t* awk, void* handle); QSE_EXPORT void* qse_awk_stdmodsym (qse_awk_t* awk, void* handle, const qse_char_t* name); - #ifdef __cplusplus } #endif diff --git a/qse/lib/http/httpd-std.c b/qse/lib/http/httpd-std.c index e4ece165..22b8fdf4 100644 --- a/qse/lib/http/httpd-std.c +++ b/qse/lib/http/httpd-std.c @@ -124,8 +124,12 @@ #if defined(HAVE_SSL) # include -# include -# include +# if defined(HAVE_OPENSSL_ERR_H) +# include +# endif +# if defined(HAVE_OPENSSL_ENGINE_H) +# include +# endif #endif #if defined(__linux) && !defined(SO_REUSEPORT)