project( 'glib-networking', 'c', version: '2.60.1', license: 'LGPL2.1+', meson_version: '>= 0.47.0', default_options: ['c_std=c11'] ) prefix = get_option('prefix') datadir = join_paths(prefix, get_option('datadir')) libdir = join_paths(prefix, get_option('libdir')) libexecdir = join_paths(prefix, get_option('libexecdir')) localedir = join_paths(prefix, get_option('localedir')) installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name()) installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name()) cc = meson.get_compiler('c') host_system = host_machine.system() config_h = configuration_data() config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name()) # Update default CA file if get_option('default_ca_file') != '' config_h.set_quoted('TIZEN_DEFAULT_CA_FILE', get_option('default_ca_file')) endif # TIZEN extension if get_option('tizen_ext') config_h.set('TIZEN_EXT', get_option('tizen_ext')) endif # compiler flags common_flags = [ '-DHAVE_CONFIG_H', '-DG_LOG_DOMAIN="GLib-Net"', '-DLOCALE_DIR="@0@"'.format(localedir), '-DG_DISABLE_DEPRECATED', '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46' ] # TIZEN dlog if get_option('tizen_debug') debug_dep = dependency('dlog') config_h.set('TIZEN_DEBUG', get_option('tizen_debug')) endif add_project_arguments(common_flags, language: 'c') symbol_map = join_paths(meson.current_source_dir(), meson.project_name() + '.map') module_ldflags = [] if host_system.contains('linux') test_ldflag = '-Wl,--version-script,' + symbol_map module_ldflags += cc.get_supported_link_arguments(test_ldflag) endif # *** Check GLib GIO *** glib_dep = dependency('glib-2.0', version: '>= 2.46.0', fallback: ['glib', 'libglib_dep']) gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep']) gobject_dep = dependency('gio-2.0', fallback: ['glib', 'libgobject_dep']) gmodule_dep = dependency('gmodule-2.0', fallback: ['glib', 'libgmodule_dep']) if glib_dep.type_name() == 'internal' glib_proj = subproject('glib') gio_module_dir = glib_proj.get_variable('glib_giomodulesdir') else gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir', define_variable: ['libdir', join_paths(prefix, libdir)]) endif assert(gio_module_dir.startswith(prefix), 'GIO_MODULE_DIR is missing from gio-2.0.pc') # *** Checks for LibProxy *** libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1', required: get_option('libproxy')) # *** Checks for GNOME *** gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', required: get_option('gnome_proxy')) backends = [] # *** Checks for GnuTLS *** gnutls_dep = dependency('gnutls', version: '>= 3.4.6', required: get_option('gnutls')) if gnutls_dep.found() backends += ['gnutls'] endif # *** Checks for OpenSSL *** openssl_option = get_option('openssl') if openssl_option.disabled() openssl_dep = [] else # XXX: https://github.com/mesonbuild/meson/issues/2945 openssl_dep = dependency('openssl1.1', required: openssl_option.enabled() and cc.get_id() != 'msvc') if openssl_dep.found() backends += ['openssl'] elif cc.get_id() == 'msvc' and not openssl_option.disabled() # 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 have_openssl = true foreach h : ['crypto.h', 'engine.h', 'err.h', 'pem.h', 'rsa.h', 'ssl.h', 'x509.h', 'rand.h', 'tls1.h'] header = 'openssl/' + h if not cc.has_header(header) have_openssl = false if openssl_option.enabled() error('openssl module is enabled and @0@ not found'.format(header)) endif endif endforeach # 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 libcrypto_dep.found() libssl = 'libssl' else libcrypto_dep = cc.find_library('libeay32', required: openssl_option) libssl = 'ssleay32' endif if libcrypto_dep.found() # Find the corresponding SSL library depending on which crypto .lib we found libssl_dep = cc.find_library(libssl, required: openssl_option) endif if libcrypto_dep.found() and have_openssl openssl_dep = [libcrypto_dep, libssl_dep] backends += ['openssl'] endif endif endif if backends.length() == 0 error('No TLS backends enabled. Please enable at least one TLS backend') endif configure_file( output: 'config.h', configuration: config_h ) gnome = import('gnome') i18n = import('i18n') pkg = import('pkgconfig') po_dir = join_paths(meson.source_root(), 'po') top_inc = include_directories('.') tls_inc = include_directories('tls') subdir('po') enable_installed_tests = get_option('installed_tests') test_template = files('template.test.in') module_suffix = [] # Keep the autotools convention for shared module suffix because GModule # depends on it: https://gitlab.gnome.org/GNOME/glib/issues/520 if ['darwin', 'ios'].contains(host_system) module_suffix = 'so' endif if libproxy_dep.found() or gsettings_desktop_schemas_dep.found() proxy_test_programs = [] if libproxy_dep.found() subdir('proxy/libproxy') endif if gsettings_desktop_schemas_dep.found() subdir('proxy/gnome') endif 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 gio_querymodules = find_program('gio-querymodules', required : false) if gio_querymodules.found() meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_module_dir) endif output = '\n\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' output += ' TIZEN default CA file: ' + get_option('default_ca_file') + '\n' output += ' TIZEN extension: ' + get_option('tizen_ext').to_string() + '\n' output += ' TIZEN debug: ' + get_option('tizen_debug').to_string() + '\n' message(output)