Rename some symbols to use lower glib-2.0 version
[platform/upstream/glib-networking.git] / meson.build
1 project(
2   'glib-networking', 'c',
3   version: '2.60.1',
4   license: 'LGPL2.1+',
5   meson_version: '>= 0.47.0',
6   default_options: ['c_std=c11']
7 )
8
9 prefix = get_option('prefix')
10 datadir = join_paths(prefix, get_option('datadir'))
11 libdir = join_paths(prefix, get_option('libdir'))
12 libexecdir = join_paths(prefix, get_option('libexecdir'))
13 localedir = join_paths(prefix, get_option('localedir'))
14
15 installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name())
16 installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name())
17
18 cc = meson.get_compiler('c')
19 host_system = host_machine.system()
20
21 config_h = configuration_data()
22
23 config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
24
25 # compiler flags
26 common_flags = [
27   '-DHAVE_CONFIG_H',
28   '-DG_LOG_DOMAIN="GLib-Net"',
29   '-DLOCALE_DIR="@0@"'.format(localedir),
30   '-DG_DISABLE_DEPRECATED',
31   '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46'
32 ]
33
34 add_project_arguments(common_flags, language: 'c')
35
36 symbol_map = join_paths(meson.current_source_dir(), meson.project_name() + '.map')
37
38 module_ldflags = []
39
40 if host_system.contains('linux')
41   test_ldflag = '-Wl,--version-script,' + symbol_map
42   module_ldflags += cc.get_supported_link_arguments(test_ldflag)
43 endif
44
45 # *** Check GLib GIO        ***
46 glib_dep = dependency('glib-2.0', version: '>= 2.46.0',
47   fallback: ['glib', 'libglib_dep'])
48 gio_dep = dependency('gio-2.0',
49   fallback: ['glib', 'libgio_dep'])
50 gobject_dep = dependency('gio-2.0',
51   fallback: ['glib', 'libgobject_dep'])
52 gmodule_dep = dependency('gmodule-2.0',
53   fallback: ['glib', 'libgmodule_dep'])
54
55 if glib_dep.type_name() == 'internal'
56   glib_proj = subproject('glib')
57   gio_module_dir = glib_proj.get_variable('glib_giomodulesdir')
58 else
59   gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir',
60                                                   define_variable: ['libdir', join_paths(prefix, libdir)])
61 endif
62
63 assert(gio_module_dir.startswith(prefix), 'GIO_MODULE_DIR is missing from gio-2.0.pc')
64
65 # *** Checks for LibProxy   ***
66 libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1', required: get_option('libproxy'))
67
68 # *** Checks for GNOME      ***
69 gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', required: get_option('gnome_proxy'))
70
71 backends = []
72
73 # *** Checks for GnuTLS     ***
74 gnutls_dep = dependency('gnutls', version: '>= 3.4.6', required: get_option('gnutls'))
75
76 if gnutls_dep.found()
77   backends += ['gnutls']
78 endif
79
80 # *** Checks for OpenSSL    ***
81 openssl_option = get_option('openssl')
82 if openssl_option.disabled()
83   openssl_dep = []
84 else
85   # XXX: https://github.com/mesonbuild/meson/issues/2945
86   openssl_dep = dependency('openssl', required: openssl_option.enabled() and cc.get_id() != 'msvc')
87   if openssl_dep.found()
88     backends += ['openssl']
89   elif cc.get_id() == 'msvc' and not openssl_option.disabled()
90     # MSVC builds of OpenSSL does not generate pkg-config files,
91     # so we check for it manually here in this case, if we can't find those files
92     # Based on the CMake check for OpenSSL in CURL's CMakeLists.txt,
93     # on which headers we should check for
94     have_openssl = true
95     foreach h : ['crypto.h', 'engine.h', 'err.h', 'pem.h',
96                  'rsa.h', 'ssl.h', 'x509.h', 'rand.h', 'tls1.h']
97       header = 'openssl/' + h
98       if not cc.has_header(header)
99         have_openssl = false
100         if openssl_option.enabled()
101           error('openssl module is enabled and @0@ not found'.format(header))
102         endif
103       endif
104     endforeach
105
106     # OpenSSL 1.1.x and 1.0.x (or earlier) have different .lib names,
107     # so we need to look for the correct pair
108
109     # Find either libcrypto.lib (1.1.x) or libeay32.lib (1.0.x or earlier) first
110     libcrypto_dep = cc.find_library('libcrypto', required: false)
111     if libcrypto_dep.found()
112       libssl = 'libssl'
113     else
114       libcrypto_dep = cc.find_library('libeay32', required: openssl_option)
115       libssl = 'ssleay32'
116     endif
117
118     if libcrypto_dep.found()
119       # Find the corresponding SSL library depending on which crypto .lib we found
120       libssl_dep = cc.find_library(libssl, required: openssl_option)
121     endif
122
123     if libcrypto_dep.found() and have_openssl
124       openssl_dep = [libcrypto_dep, libssl_dep]
125       backends += ['openssl']
126     endif
127   endif
128 endif
129
130 if backends.length() == 0
131   error('No TLS backends enabled. Please enable at least one TLS backend')
132 endif
133
134 configure_file(
135   output: 'config.h',
136   configuration: config_h
137 )
138
139 gnome = import('gnome')
140 i18n = import('i18n')
141 pkg = import('pkgconfig')
142
143 po_dir = join_paths(meson.source_root(), 'po')
144
145 top_inc = include_directories('.')
146 tls_inc = include_directories('tls')
147
148 subdir('po')
149
150 enable_installed_tests = get_option('installed_tests')
151 test_template = files('template.test.in')
152
153 module_suffix = []
154 # Keep the autotools convention for shared module suffix because GModule
155 # depends on it: https://gitlab.gnome.org/GNOME/glib/issues/520
156 if ['darwin', 'ios'].contains(host_system)
157   module_suffix = 'so'
158 endif
159
160 if libproxy_dep.found() or gsettings_desktop_schemas_dep.found()
161   proxy_test_programs = []
162
163   if libproxy_dep.found()
164     subdir('proxy/libproxy')
165   endif
166
167   if gsettings_desktop_schemas_dep.found()
168     subdir('proxy/gnome')
169   endif
170
171   subdir('proxy/tests')
172 endif
173
174 subdir('tls/base')
175
176 if gnutls_dep.found()
177   subdir('tls/gnutls')
178 endif
179
180 if backends.contains('openssl')
181   subdir('tls/openssl')
182 endif
183
184 subdir('tls/tests')
185
186 # Will automatically pick it up from the cross file if defined
187 gio_querymodules = find_program('gio-querymodules', required : false)
188 if gio_querymodules.found()
189   meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_module_dir)
190 endif
191
192 output = '\n\n'
193 output += '  gnutls support:      ' + backends.contains('gnutls').to_string() + '\n'
194 output += '  openssl support:     ' + backends.contains('openssl').to_string() + '\n'
195 output += '  libproxy support:    ' + libproxy_dep.found().to_string() + '\n'
196 output += '  GNOME proxy support: ' + gsettings_desktop_schemas_dep.found().to_string() + '\n'
197 message(output)