2016-03-07 12:13:24 +01:00
|
|
|
gmoduleconf_conf = configuration_data()
|
|
|
|
|
|
|
|
g_module_need_uscore = 0
|
|
|
|
g_module_broken_rtld_global = 0
|
|
|
|
g_module_have_dlerror = 0
|
|
|
|
|
|
|
|
libdl_dep = [ ]
|
|
|
|
g_module_lib_args = [ ]
|
|
|
|
g_module_impl = ''
|
|
|
|
|
|
|
|
dlopen_dlsym_test_code = '''
|
|
|
|
#include <dlfcn.h>
|
|
|
|
int glib_underscore_test (void) { return 42; }
|
|
|
|
int main (int argc, char ** argv) {
|
|
|
|
void *f1 = (void*)0, *f2 = (void*)0, *handle;
|
|
|
|
handle = dlopen ((void*)0, 0);
|
|
|
|
if (handle) {
|
|
|
|
f1 = dlsym (handle, "glib_underscore_test");
|
|
|
|
f2 = dlsym (handle, "_glib_underscore_test");
|
|
|
|
}
|
|
|
|
return (!f2 || f1);
|
|
|
|
}'''
|
|
|
|
|
|
|
|
# On Windows force native WIN32 shared lib loader
|
2016-12-20 23:37:24 +01:00
|
|
|
if host_system == 'windows'
|
2016-03-07 12:13:24 +01:00
|
|
|
g_module_impl = 'G_MODULE_IMPL_WIN32'
|
|
|
|
# Force native AIX library loader
|
|
|
|
# dlopen() filepath must be of the form /path/libname.a(libname.so)
|
2016-12-20 23:37:24 +01:00
|
|
|
elif host_system == 'aix'
|
2016-03-07 12:13:24 +01:00
|
|
|
g_module_impl = 'G_MODULE_IMPL_AR'
|
|
|
|
elif cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
|
|
|
|
g_module_impl = 'G_MODULE_IMPL_DL'
|
|
|
|
# NSLinkModule (dyld) in system libraries (Darwin)
|
2016-12-20 23:37:24 +01:00
|
|
|
elif cc.has_function('NSLinkModule')
|
2016-03-07 12:13:24 +01:00
|
|
|
g_module_impl = 'G_MODULE_IMPL_DYLD'
|
|
|
|
g_module_need_uscore = 1
|
|
|
|
elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
|
|
|
|
g_module_impl = 'G_MODULE_IMPL_DL'
|
2016-12-20 23:37:24 +01:00
|
|
|
libdl_dep = cc.find_library('dl')
|
2016-03-07 12:13:24 +01:00
|
|
|
g_module_lib_args = '-ldl'
|
|
|
|
endif
|
|
|
|
|
|
|
|
# additional checks for G_MODULE_IMPL_DL
|
|
|
|
if g_module_impl == 'G_MODULE_IMPL_DL'
|
|
|
|
# FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
|
|
|
|
|
|
|
|
# Check whether we need preceding underscores
|
2016-12-20 23:37:24 +01:00
|
|
|
if cc.get_id() == 'msvc'
|
|
|
|
message('Building for MSVC: assuming that symbols are prefixed with underscore')
|
|
|
|
g_module_need_uscore = 1
|
|
|
|
elif meson.has_exe_wrapper()
|
2016-03-07 12:13:24 +01:00
|
|
|
# FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold red
|
|
|
|
rres = cc.run(dlopen_dlsym_test_code,
|
|
|
|
args : g_module_lib_args,
|
|
|
|
name : 'dlsym() preceding underscores')
|
2016-12-20 23:37:24 +01:00
|
|
|
if host_system == 'windows' or rres.returncode() == 0
|
2016-03-07 12:13:24 +01:00
|
|
|
g_module_need_uscore = 1
|
|
|
|
endif
|
2016-12-20 23:37:24 +01:00
|
|
|
else
|
|
|
|
message('Cross-compiling: assuming that symbols aren\'t prefixed with underscore')
|
|
|
|
g_module_need_uscore = 0
|
2016-03-07 12:13:24 +01:00
|
|
|
endif
|
|
|
|
|
2016-12-20 23:37:24 +01:00
|
|
|
if cc.has_function('dlerror', args : g_module_lib_args)
|
2016-03-07 12:13:24 +01:00
|
|
|
g_module_have_dlerror = 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Done, have we got an implementation?
|
|
|
|
if g_module_impl == ''
|
|
|
|
g_module_impl = '0'
|
|
|
|
message('WARNING: No suitable GModule implementation found!')
|
|
|
|
endif
|
|
|
|
|
|
|
|
gmoduleconf_conf.set('G_MODULE_IMPL', g_module_impl)
|
|
|
|
gmoduleconf_conf.set('G_MODULE_SUPPORTED', g_module_impl != '0')
|
|
|
|
gmoduleconf_conf.set('G_MODULE_HAVE_DLERROR', g_module_have_dlerror)
|
|
|
|
gmoduleconf_conf.set('G_MODULE_NEED_USCORE', g_module_need_uscore)
|
|
|
|
gmoduleconf_conf.set('G_MODULE_BROKEN_RTLD_GLOBAL', g_module_broken_rtld_global)
|
|
|
|
|
|
|
|
gmoduleconf_h = configure_file(input : 'gmoduleconf.h.in',
|
|
|
|
output : 'gmoduleconf.h',
|
|
|
|
configuration : gmoduleconf_conf)
|
|
|
|
|
2016-12-09 20:30:22 +01:00
|
|
|
install_headers(['gmodule.h'], subdir : 'glib-2.0')
|
2016-03-07 12:13:24 +01:00
|
|
|
|
2017-12-14 13:32:56 +01:00
|
|
|
gmodule_sources = ['gmodule.c']
|
|
|
|
if host_system == 'windows'
|
|
|
|
gmodule_win_rc = configure_file(
|
|
|
|
input: 'gmodule.rc.in',
|
|
|
|
output: 'gmodule.rc',
|
|
|
|
configuration: glibconfig_conf,
|
|
|
|
)
|
|
|
|
gmodule_win_res = windows.compile_resources(gmodule_win_rc)
|
|
|
|
gmodule_sources += [gmodule_win_res]
|
|
|
|
endif
|
|
|
|
|
2017-07-16 16:41:02 +02:00
|
|
|
libgmodule = library('gmodule-2.0',
|
2017-12-14 13:32:56 +01:00
|
|
|
sources : gmodule_sources,
|
2016-12-20 23:37:24 +01:00
|
|
|
version : library_version,
|
|
|
|
soversion : soversion,
|
2016-03-07 12:13:24 +01:00
|
|
|
install : true,
|
2016-12-20 23:37:24 +01:00
|
|
|
include_directories : [configinc, gmoduleinc],
|
|
|
|
dependencies : [libdl_dep, libglib_dep],
|
2018-05-01 15:44:19 +02:00
|
|
|
c_args : ['-DG_LOG_DOMAIN="GModule"', '-DG_DISABLE_DEPRECATED'] + glib_hidden_visibility_args,
|
|
|
|
link_args : [glib_link_flags],
|
|
|
|
)
|
2016-12-20 23:37:24 +01:00
|
|
|
|
2017-12-11 20:47:04 +01:00
|
|
|
supported_var = 'gmodule_supported=@0@'.format(g_module_impl != '0')
|
|
|
|
|
|
|
|
pkg.generate(libraries : [libgmodule, thread_dep],
|
|
|
|
requires : ['glib-2.0'],
|
|
|
|
version : glib_version,
|
|
|
|
variables : [supported_var],
|
|
|
|
install_dir : glib_pkgconfigreldir,
|
|
|
|
filebase : 'gmodule-no-export-2.0',
|
|
|
|
name : 'GModule',
|
|
|
|
description : 'Dynamic module loader for GLib',
|
|
|
|
)
|
|
|
|
|
|
|
|
pkg.generate(libraries : [libgmodule],
|
|
|
|
requires : ['glib-2.0'],
|
|
|
|
version : glib_version,
|
|
|
|
variables : [supported_var],
|
|
|
|
install_dir : glib_pkgconfigreldir,
|
|
|
|
filebase : 'gmodule-export-2.0',
|
|
|
|
name : 'GModule',
|
|
|
|
description : 'Dynamic module loader for GLib',
|
|
|
|
)
|
|
|
|
|
|
|
|
pkg.generate(libraries : [libgmodule],
|
|
|
|
requires : ['glib-2.0'],
|
|
|
|
version : glib_version,
|
|
|
|
variables : [supported_var],
|
|
|
|
install_dir : glib_pkgconfigreldir,
|
|
|
|
filebase : 'gmodule-2.0',
|
|
|
|
name : 'GModule',
|
|
|
|
description : 'Dynamic module loader for GLib',
|
|
|
|
)
|
|
|
|
|
2016-12-20 23:37:24 +01:00
|
|
|
libgmodule_dep = declare_dependency(link_with : libgmodule,
|
|
|
|
include_directories : gmoduleinc)
|