[glib-networking: 127/129] Update openssl build system
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking: 127/129] Update openssl build system
- Date: Sat, 2 Feb 2019 22:54:04 +0000 (UTC)
commit cbba9601270223beba83e542018d7aa897e76629
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Sun Dec 9 10:01:40 2018 -0500
Update openssl build system
meson.build | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-
meson_options.txt | 1 +
tls/base/meson.build | 18 +++++++----
tls/openssl/meson.build | 60 ++++++++++++++++++------------------
4 files changed, 123 insertions(+), 37 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1a3bef2..6a63dc7 100644
--- a/meson.build
+++ b/meson.build
@@ -42,6 +42,12 @@ if host_system.contains('linux')
module_ldflags += cc.get_supported_link_arguments(test_ldflag)
endif
+extra_args= []
+# Detect and set symbol visibility
+if cc.get_id() == 'msvc'
+ extra_args += ['-D_GLIB_EXTERN=__declspec (dllexport) extern']
+endif
+
# *** Check GLib GIO ***
glib_dep = dependency('glib-2.0', version: '>= 2.55.1',
fallback: ['glib', 'libglib_dep'])
@@ -77,6 +83,72 @@ if gnutls_dep.found()
backends += ['gnutls']
endif
+# *** Checks for OpenSSL ***
+openssl_dep = dependency('openssl', required: get_option('openssl'))
+if openssl_dep.found()
+ backends += ['openssl']
+elif cc.get_id() == 'msvc'
+ # MSVC builds of OpenSSL does not generate pkg-config files,
+ # so we check for it manually here in this case, if we can't find those files
+ # Based on the CMake check for OpenSSL in CURL's CMakeLists.txt,
+ # on which headers we should check for
+ cc.has_header('openssl/crypto.h')
+ cc.has_header('openssl/engine.h')
+ cc.has_header('openssl/err.h')
+ cc.has_header('openssl/pem.h')
+ cc.has_header('openssl/rsa.h')
+ cc.has_header('openssl/ssl.h')
+ cc.has_header('openssl/x509.h')
+ cc.has_header('openssl/rand.h')
+ cc.has_header('openssl/tls1.h')
+
+ # OpenSSL 1.1.x and 1.0.x (or earlier) have different .lib names,
+ # so we need to look for the correct pair
+
+ # Find either libcrypto.lib (1.1.x) or libeay32.lib (1.0.x or earlier) first
+ libcrypto_dep = cc.find_library('libcrypto', required: false)
+ if not libcrypto_dep.found()
+ libeay_dep = cc.find_library('libeay32')
+ endif
+
+ # Find the corresponding SSL library depending on which crypto .lib we found
+ if libcrypto_dep.found()
+ libssl_dep = cc.find_library('libssl')
+ elif libeay_dep.found()
+ ssleay_dep = cc.find_library('ssleay32')
+ endif
+
+ # Now set the openssl dependency to the corresponding pair of .lib files that we found
+ if libcrypto_dep.found()
+ openssl_dep = [libcrypto_dep, libssl_dep]
+ else
+ openssl_dep = [libeay_dep, ssleay_dep]
+ endif
+
+ backends += ['openssl']
+endif
+
+if backends.contains('openssl') and host_machine.system() != 'windows'
+ ca_certificates = get_option('ca_certificates')
+ if ca_certificates == 'no'
+ message('CA certificates disabled')
+ else
+ if ca_certificates == ''
+ detect_certificates = run_command(join_paths(meson.source_root(), 'detect_certificates.py'))
+
+ if detect_certificates.returncode() == 1
+ error('Could not find certificates. Use -Dca_certificates=path to set, or -Dca_certificates=no to
disable it')
+ endif
+
+ ca_certificates = detect_certificates.stdout().strip()
+ endif
+
+ message('CA certificates: ' + ca_certificates)
+
+ config_h.set_quoted('GTLS_SYSTEM_CA_FILE', ca_certificates)
+ endif
+endif
+
if backends.length() == 0
error('No TLS backends enabled. Please enable at least one TLS backend')
endif
@@ -121,10 +193,16 @@ if libproxy_dep.found() or gsettings_desktop_schemas_dep.found()
subdir('proxy/tests')
endif
+subdir('tls/base')
+
if gnutls_dep.found()
subdir('tls/gnutls')
endif
+if backends.contains('openssl')
+ subdir('tls/openssl')
+endif
+
subdir('tls/tests')
# Will automatically pick it up from the cross file if defined
@@ -134,7 +212,8 @@ if gio_querymodules.found()
endif
output = '\n\n'
-output += ' GnuTLS support: ' + libproxy_dep.found().to_string() + '\n'
+output += ' gnutls support: ' + backends.contains('gnutls').to_string() + '\n'
+output += ' openssl support: ' + backends.contains('openssl').to_string() + '\n'
output += ' libproxy support: ' + libproxy_dep.found().to_string() + '\n'
output += ' GNOME proxy support: ' + gsettings_desktop_schemas_dep.found().to_string() + '\n'
message(output)
diff --git a/meson_options.txt b/meson_options.txt
index d5a8279..3a525dd 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,5 @@
option('gnutls', type: 'feature', value: 'auto', description: 'support for GnuTLS networking configration')
+option('openssl', type: 'feature', value: 'disabled', description: 'support for OpenSSL networking
configration')
option('libproxy', type: 'feature', value: 'auto', description: 'support for libproxy proxy configration')
option('gnome_proxy', type: 'feature', value: 'auto', description: 'support for GNOME desktop proxy
configuration')
option('installed_tests', type: 'boolean', value: false, description: 'enable installed tests')
diff --git a/tls/base/meson.build b/tls/base/meson.build
index cc45ea3..69d907a 100644
--- a/tls/base/meson.build
+++ b/tls/base/meson.build
@@ -1,14 +1,20 @@
-tlsbase_sources = [
+tlsbase_headers = files(
+ 'gtlsconnection-base.h',
+ 'gtlsinputstream-base.h',
+ 'gtlsoutputstream-base.h',
+)
+
+tlsbase_sources = files(
'gtlsconnection-base.c',
'gtlsinputstream-base.c',
'gtlsoutputstream-base.c',
-]
+)
tlsbase = static_library('tlsbase',
- tlsbase_sources,
- dependencies: gio,
- include_directories: config_h_include)
+ tlsbase_sources + tlsbase_headers,
+ dependencies: gio_dep,
+ include_directories: top_inc)
tlsbase_dep = declare_dependency(link_with: tlsbase,
include_directories: include_directories('.'),
- dependencies: gio)
+ dependencies: gio_dep)
diff --git a/tls/openssl/meson.build b/tls/openssl/meson.build
index 24caa85..6684007 100644
--- a/tls/openssl/meson.build
+++ b/tls/openssl/meson.build
@@ -1,4 +1,4 @@
-tlsopenssl_sources = [
+sources = files(
'openssl-module.c',
'gtlsbackend-openssl.c',
'gtlscertificate-openssl.c',
@@ -9,37 +9,37 @@ tlsopenssl_sources = [
'gtlsfiledatabase-openssl.c',
'gtlsbio.c',
'openssl-util.c',
-]
-
-platform_deps = [ openssl, gio, glib, gobject ]
+)
-tlsopenssl = static_library('tlsopenssl',
- tlsopenssl_sources,
- dependencies: [tlsbase_dep, platform_deps],
- include_directories: config_h_include)
+incs = [top_inc]
-tlsopenssl_dep = declare_dependency(link_with: tlsopenssl,
- include_directories: include_directories('.', '../base'),
- dependencies: platform_deps)
+deps = [
+ gio_dep,
+ glib_dep,
+ gmodule_dep,
+ gobject_dep,
+ tlsbase_dep,
+ openssl_dep,
+]
-name_suffix = []
+module = shared_module(
+ 'gioopenssl',
+ sources: sources,
+ include_directories: incs,
+ dependencies: deps,
+ link_args: module_ldflags,
+ link_depends: symbol_map,
+ name_suffix: module_suffix,
+ install: true,
+ install_dir: gio_module_dir,
+ c_args: extra_args
+)
-# FIXME: workaround for https://gitlab.gnome.org/GNOME/glib/issues/1413
-if host_system == 'darwin'
- name_suffix = 'so'
+if get_option('static_modules')
+ static_library('gioopenssl',
+ objects: module.extract_all_objects(),
+ install: true,
+ install_dir: gio_module_dir
+ )
+ pkg.generate(module)
endif
-
-gioopenssl = shared_module('gioopenssl',
- tlsopenssl_sources,
- dependencies: [tlsopenssl_dep],
- include_directories: config_h_include,
- name_suffix: name_suffix,
- install: true,
- install_dir: gio_module_dir,
- c_args: [extra_args + common_flags])
-
-# Internal dependency, for tests and benchmarks
-tlsopenssl_inc = include_directories([ '.', '..' ])
-tlsopenssl_dep = declare_dependency(link_with: tlsopenssl,
- include_directories: [ tlsopenssl_inc, config_h_include ],
- dependencies: platform_deps)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]