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
128AM_CONDITIONAL([HAVE_CYTHON],[test "x$CYTHON_SUB" = "xcython"]) 128AM_CONDITIONAL([HAVE_CYTHON],[test "x$CYTHON_SUB" = "xcython"])
129AC_SUBST([CYTHON_SUB]) 129AC_SUBST([CYTHON_SUB])
130 130
131AC_ARG_ENABLE([openssl], 131default_openssl=yes
132 [AS_HELP_STRING([--disable-openssl], 132
133AC_ARG_WITH([mbedtls],
134 [AS_HELP_STRING([--without-mbedtls],
135 [Do not look for mbedtls])],
136 [use_mbedtls=$withval],
137 [use_mbedtls=no])
138if test "x$use_mbedtls" == "xyes"; then
139 default_openssl=no
140fi
141AC_ARG_WITH([gnutls],
142 [AS_HELP_STRING([--without-gnutls],
143 [Do not look for GnuTLS])],
144 [use_gnutls=$withval],
145 [use_gnutls=no])
146if test "x$use_gnutls" == "xyes"; then
147 default_openssl=no
148fi
149AC_ARG_WITH([openssl],
150 [AS_HELP_STRING([--without-openssl],
133 [Do not look for OpenSSL])], 151 [Do not look for OpenSSL])],
134 [use_openssl=$enableval], 152 [use_openssl=$withval],
135 [use_openssl=yes]) 153 [use_openssl=$default_openssl])
136 154
137pkg_req_openssl="openssl >= 0.9.8" 155if test "x$use_mbedtls" == "xyes"; then
138PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no) 156 CACHED_CFLAGS="$CFLAGS"
139if test "x$have_openssl" = "xyes"; then 157 conf_mbedtls_CFLAGS=""
140 if test "x$use_openssl" != "xyes"; then 158 if test -n "$mbedtls_INCLUDES"; then
141 enable_openssl=no 159 CFLAGS=" -I$mbedtls_INCLUDES"
142 echo "*** Note: OpenSSL support explicitly disabled ***" 160 conf_mbedtls_CFLAGS="-I$mbedtls_INCLUDES"
143 else
144 enable_openssl=yes
145 fi 161 fi
146else 162 conf_mbedtls_LIBS=""
147 if test "x$use_openssl" == "xyes" -a "x$have_openssl" != "xyes"; then 163 if test -n "$mbedtls_LIBDIR"; then
148 AC_MSG_ERROR([OpenSSL support explicitly requested but OpenSSL could not be found]) 164 conf_mbedtls_LIBS+=" -L$mbedtls_LIBDIR"
149 fi 165 fi
150fi 166 if test -n "$mbedtls_LIBS"; then
151 167 conf_mbedtls_LIBS+=" $mbedtls_LIBS"
152if test "x$enable_openssl" = "xyes"; then 168 else
153 AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL support]) 169 conf_mbedtls_LIBS+=" -lmbedtls -lmbedx509 -lmbedcrypto"
154 AC_SUBST(openssl_CFLAGS) 170 fi
155 AC_SUBST(openssl_LIBS) 171 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])])
156 ssl_provider="OpenSSL"; 172 CFLAGS="$CACHED_CFLAGS"
157 ssl_requires="$pkg_req_openssl" 173 AC_DEFINE(HAVE_MBEDTLS, 1, [Define if you have MbedTLS support])
174 ssl_lib_CFLAGS="$conf_mbedtls_CFLAGS"
175 ssl_lib_LIBS="$conf_mbedtls_LIBS"
176 AC_SUBST(ssl_lib_CFLAGS)
177 AC_SUBST(ssl_lib_LIBS)
178 ssl_provider="MbedTLS";
179 ssl_requires=""
158 AC_SUBST(ssl_requires) 180 AC_SUBST(ssl_requires)
159else 181else
160 pkg_req_gnutls="gnutls >= 2.2.0" 182 if test "x$use_openssl" == "xyes"; then
161 pkg_req_libtasn1="libtasn1 >= 1.1" 183 pkg_req_openssl="openssl >= 0.9.8"
162 PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls) 184 PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no)
163 AC_CHECK_LIB(gcrypt, gcry_control, [AC_SUBST(libgcrypt_LIBS,[-lgcrypt])], [AC_MSG_ERROR([libgcrypt is required to build libimobiledevice with GnuTLS])]) 185 if test "x$have_openssl" != "xyes"; then
164 PKG_CHECK_MODULES(libtasn1, $pkg_req_libtasn1) 186 AC_MSG_ERROR([OpenSSL support explicitly requested but OpenSSL could not be found])
165 ssl_provider="GnuTLS" 187 else
166 ssl_requires="$pkg_req_gnutls $pkg_req_libtasn1" 188 AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL support])
167 AC_SUBST(ssl_requires) 189 ssl_lib_CFLAGS="$openssl_CFLAGS"
190 ssl_lib_LIBS="$openssl_LIBS"
191 AC_SUBST(ssl_lib_CFLAGS)
192 AC_SUBST(ssl_lib_LIBS)
193 ssl_provider="OpenSSL";
194 ssl_requires="$pkg_req_openssl"
195 AC_SUBST(ssl_requires)
196 fi
197 else
198 if test "x$use_gnutls" == "xyes"; then
199 pkg_req_gnutls="gnutls >= 2.2.0"
200 pkg_req_libtasn1="libtasn1 >= 1.1"
201 PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls)
202 AC_CHECK_LIB(gcrypt, gcry_control, [AC_SUBST(libgcrypt_LIBS,[-lgcrypt])], [AC_MSG_ERROR([libgcrypt is required to build libimobiledevice with GnuTLS])])
203 PKG_CHECK_MODULES(libtasn1, $pkg_req_libtasn1)
204
205 AC_DEFINE(HAVE_GNUTLS, 1, [Define if you have GnuTLS support])
206 ssl_lib_CFLAGS="$libgnutls_CFLAGS $libtasn1_CFLAGS $libgcrypt_CFLAGS"
207 ssl_lib_LIBS="$libgnutls_LIBS $libtasn1_LIBS $libgcrypt_LIBS"
208 AC_SUBST(ssl_lib_CFLAGS)
209 AC_SUBST(ssl_lib_LIBS)
210 ssl_provider="GnuTLS"
211 ssl_requires="$pkg_req_gnutls $pkg_req_libtasn1"
212 AC_SUBST(ssl_requires)
213 else
214 AC_MSG_ERROR([No SSL library configured. $PACKAGE cannot be built without a supported SSL library.])
215 fi
216 fi
168fi 217fi
169 218
170AC_ARG_ENABLE([debug], 219AC_ARG_ENABLE([debug],