-AS_IF([test x"$tls_support" = x"yes"],[
- AC_CHECK_HEADER([openssl/ssl.h], , [AC_MSG_ERROR([openssl/ssl.h not found])])
- AC_CHECK_LIB([crypto], [BIO_write], ,
- [AC_MSG_ERROR([OpenSSL crypto library not found])])
- AC_CHECK_LIB([ssl], [SSL_library_init], ,
- [AC_MSG_ERROR([OpenSSL library not found])])])
-
-dnl ---------------------
-dnl CHECK TERMCAP LIBRARY
-dnl ---------------------
-
-dnl Add the termcap library, so that the following configure
-dnl tests will find it when it tries to link test programs.
-nmh_save_LIBS="$LIBS"
-LIBS="$TERMLIB $LIBS"
-
-dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer)
-dnl Some termcaps reportedly accept a zero buffer, but then dump core
-dnl in tgetstr().
-dnl Under Cygwin test program crashes but exit code is still 0. So,
-dnl we test for a file that porgram should create
-AH_TEMPLATE([TGETENT_ACCEPTS_NULL],
-[Define to 1 if tgetent() accepts NULL as a buffer.])
-AC_CACHE_CHECK(if tgetent accepts NULL,
-nmh_cv_func_tgetent_accepts_null,
-[AC_TRY_RUN([
-main()
-{
- char buf[4096];
- int r1 = tgetent(buf, "vt100");
- int r2 = tgetent((char*)0,"vt100");
- if (r1 >= 0 && r1 == r2) {
- char tbuf[1024], *u;
- u = tbuf;
- tgetstr("cl", &u);
- creat("conftest.tgetent", 0640);
- }
- exit((r1 != r2) || r2 == -1);
-}
-],
- if test -f conftest.tgetent; then
- nmh_cv_func_tgetent_accepts_null=yes
- else
- nmh_cv_func_tgetent_accepts_null=no
- fi,
- nmh_cv_func_tgetent_accepts_null=no,
- nmh_cv_func_tgetent_accepts_null=no)])
-if test x$nmh_cv_func_tgetent_accepts_null = xyes; then
- AC_DEFINE(TGETENT_ACCEPTS_NULL)
-fi
-AC_CACHE_CHECK(if tgetent returns 0 on success,
-nmh_cv_func_tgetent_zero_success,
-[AC_TRY_RUN([
-main()
-{
- char buf[4096];
- int r1 = tgetent(buf, "!@#$%^&*");
- int r2 = tgetent(buf, "vt100");
- if (r1 < 0 && r2 == 0) {
- char tbuf[1024], *u;
- u = tbuf;
- tgetstr("cl", &u);
- creat("conftest.tgetent0", 0640);
- }
- exit(r1 == r2);
-}
-],
- if test -f conftest.tgetent0; then
- nmh_cv_func_tgetent_zero_success=yes
- else
- nmh_cv_func_tgetent_zero_success=no
- fi,
- nmh_cv_func_tgetent_zero_success=no,
- nmh_cv_func_tgetent_zero_success=no)])
-AH_TEMPLATE([TGETENT_SUCCESS],
-[Define to what tgetent() returns on success (0 on HP-UX X/Open curses).])
-if test x$nmh_cv_func_tgetent_zero_success = xyes; then
- AC_DEFINE(TGETENT_SUCCESS, 0)
-else
- AC_DEFINE(TGETENT_SUCCESS, 1)
-fi
+AS_IF([test x"$with_tls" != x"no"],[
+ dnl OpenBSD 5 needs the other-libraries (fifth argument) to the
+ dnl AC_CHECK_LIB for SSL_new, because it doesn't
+ dnl automatically append -lcrypto when linking with -lssl.
+ AC_CHECK_HEADER([openssl/ssl.h], HAVE_SSL_H=1)
+ AC_CHECK_LIB([crypto], [BIO_write], [TLSLIB="-lcrypto"])
+ AC_CHECK_LIB([ssl], [SSL_new], [TLSLIB="-lssl $TLSLIB"], [TLSLIB=],
+ [$TLSLIB])])
+AC_SUBST([TLSLIB])
+
+dnl -----------------
+dnl Enable TLS?
+dnl -----------------
+dnl By default (with_tls=''), enable TLS if header and libs were found.
+dnl If TLS requested (--with-tls with_tls=yes), error if header/lib not found.
+dnl If TLS disabled (--without-tls with_tls=no), don't enable it.
+tls_support=no
+TLS_SUPPORT=0
+AC_SUBST([TLS_SUPPORT])
+AS_IF([test "x$with_tls" = xyes && test "x$HAVE_SSL_H" = x],
+ [AC_MSG_ERROR([TLS requested but openssl/ssl.h not found])],
+ [test "x$with_tls" = xyes && test "x$TLSLIB" = x],
+ [AC_MSG_ERROR([TLS requested but crypto or ssl library not found])],
+ [test "x$with_tls" != xno && test "x$HAVE_SSL_H" = x1 && test "x$TLSLIB" != x],
+ [AC_DEFINE([TLS_SUPPORT], [1], [Support TLS for session encryption.])
+ TLS_SUPPORT=1
+ tls_support=yes
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $TLSLIB"
+ AC_CHECK_FUNCS([X509_VERIFY_PARAM_set1_host])
+ LIBS="$save_LIBS"])