summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-07-27 03:36:45 +0200
committerGravatar Nikias Bassen2021-07-27 03:36:45 +0200
commitab1c815340afc2883c9ef08795eebd9bed1858c5 (patch)
treea188e92dfdff14e501bf42b5d880155468cffbdd /configure.ac
parent19eca85f90d9950596e1c6021d7b0f89407f5d7f (diff)
downloadlibimobiledevice-ab1c815340afc2883c9ef08795eebd9bed1858c5.tar.gz
libimobiledevice-ab1c815340afc2883c9ef08795eebd9bed1858c5.tar.bz2
Add support for MbedTLS
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac113
1 files changed, 81 insertions, 32 deletions
diff --git a/configure.ac b/configure.ac
index 82038e1..bd061fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,43 +128,92 @@ fi
AM_CONDITIONAL([HAVE_CYTHON],[test "x$CYTHON_SUB" = "xcython"])
AC_SUBST([CYTHON_SUB])
-AC_ARG_ENABLE([openssl],
- [AS_HELP_STRING([--disable-openssl],
+default_openssl=yes
+
+AC_ARG_WITH([mbedtls],
+ [AS_HELP_STRING([--without-mbedtls],
+ [Do not look for mbedtls])],
+ [use_mbedtls=$withval],
+ [use_mbedtls=no])
+if test "x$use_mbedtls" == "xyes"; then
+ default_openssl=no
+fi
+AC_ARG_WITH([gnutls],
+ [AS_HELP_STRING([--without-gnutls],
+ [Do not look for GnuTLS])],
+ [use_gnutls=$withval],
+ [use_gnutls=no])
+if test "x$use_gnutls" == "xyes"; then
+ default_openssl=no
+fi
+AC_ARG_WITH([openssl],
+ [AS_HELP_STRING([--without-openssl],
[Do not look for OpenSSL])],
- [use_openssl=$enableval],
- [use_openssl=yes])
-
-pkg_req_openssl="openssl >= 0.9.8"
-PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no)
-if test "x$have_openssl" = "xyes"; then
- if test "x$use_openssl" != "xyes"; then
- enable_openssl=no
- echo "*** Note: OpenSSL support explicitly disabled ***"
- else
- enable_openssl=yes
+ [use_openssl=$withval],
+ [use_openssl=$default_openssl])
+
+if test "x$use_mbedtls" == "xyes"; then
+ CACHED_CFLAGS="$CFLAGS"
+ conf_mbedtls_CFLAGS=""
+ if test -n "$mbedtls_INCLUDES"; then
+ CFLAGS=" -I$mbedtls_INCLUDES"
+ conf_mbedtls_CFLAGS="-I$mbedtls_INCLUDES"
fi
-else
- if test "x$use_openssl" == "xyes" -a "x$have_openssl" != "xyes"; then
- AC_MSG_ERROR([OpenSSL support explicitly requested but OpenSSL could not be found])
+ conf_mbedtls_LIBS=""
+ if test -n "$mbedtls_LIBDIR"; then
+ conf_mbedtls_LIBS+=" -L$mbedtls_LIBDIR"
fi
-fi
-
-if test "x$enable_openssl" = "xyes"; then
- AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL support])
- AC_SUBST(openssl_CFLAGS)
- AC_SUBST(openssl_LIBS)
- ssl_provider="OpenSSL";
- ssl_requires="$pkg_req_openssl"
+ if test -n "$mbedtls_LIBS"; then
+ conf_mbedtls_LIBS+=" $mbedtls_LIBS"
+ else
+ conf_mbedtls_LIBS+=" -lmbedtls -lmbedx509 -lmbedcrypto"
+ fi
+ AC_CHECK_HEADER(mbedtls/ssl.h, [break], [AC_MSG_ERROR([MbedTLS support explicitly requested, but includes could not be found. Try setting mbedtls_INCLUDES=/path/to/mbedtls/include])])
+ CFLAGS="$CACHED_CFLAGS"
+ AC_DEFINE(HAVE_MBEDTLS, 1, [Define if you have MbedTLS support])
+ ssl_lib_CFLAGS="$conf_mbedtls_CFLAGS"
+ ssl_lib_LIBS="$conf_mbedtls_LIBS"
+ AC_SUBST(ssl_lib_CFLAGS)
+ AC_SUBST(ssl_lib_LIBS)
+ ssl_provider="MbedTLS";
+ ssl_requires=""
AC_SUBST(ssl_requires)
else
- pkg_req_gnutls="gnutls >= 2.2.0"
- pkg_req_libtasn1="libtasn1 >= 1.1"
- PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls)
- AC_CHECK_LIB(gcrypt, gcry_control, [AC_SUBST(libgcrypt_LIBS,[-lgcrypt])], [AC_MSG_ERROR([libgcrypt is required to build libimobiledevice with GnuTLS])])
- PKG_CHECK_MODULES(libtasn1, $pkg_req_libtasn1)
- ssl_provider="GnuTLS"
- ssl_requires="$pkg_req_gnutls $pkg_req_libtasn1"
- AC_SUBST(ssl_requires)
+ if test "x$use_openssl" == "xyes"; then
+ pkg_req_openssl="openssl >= 0.9.8"
+ PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no)
+ if test "x$have_openssl" != "xyes"; then
+ AC_MSG_ERROR([OpenSSL support explicitly requested but OpenSSL could not be found])
+ else
+ AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL support])
+ ssl_lib_CFLAGS="$openssl_CFLAGS"
+ ssl_lib_LIBS="$openssl_LIBS"
+ AC_SUBST(ssl_lib_CFLAGS)
+ AC_SUBST(ssl_lib_LIBS)
+ ssl_provider="OpenSSL";
+ ssl_requires="$pkg_req_openssl"
+ AC_SUBST(ssl_requires)
+ fi
+ else
+ if test "x$use_gnutls" == "xyes"; then
+ pkg_req_gnutls="gnutls >= 2.2.0"
+ pkg_req_libtasn1="libtasn1 >= 1.1"
+ PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls)
+ AC_CHECK_LIB(gcrypt, gcry_control, [AC_SUBST(libgcrypt_LIBS,[-lgcrypt])], [AC_MSG_ERROR([libgcrypt is required to build libimobiledevice with GnuTLS])])
+ PKG_CHECK_MODULES(libtasn1, $pkg_req_libtasn1)
+
+ AC_DEFINE(HAVE_GNUTLS, 1, [Define if you have GnuTLS support])
+ ssl_lib_CFLAGS="$libgnutls_CFLAGS $libtasn1_CFLAGS $libgcrypt_CFLAGS"
+ ssl_lib_LIBS="$libgnutls_LIBS $libtasn1_LIBS $libgcrypt_LIBS"
+ AC_SUBST(ssl_lib_CFLAGS)
+ AC_SUBST(ssl_lib_LIBS)
+ ssl_provider="GnuTLS"
+ ssl_requires="$pkg_req_gnutls $pkg_req_libtasn1"
+ AC_SUBST(ssl_requires)
+ else
+ AC_MSG_ERROR([No SSL library configured. $PACKAGE cannot be built without a supported SSL library.])
+ fi
+ fi
fi
AC_ARG_ENABLE([debug],