Add log messages for debugging
[platform/upstream/glib-networking.git] / meson.build
1 project(
2   'glib-networking', 'c',
3   version: '2.72.alpha',
4   license: 'LGPL2.1+',
5   meson_version: '>= 0.50.0',
6   default_options: ['c_std=gnu99']
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 # Update default CA file
26 if get_option('default_ca_file') != ''
27   config_h.set_quoted('TIZEN_DEFAULT_CA_FILE', get_option('default_ca_file'))
28 endif
29
30 # TIZEN extension
31 if get_option('tizen_ext')
32   config_h.set('TIZEN_EXT', get_option('tizen_ext'))
33 endif
34
35 # compiler flags
36 common_flags = [
37   '-DHAVE_CONFIG_H',
38   '-DG_LOG_DOMAIN="GLib-Net"',
39   '-DG_LOG_USE_STRUCTURED',
40   '-DLOCALE_DIR="@0@"'.format(localedir),
41   '-DG_DISABLE_DEPRECATED',
42   '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_70'
43 ]
44
45 # TIZEN dlog
46 if get_option('tizen_debug')
47   debug_dep = dependency('dlog')
48   config_h.set('TIZEN_DEBUG', get_option('tizen_debug'))
49 endif
50
51 add_project_arguments(common_flags, language: 'c')
52
53 cflags = cc.get_supported_arguments(['-Werror=declaration-after-statement',
54                                      '-Werror=implicit-function-declaration'])
55 add_project_arguments(cflags, language: 'c')
56
57 symbol_map = join_paths(meson.current_source_dir(), meson.project_name() + '.map')
58
59 module_ldflags = []
60
61 if host_system.contains('linux') or host_system == 'android'
62   test_ldflag = '-Wl,--version-script,' + symbol_map
63   module_ldflags += cc.get_supported_link_arguments(test_ldflag)
64 endif
65
66 # *** Check GLib GIO        ***
67 glib_dep = dependency('glib-2.0', version: '>= 2.69.0',
68   fallback: ['glib', 'libglib_dep'])
69 gio_dep = dependency('gio-2.0',
70   fallback: ['glib', 'libgio_dep'])
71 gobject_dep = dependency('gobject-2.0',
72   fallback: ['glib', 'libgobject_dep'])
73 gmodule_dep = dependency('gmodule-2.0',
74   fallback: ['glib', 'libgmodule_dep'])
75
76 if glib_dep.type_name() == 'internal'
77   glib_proj = subproject('glib')
78   gio_module_dir = glib_proj.get_variable('glib_giomodulesdir')
79 else
80   gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir',
81                                                   define_variable: ['libdir', join_paths(prefix, libdir)])
82 endif
83
84 assert(gio_module_dir != '', 'GIO_MODULE_DIR is missing from gio-2.0.pc')
85
86 # *** Checks for LibProxy   ***
87 libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1', required: get_option('libproxy'))
88
89 # *** Checks for GNOME      ***
90 gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', required: get_option('gnome_proxy'))
91
92 backends = []
93
94 # *** Check for dl          ***
95 have_rtld_noload = cc.has_header_symbol('dlfcn.h', 'RTLD_NOLOAD')
96 config_h.set('HAVE_RTLD_NOLOAD', have_rtld_noload)
97
98 # *** Checks for GnuTLS     ***
99 gnutls_dep = dependency('gnutls', version: '>= 3.6.5', required: get_option('gnutls'))
100
101 if gnutls_dep.found()
102   backends += ['gnutls']
103 endif
104
105 # *** Checks for OpenSSL    ***
106 openssl_option = get_option('openssl')
107 if openssl_option.disabled()
108   openssl_dep = []
109 else
110   # XXX: https://github.com/mesonbuild/meson/issues/2945
111
112   openssl_dep = dependency('openssl1.1', version: '>= 1.0.2', required: false)
113   if openssl_dep.found()
114     backends += ['openssl']
115   else
116     # MSVC builds of OpenSSL does not generate pkg-config files,
117     # so we check for it manually here in this case, if we can't find those files
118     # Based on the CMake check for OpenSSL in CURL's CMakeLists.txt,
119     # on which headers we should check for
120
121     # OpenSSL's MSVC NMake Makefiles prepends the library filenames with 'lib',
122     # so we must prepend the libraries with 'lib' on MSVC, except for the pre-1.1.x
123     # ssleay32.lib
124     openssl_lib_prefix = ''
125     if cc.get_argument_syntax() == 'msvc'
126       openssl_lib_prefix = 'lib'
127     endif
128
129     openssl_headers = []
130     foreach h : ['crypto.h', 'engine.h', 'err.h', 'pem.h',
131                  'rsa.h', 'ssl.h', 'x509.h', 'rand.h', 'tls1.h']
132       openssl_headers += 'openssl/' + h
133     endforeach
134
135     # OpenSSL 1.1.x and 1.0.x (or earlier) have different .lib names,
136     # so we need to look for the correct pair
137
138     # Find either libcrypto.lib (1.1.x) or libeay32.lib (1.0.x or earlier) first
139     libcrypto_dep = cc.find_library('@0@crypto'.format(openssl_lib_prefix), required: false)
140     if libcrypto_dep.found()
141       libssl = '@0@ssl'.format(openssl_lib_prefix)
142     else
143       libcrypto_dep = cc.find_library('@0@eay32'.format(openssl_lib_prefix), required: openssl_option)
144       libssl = 'ssleay32'
145     endif
146
147     if libcrypto_dep.found()
148       # Find the corresponding SSL library depending on which crypto .lib we found
149       libssl_dep = cc.find_library(libssl, required: openssl_option, has_headers: openssl_headers)
150     endif
151
152     if libcrypto_dep.found() and libssl_dep.found()
153       openssl_dep = [libcrypto_dep, libssl_dep]
154       backends += ['openssl']
155     endif
156   endif
157 endif
158
159 if backends.length() == 0
160   error('No TLS backends enabled. Please enable at least one TLS backend')
161 endif
162
163 configure_file(
164   output: 'config.h',
165   configuration: config_h
166 )
167
168 gnome = import('gnome')
169 i18n = import('i18n')
170 pkg = import('pkgconfig')
171
172 po_dir = join_paths(meson.source_root(), 'po')
173
174 top_inc = include_directories('.')
175 tls_inc = include_directories('tls')
176
177 subdir('po')
178
179 enable_installed_tests = get_option('installed_tests')
180 test_template = files('template.test.in')
181
182 module_suffix = []
183 # Keep the autotools convention for shared module suffix because GModule
184 # depends on it: https://gitlab.gnome.org/GNOME/glib/issues/520
185 if ['darwin', 'ios'].contains(host_system)
186   module_suffix = 'so'
187 endif
188
189 if libproxy_dep.found() or gsettings_desktop_schemas_dep.found()
190   proxy_test_programs = []
191
192   if libproxy_dep.found()
193     subdir('proxy/libproxy')
194   endif
195
196   if gsettings_desktop_schemas_dep.found()
197     subdir('proxy/gnome')
198   endif
199
200   subdir('proxy/tests')
201 endif
202
203 subdir('tls/base')
204
205 if gnutls_dep.found()
206   subdir('tls/gnutls')
207 endif
208
209 if backends.contains('openssl')
210   if ['darwin', 'ios'].contains(host_system)
211     security_dep = dependency('appleframeworks', modules : ['Security'])
212   elif ['windows'].contains(host_system)
213     crypt32_dep = cc.find_library('crypt32')
214   endif
215
216   subdir('tls/openssl')
217 endif
218
219 #subdir('tls/tests')
220
221 # Will automatically pick it up from the cross file if defined
222 gio_querymodules = find_program('gio-querymodules', required : false)
223 if gio_querymodules.found()
224   meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_module_dir)
225 endif
226
227 output = '\n\n'
228 output += '  gnutls support:      ' + backends.contains('gnutls').to_string() + '\n'
229 output += '  openssl support:     ' + backends.contains('openssl').to_string() + '\n'
230 output += '  libproxy support:    ' + libproxy_dep.found().to_string() + '\n'
231 output += '  GNOME proxy support: ' + gsettings_desktop_schemas_dep.found().to_string() + '\n'
232 output += '  TIZEN default CA file: ' + get_option('default_ca_file') + '\n'
233 output += '  TIZEN extension:     ' + get_option('tizen_ext').to_string() + '\n'
234 output += '  TIZEN debug:         ' + get_option('tizen_debug').to_string() + '\n'
235 message(output)