• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1gmoduleconf_conf = configuration_data()
2
3g_module_need_uscore = 0
4g_module_broken_rtld_global = 0
5g_module_have_dlerror = 0
6
7g_module_impl = ''
8
9# On Windows force native WIN32 shared lib loader
10if host_system == 'windows'
11  g_module_impl = 'G_MODULE_IMPL_WIN32'
12# Force native AIX library loader
13# dlopen() filepath must be of the form /path/libname.a(libname.so)
14elif host_system == 'aix'
15  g_module_impl = 'G_MODULE_IMPL_AR'
16elif have_dlopen_dlsym
17  g_module_impl = 'G_MODULE_IMPL_DL'
18endif
19
20# additional checks for G_MODULE_IMPL_DL
21if g_module_impl == 'G_MODULE_IMPL_DL'
22  # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
23
24  # Check whether we need preceding underscores
25  if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
26    message('Building for MSVC: assuming that symbols are prefixed with underscore')
27    g_module_need_uscore = 1
28  elif meson.has_exe_wrapper()
29    # FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold red
30    rres = cc.run(dlopen_dlsym_test_code,
31                  dependencies : libdl_dep,
32                  name : 'dlsym() preceding underscores')
33    if host_system == 'windows' or rres.returncode() == 0
34      g_module_need_uscore = 1
35    endif
36  else
37    message('Cross-compiling: assuming that symbols aren\'t prefixed with underscore')
38    g_module_need_uscore = 0
39  endif
40
41  if cc.has_function('dlerror', dependencies : libdl_dep)
42    g_module_have_dlerror = 1
43  endif
44endif
45
46# Done, have we got an implementation?
47if g_module_impl == ''
48  g_module_impl = '0'
49  message('WARNING: No suitable GModule implementation found!')
50endif
51
52gmoduleconf_conf.set('G_MODULE_IMPL', g_module_impl)
53gmoduleconf_conf.set('G_MODULE_SUPPORTED', g_module_impl != '0')
54gmoduleconf_conf.set('G_MODULE_HAVE_DLERROR', g_module_have_dlerror)
55gmoduleconf_conf.set('G_MODULE_NEED_USCORE', g_module_need_uscore)
56gmoduleconf_conf.set('G_MODULE_BROKEN_RTLD_GLOBAL', g_module_broken_rtld_global)
57
58gmoduleconf_h = configure_file(input : 'gmoduleconf.h.in',
59                               output : 'gmoduleconf.h',
60                               configuration : gmoduleconf_conf)
61
62install_headers(['gmodule.h'], subdir : 'glib-2.0')
63
64gmodule_sources = ['gmodule.c']
65if host_system == 'windows'
66  gmodule_win_rc = configure_file(
67    input: 'gmodule.rc.in',
68    output: 'gmodule.rc',
69    configuration: glibconfig_conf,
70  )
71  gmodule_win_res = windows.compile_resources(gmodule_win_rc)
72  gmodule_sources += [gmodule_win_res]
73endif
74
75libgmodule = library('gmodule-2.0',
76  sources : gmodule_sources,
77  version : library_version,
78  soversion : soversion,
79  darwin_versions : darwin_versions,
80  install : true,
81  include_directories : [configinc, gmoduleinc],
82  dependencies : [libdl_dep, libglib_dep],
83  c_args : ['-DG_LOG_DOMAIN="GModule"'] + glib_hidden_visibility_args,
84  link_args : [glib_link_flags],
85)
86
87supported_var = 'gmodule_supported=@0@'.format(g_module_impl != '0')
88
89pkg.generate(libgmodule,
90  libraries : [thread_dep],
91  requires : ['glib-2.0'],
92  version : glib_version,
93  variables : [supported_var],
94  install_dir : glib_pkgconfigreldir,
95  filebase : 'gmodule-no-export-2.0',
96  name : 'GModule',
97  description : 'Dynamic module loader for GLib',
98)
99
100pkg.generate(libraries : [libgmodule, export_dynamic_ldflags],
101  requires : ['glib-2.0'],
102  version : glib_version,
103  variables : [supported_var],
104  install_dir : glib_pkgconfigreldir,
105  filebase : 'gmodule-export-2.0',
106  name : 'GModule',
107  description : 'Dynamic module loader for GLib',
108)
109
110pkg.generate(libraries : [libgmodule, export_dynamic_ldflags],
111  requires : ['glib-2.0'],
112  version : glib_version,
113  variables : [supported_var],
114  install_dir : glib_pkgconfigreldir,
115  filebase : 'gmodule-2.0',
116  name : 'GModule',
117  description : 'Dynamic module loader for GLib',
118)
119
120libgmodule_dep = declare_dependency(link_with : libgmodule,
121  include_directories : [gmoduleinc],
122  dependencies : [libglib_dep])
123
124if meson.version().version_compare('>=0.54.0')
125  meson.override_dependency('gmodule-no-export-2.0', libgmodule_dep)
126  meson.override_dependency('gmodule-export-2.0', libgmodule_dep)
127  meson.override_dependency('gmodule-2.0', libgmodule_dep)
128endif
129