Merge branch 'GVariant-bytestring-docs' into 'master'
[glib.git] / gmodule / meson.build
blob8bb61897bdfaa0e338e8f7a19cb3ad204d3f9ba9
1 gmoduleconf_conf = configuration_data()
3 g_module_need_uscore = 0
4 g_module_broken_rtld_global = 0
5 g_module_have_dlerror = 0
7 libdl_dep = [ ]
8 g_module_lib_args = [ ]
9 g_module_impl = ''
11 dlopen_dlsym_test_code = '''
12 #include <dlfcn.h>
13 int glib_underscore_test (void) { return 42; }
14 int main (int argc, char ** argv) {
15   void *f1 = (void*)0, *f2 = (void*)0, *handle;
16   handle = dlopen ((void*)0, 0);
17   if (handle) {
18     f1 = dlsym (handle, "glib_underscore_test");
19     f2 = dlsym (handle, "_glib_underscore_test");
20   }
21   return (!f2 || f1);
22 }'''
24 # On Windows force native WIN32 shared lib loader
25 if host_system == 'windows'
26   g_module_impl = 'G_MODULE_IMPL_WIN32'
27 # Force native AIX library loader
28 # dlopen() filepath must be of the form /path/libname.a(libname.so)
29 elif host_system == 'aix'
30   g_module_impl = 'G_MODULE_IMPL_AR'
31 elif cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
32   g_module_impl = 'G_MODULE_IMPL_DL'
33 # NSLinkModule (dyld) in system libraries (Darwin)
34 elif cc.has_function('NSLinkModule')
35   g_module_impl = 'G_MODULE_IMPL_DYLD'
36   g_module_need_uscore = 1
37 elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
38   g_module_impl = 'G_MODULE_IMPL_DL'
39   libdl_dep = cc.find_library('dl')
40   g_module_lib_args = '-ldl'
41 endif
43 # additional checks for G_MODULE_IMPL_DL
44 if g_module_impl == 'G_MODULE_IMPL_DL'
45   # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
47   # Check whether we need preceding underscores
48   if cc.get_id() == 'msvc'
49     message('Building for MSVC: assuming that symbols are prefixed with underscore')
50     g_module_need_uscore = 1
51   elif meson.has_exe_wrapper()
52     # FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold red
53     rres = cc.run(dlopen_dlsym_test_code,
54                   args : g_module_lib_args,
55                   name : 'dlsym() preceding underscores')
56     if host_system == 'windows' or rres.returncode() == 0
57       g_module_need_uscore = 1
58     endif
59   else
60     message('Cross-compiling: assuming that symbols aren\'t prefixed with underscore')
61     g_module_need_uscore = 0
62   endif
64   if cc.has_function('dlerror', args : g_module_lib_args)
65     g_module_have_dlerror = 1
66   endif
67 endif
69 # Done, have we got an implementation?
70 if g_module_impl == ''
71   g_module_impl = '0'
72   message('WARNING: No suitable GModule implementation found!')
73 endif
75 gmoduleconf_conf.set('G_MODULE_IMPL', g_module_impl)
76 gmoduleconf_conf.set('G_MODULE_SUPPORTED', g_module_impl != '0')
77 gmoduleconf_conf.set('G_MODULE_HAVE_DLERROR', g_module_have_dlerror)
78 gmoduleconf_conf.set('G_MODULE_NEED_USCORE', g_module_need_uscore)
79 gmoduleconf_conf.set('G_MODULE_BROKEN_RTLD_GLOBAL', g_module_broken_rtld_global)
81 gmoduleconf_h = configure_file(input : 'gmoduleconf.h.in',
82                                output : 'gmoduleconf.h',
83                                configuration : gmoduleconf_conf)
85 install_headers(['gmodule.h'], subdir : 'glib-2.0')
87 gmodule_sources = ['gmodule.c']
88 if host_system == 'windows'
89   gmodule_win_rc = configure_file(
90     input: 'gmodule.rc.in',
91     output: 'gmodule.rc',
92     configuration: glibconfig_conf,
93   )
94   gmodule_win_res = windows.compile_resources(gmodule_win_rc)
95   gmodule_sources += [gmodule_win_res]
96 endif
98 libgmodule = library('gmodule-2.0',
99   sources : gmodule_sources,
100   version : library_version,
101   soversion : soversion,
102   install : true,
103   include_directories : [configinc, gmoduleinc],
104   dependencies : [libdl_dep, libglib_dep],
105   c_args : ['-DG_LOG_DOMAIN="GModule"', '-DG_DISABLE_DEPRECATED'] + glib_hidden_visibility_args,
106   link_args : [glib_link_flags],
109 supported_var = 'gmodule_supported=@0@'.format(g_module_impl != '0')
111 pkg.generate(libraries : [libgmodule, thread_dep],
112   requires : ['glib-2.0'],
113   version : glib_version,
114   variables : [supported_var],
115   install_dir : glib_pkgconfigreldir,
116   filebase : 'gmodule-no-export-2.0',
117   name : 'GModule',
118   description : 'Dynamic module loader for GLib',
121 pkg.generate(libraries : [libgmodule, export_dynamic_ldflags],
122   requires : ['glib-2.0'],
123   version : glib_version,
124   variables : [supported_var],
125   install_dir : glib_pkgconfigreldir,
126   filebase : 'gmodule-export-2.0',
127   name : 'GModule',
128   description : 'Dynamic module loader for GLib',
131 pkg.generate(libraries : [libgmodule, export_dynamic_ldflags],
132   requires : ['glib-2.0'],
133   version : glib_version,
134   variables : [supported_var],
135   install_dir : glib_pkgconfigreldir,
136   filebase : 'gmodule-2.0',
137   name : 'GModule',
138   description : 'Dynamic module loader for GLib',
141 libgmodule_dep = declare_dependency(link_with : libgmodule,
142   include_directories : gmoduleinc)