Add tizen dlog for debugging
[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 # 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   '-DLOCALE_DIR="@0@"'.format(localedir),
40   '-DG_DISABLE_DEPRECATED',
41   '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46'
42 ]
43
44 # TIZEN dlog
45 if get_option('tizen_debug')
46   debug_dep = dependency('dlog')
47   config_h.set('TIZEN_DEBUG', get_option('tizen_debug'))
48 endif
49
50 add_project_arguments(common_flags, language: 'c')
51
52 symbol_map = join_paths(meson.current_source_dir(), meson.project_name() + '.map')
53
54 module_ldflags = []
55
56 if host_system.contains('linux')
57   test_ldflag = '-Wl,--version-script,' + symbol_map
58   module_ldflags += cc.get_supported_link_arguments(test_ldflag)
59 endif
60
61 # *** Check GLib GIO        ***
62 glib_dep = dependency('glib-2.0', version: '>= 2.46.0',
63   fallback: ['glib', 'libglib_dep'])
64 gio_dep = dependency('gio-2.0',
65   fallback: ['glib', 'libgio_dep'])
66 gobject_dep = dependency('gio-2.0',
67   fallback: ['glib', 'libgobject_dep'])
68 gmodule_dep = dependency('gmodule-2.0',
69   fallback: ['glib', 'libgmodule_dep'])
70
71 if glib_dep.type_name() == 'internal'
72   glib_proj = subproject('glib')
73   gio_module_dir = glib_proj.get_variable('glib_giomodulesdir')
74 else
75   gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir',
76                                                   define_variable: ['libdir', join_paths(prefix, libdir)])
77 endif
78
79 assert(gio_module_dir.startswith(prefix), 'GIO_MODULE_DIR is missing from gio-2.0.pc')
80
81 # *** Checks for LibProxy   ***
82 libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1', required: get_option('libproxy'))
83
84 # *** Checks for GNOME      ***
85 gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', required: get_option('gnome_proxy'))
86
87 backends = []
88
89 # *** Checks for GnuTLS     ***
90 gnutls_dep = dependency('gnutls', version: '>= 3.4.6', required: get_option('gnutls'))
91
92 if gnutls_dep.found()
93   backends += ['gnutls']
94 endif
95
96 # *** Checks for OpenSSL    ***
97 openssl_option = get_option('openssl')
98 if openssl_option.disabled()
99   openssl_dep = []
100 else
101   # XXX: https://github.com/mesonbuild/meson/issues/2945
102   openssl_dep = dependency('openssl1.1', required: openssl_option.enabled() and cc.get_id() != 'msvc')
103   if openssl_dep.found()
104     backends += ['openssl']
105   elif cc.get_id() == 'msvc' and not openssl_option.disabled()
106     # MSVC builds of OpenSSL does not generate pkg-config files,
107     # so we check for it manually here in this case, if we can't find those files
108     # Based on the CMake check for OpenSSL in CURL's CMakeLists.txt,
109     # on which headers we should check for
110     have_openssl = true
111     foreach h : ['crypto.h', 'engine.h', 'err.h', 'pem.h',
112                  'rsa.h', 'ssl.h', 'x509.h', 'rand.h', 'tls1.h']
113       header = 'openssl/' + h
114       if not cc.has_header(header)
115         have_openssl = false
116         if openssl_option.enabled()
117           error('openssl module is enabled and @0@ not found'.format(header))
118         endif
119       endif
120     endforeach
121
122     # OpenSSL 1.1.x and 1.0.x (or earlier) have different .lib names,
123     # so we need to look for the correct pair
124
125     # Find either libcrypto.lib (1.1.x) or libeay32.lib (1.0.x or earlier) first
126     libcrypto_dep = cc.find_library('libcrypto', required: false)
127     if libcrypto_dep.found()
128       libssl = 'libssl'
129     else
130       libcrypto_dep = cc.find_library('libeay32', required: openssl_option)
131       libssl = 'ssleay32'
132     endif
133
134     if libcrypto_dep.found()
135       # Find the corresponding SSL library depending on which crypto .lib we found
136       libssl_dep = cc.find_library(libssl, required: openssl_option)
137     endif
138
139     if libcrypto_dep.found() and have_openssl
140       openssl_dep = [libcrypto_dep, libssl_dep]
141       backends += ['openssl']
142     endif
143   endif
144 endif
145
146 if backends.length() == 0
147   error('No TLS backends enabled. Please enable at least one TLS backend')
148 endif
149
150 configure_file(
151   output: 'config.h',
152   configuration: config_h
153 )
154
155 gnome = import('gnome')
156 i18n = import('i18n')
157 pkg = import('pkgconfig')
158
159 po_dir = join_paths(meson.source_root(), 'po')
160
161 top_inc = include_directories('.')
162 tls_inc = include_directories('tls')
163
164 subdir('po')
165
166 enable_installed_tests = get_option('installed_tests')
167 test_template = files('template.test.in')
168
169 module_suffix = []
170 # Keep the autotools convention for shared module suffix because GModule
171 # depends on it: https://gitlab.gnome.org/GNOME/glib/issues/520
172 if ['darwin', 'ios'].contains(host_system)
173   module_suffix = 'so'
174 endif
175
176 if libproxy_dep.found() or gsettings_desktop_schemas_dep.found()
177   proxy_test_programs = []
178
179   if libproxy_dep.found()
180     subdir('proxy/libproxy')
181   endif
182
183   if gsettings_desktop_schemas_dep.found()
184     subdir('proxy/gnome')
185   endif
186
187   subdir('proxy/tests')
188 endif
189
190 subdir('tls/base')
191
192 if gnutls_dep.found()
193   subdir('tls/gnutls')
194 endif
195
196 if backends.contains('openssl')
197   subdir('tls/openssl')
198 endif
199
200 subdir('tls/tests')
201
202 # Will automatically pick it up from the cross file if defined
203 gio_querymodules = find_program('gio-querymodules', required : false)
204 if gio_querymodules.found()
205   meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_module_dir)
206 endif
207
208 output = '\n\n'
209 output += '  gnutls support:      ' + backends.contains('gnutls').to_string() + '\n'
210 output += '  openssl support:     ' + backends.contains('openssl').to_string() + '\n'
211 output += '  libproxy support:    ' + libproxy_dep.found().to_string() + '\n'
212 output += '  GNOME proxy support: ' + gsettings_desktop_schemas_dep.found().to_string() + '\n'
213 output += '  TIZEN default CA file: ' + get_option('default_ca_file') + '\n'
214 output += '  TIZEN extension:     ' + get_option('tizen_ext').to_string() + '\n'
215 output += '  TIZEN debug:         ' + get_option('tizen_debug').to_string() + '\n'
216 message(output)