Fix getauxval error at qemu
[platform/upstream/glib.git] / glib / meson.build
1 glib_sources = []
2 glib_sub_includedir = glib_includedir / 'glib'
3
4 glibconfig_h = configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
5   install_dir : join_paths(get_option('libdir'), 'glib-2.0/include'),
6   install_tag : 'devel',
7   configuration : glibconfig_conf)
8 glib_sources += glibconfig_h
9
10 gversionmacros_h = custom_target(
11   input: 'gversionmacros.h.in',
12   output: 'gversionmacros.h',
13   command: [gen_visibility_macros, meson.project_version(), 'versions-macros', '@INPUT@', '@OUTPUT@'],
14   install: true,
15   install_dir: glib_sub_includedir,
16   # FIXME: Not needed with Meson >= 0.64.0
17   install_tag: 'devel',
18 )
19
20 glib_visibility_h = custom_target(
21   output: 'glib-visibility.h',
22   command: [gen_visibility_macros, meson.project_version(), 'visibility-macros', 'GLIB', '@OUTPUT@'],
23   install: true,
24   install_dir: glib_sub_includedir,
25   # FIXME: Not needed with Meson >= 0.64.0
26   install_tag: 'devel',
27 )
28
29 glib_built_headers = [gversionmacros_h, glib_visibility_h]
30 glib_sources += glib_built_headers
31 glib_c_args_internal = [
32   '-DGLIB_COMPILATION',
33 ]
34
35 subdir('libcharset')
36
37 # libsysprof-capture support
38 libsysprof_capture_dep = dependency('sysprof-capture-4', version: '>= 3.38.0',
39   required: get_option('sysprof'),
40   default_options: [
41     'examples=false',
42     'gtk=false',
43     'tests=false',
44     'tools=false',
45     'libsysprof=false',
46     'sysprofd=none',
47     'help=false',
48   ],
49   fallback: ['sysprof', 'libsysprof_capture_dep'],
50 )
51 glib_conf.set('HAVE_SYSPROF', libsysprof_capture_dep.found())
52
53 if use_system_printf
54   gnulib_lib = []
55   gnulib_libm_dependency = []
56   glib_conf.set ('gl_unused', '')
57   glib_conf.set ('gl_extern_inline', '')
58 else
59   subdir ('gnulib/gl_extern_inline')
60   subdir ('gnulib/gl_cv_long_double_equals_double')
61   subdir ('gnulib/gl_cv_cc_double_expbit0')
62   subdir ('gnulib/gl_cv_func_printf_precision')
63   subdir ('gnulib/gl_cv_func_printf_enomem')
64   subdir ('gnulib/gl_cv_func_printf_flag_zero')
65   subdir ('gnulib/gl_cv_func_printf_flag_leftadjust')
66   subdir ('gnulib/gl_cv_func_printf_flag_grouping')
67   subdir ('gnulib/gl_cv_func_printf_directive_a')
68   subdir ('gnulib/gl_cv_func_printf_directive_f')
69   subdir ('gnulib/gl_cv_func_printf_directive_ls')
70   subdir ('gnulib/gl_cv_func_printf_long_double')
71   subdir ('gnulib/gl_cv_func_printf_infinite')
72   subdir ('gnulib/gl_cv_func_printf_infinite_long_double')
73
74   gl_unused = '''
75 /* Define as a marker that can be attached to declarations that might not
76     be used.  This helps to reduce warnings, such as from
77     GCC -Wunused-parameter.  */
78 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
79 # define _GL_UNUSED __attribute__ ((__unused__))
80 #else
81 # define _GL_UNUSED
82 #endif
83 '''
84   glib_conf.set ('gl_unused', gl_unused)
85   glib_conf.set ('gl_extern_inline', gl_extern_inline)
86
87   if (gl_cv_long_double_equals_double)
88     glib_conf.set ('HAVE_SAME_LONG_DOUBLE_AS_DOUBLE', 1)
89   endif
90
91   if (gl_cv_cc_double_expbit0_word >= 0 and
92       gl_cv_cc_double_expbit0_bit >= 0)
93     glib_conf.set('DBL_EXPBIT0_WORD', gl_cv_cc_double_expbit0_word)
94     glib_conf.set('DBL_EXPBIT0_BIT', gl_cv_cc_double_expbit0_bit)
95   endif
96
97   if not gl_cv_func_printf_precision
98     glib_conf.set('NEED_PRINTF_UNBOUNDED_PRECISION', 1)
99   endif
100
101   if not gl_cv_func_printf_enomem
102     glib_conf.set('NEED_PRINTF_ENOMEM', 1)
103   endif
104
105   if not gl_cv_func_printf_flag_leftadjust
106     glib_conf.set('NEED_PRINTF_FLAG_LEFTADJUST', 1)
107   endif
108
109   if not gl_cv_func_printf_flag_zero
110     glib_conf.set('NEED_PRINTF_FLAG_ZERO', 1)
111   endif
112
113   if not gl_cv_func_printf_flag_grouping
114     glib_conf.set('NEED_PRINTF_FLAG_GROUPING', 1)
115   endif
116
117   if not gl_cv_func_printf_directive_a
118     glib_conf.set('NEED_PRINTF_DIRECTIVE_A', 1)
119   endif
120
121   if not gl_cv_func_printf_directive_f
122     glib_conf.set('NEED_PRINTF_DIRECTIVE_F', 1)
123   endif
124
125   if not gl_cv_func_printf_directive_ls
126     glib_conf.set('NEED_PRINTF_DIRECTIVE_LS', 1)
127   endif
128
129   if (not gl_cv_func_printf_precision or
130       not gl_cv_func_printf_enomem)
131     glib_conf.set('NEED_PRINTF_DOUBLE', 1)
132     glib_conf.set('NEED_PRINTF_LONG_DOUBLE', 1)
133   endif
134
135   if not gl_cv_func_printf_infinite
136     glib_conf.set('NEED_PRINTF_INFINITE_DOUBLE', 1)
137   endif
138
139   if gl_cv_func_printf_long_double and gl_cv_func_printf_infinite_long_double
140     glib_conf.set('NEED_PRINTF_INFINITE_LONG_DOUBLE', 1)
141   endif
142
143   subdir('gnulib')
144 endif
145
146 glib_headers = files(
147   'glib.h',
148   'glib-unix.h',
149   'glib-object.h',
150 )
151 install_headers(glib_headers, install_dir : glib_includedir)
152
153 if host_system == 'windows'
154   install_headers([ 'msvc_recommended_pragmas.h' ], install_dir : glib_includedir)
155 endif
156
157 # Expose as variable to be used by gobject-introspection
158 # when it includes GLib as a subproject
159 glib_unix_h = files('glib-unix.h')
160
161 glib_deprecated_headers = files(
162   'deprecated/gallocator.h',
163   'deprecated/gcache.h',
164   'deprecated/gcompletion.h',
165   'deprecated/gmain.h',
166   'deprecated/grel.h',
167   'deprecated/gthread.h',
168 )
169 install_headers(glib_deprecated_headers,
170   install_dir : glib_sub_includedir / 'deprecated')
171
172 glib_sub_headers = files(
173   'glib-autocleanups.h',
174   'glib-typeof.h',
175   'galloca.h',
176   'garray.h',
177   'gasyncqueue.h',
178   'gatomic.h',
179   'gbacktrace.h',
180   'gbase64.h',
181   'gbitlock.h',
182   'gbookmarkfile.h',
183   'gbytes.h',
184   'gcharset.h',
185   'gchecksum.h',
186   'gconvert.h',
187   'gdataset.h',
188   'gdate.h',
189   'gdatetime.h',
190   'gdir.h',
191   'genviron.h',
192   'gerror.h',
193   'gfileutils.h',
194   'ggettext.h',
195   'ghash.h',
196   'ghmac.h',
197   'ghook.h',
198   'ghostutils.h',
199   'gi18n.h',
200   'gi18n-lib.h',
201   'giochannel.h',
202   'gkeyfile.h',
203   'glist.h',
204   'gmacros.h',
205   'gmain.h',
206   'gmappedfile.h',
207   'gmarkup.h',
208   'gmem.h',
209   'gmessages.h',
210   'gnode.h',
211   'goption.h',
212   'gpathbuf.h',
213   'gpattern.h',
214   'gpoll.h',
215   'gprimes.h',
216   'gqsort.h',
217   'gquark.h',
218   'gqueue.h',
219   'grand.h',
220   'grcbox.h',
221   'grefcount.h',
222   'grefstring.h',
223   'gregex.h',
224   'gscanner.h',
225   'gsequence.h',
226   'gshell.h',
227   'gslice.h',
228   'gslist.h',
229   'gspawn.h',
230   'gstdio.h',
231   'gstrfuncs.h',
232   'gstrvbuilder.h',
233   'gtestutils.h',
234   'gstring.h',
235   'gstringchunk.h',
236   'gthread.h',
237   'gthreadpool.h',
238   'gtimer.h',
239   'gtimezone.h',
240   'gtrashstack.h',
241   'gtree.h',
242   'gtypes.h',
243   'guuid.h',
244   'gunicode.h',
245   'guri.h',
246   'gutils.h',
247   'gvarianttype.h',
248   'gvariant.h',
249   'gversion.h',
250   'gwin32.h',
251   'gprintf.h',
252 )
253
254 install_headers(glib_sub_headers, install_dir : glib_sub_includedir)
255
256 deprecated_sources = files(
257   'deprecated/gallocator.c',
258   'deprecated/gcache.c',
259   'deprecated/gcompletion.c',
260   'deprecated/grel.c',
261   'deprecated/gthread-deprecated.c'
262 )
263
264 glib_sources += files(
265   'garcbox.c',
266   'garray.c',
267   'gasyncqueue.c',
268   'gatomic.c',
269   'gbacktrace.c',
270   'gbase64.c',
271   'gbitlock.c',
272   'gbookmarkfile.c',
273   'gbytes.c',
274   'gcharset.c',
275   'gchecksum.c',
276   'gconvert.c',
277   'gdataset.c',
278   'gdate.c',
279   'gdatetime.c',
280   'gdir.c',
281   'genviron.c',
282   'gerror.c',
283   'gfileutils.c',
284   'ggettext.c',
285   'ghash.c',
286   'ghmac.c',
287   'ghook.c',
288   'ghostutils.c',
289   'giochannel.c',
290   'gkeyfile.c',
291   'glib-init.c',
292   'glib-private.c',
293   'glist.c',
294   'gmain.c',
295   'gmappedfile.c',
296   'gmarkup.c',
297   'gmem.c',
298   'gmessages.c',
299   'gnode.c',
300   'goption.c',
301   'gpathbuf.c',
302   'gpattern.c',
303   'gpoll.c',
304   'gprimes.c',
305   'gqsort.c',
306   'gquark.c',
307   'gqueue.c',
308   'grand.c',
309   'grcbox.c',
310   'grefcount.c',
311   'grefstring.c',
312   'gregex.c',
313   'gscanner.c',
314   'gsequence.c',
315   'gshell.c',
316   'gslice.c',
317   'gslist.c',
318   'gstdio.c',
319   'gstrfuncs.c',
320   'gstring.c',
321   'gstringchunk.c',
322   'gstrvbuilder.c',
323   'gtestutils.c',
324   'gthread.c',
325   'gthreadpool.c',
326   'gtimer.c',
327   'gtimezone.c',
328   'gtrace.c',
329   'gtrace-private.h',
330   'gtranslit.c',
331   'gtrashstack.c',
332   'gtree.c',
333   'guniprop.c',
334   'gutf8.c',
335   'gunibreak.c',
336   'gunicollate.c',
337   'gunidecomp.c',
338   'guri.c',
339   'guriprivate.h',
340   'gutils.c',
341   'gutilsprivate.h',
342   'guuid.c',
343   'gvariant.c',
344   'gvariant-core.c',
345   'gvariant-parser.c',
346   'gvariant-serialiser.c',
347   'gvarianttypeinfo.c',
348   'gvarianttype.c',
349   'gversion.c',
350   'gwakeup.c',
351   'gprintf.c',
352 )
353
354 platform_deps = []
355
356 if host_system == 'windows'
357   if glib_build_shared
358     glib_win_rc = configure_file(
359       input: 'glib.rc.in',
360       output: 'glib.rc',
361       configuration: glibconfig_conf,
362     )
363     glib_win_res = windows.compile_resources(glib_win_rc)
364     glib_sources += [glib_win_res]
365   endif
366   glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
367   platform_deps = [winsock2, cc.find_library('winmm')]
368   if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
369     glib_sources += files('dirent/wdirent.c')
370   endif
371 else
372   glib_sources += files('glib-unix.c', 'glib-unixprivate.h', 'gspawn.c', 'giounix.c')
373   platform_deps = []
374 endif
375
376 if host_system == 'linux'
377   glib_sources += files('gjournal-private.c')
378 endif
379
380 if glib_have_cocoa
381   glib_sources += files('gosxutils.m')
382   framework_dep = dependency('appleframeworks', modules : ['Foundation', 'CoreFoundation', 'AppKit'])
383   platform_deps += [framework_dep]
384 endif
385
386 if glib_have_carbon
387   framework_dep = dependency('appleframeworks', modules : 'Carbon')
388   platform_deps += [framework_dep]
389 endif
390
391 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
392
393 if enable_dtrace
394   glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
395   glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
396 else
397   glib_dtrace_obj = []
398   glib_dtrace_hdr = []
399 endif
400
401 pcre2_static_args = []
402
403 if use_pcre2_static_flag
404   pcre2_static_args = ['-DPCRE2_STATIC']
405 endif
406
407 glib_c_args = ['-DG_LOG_DOMAIN="GLib"'] + glib_c_args_internal + pcre2_static_args
408 libglib = library('glib-2.0',
409   glib_dtrace_obj, glib_dtrace_hdr,
410   sources : [deprecated_sources, glib_sources],
411   version : library_version,
412   soversion : soversion,
413   darwin_versions : darwin_versions,
414   install : true,
415   # intl.lib is not compatible with SAFESEH
416   link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
417   include_directories : configinc,
418   link_with: [charset_lib, gnulib_lib],
419   dependencies : [
420     gnulib_libm_dependency,
421     libiconv,
422     libintl_deps,
423     libm,
424     librt,
425     libsysprof_capture_dep,
426     pcre2,
427     platform_deps,
428     thread_dep,
429   ],
430   c_args : glib_c_args,
431   objc_args : glib_c_args,
432   gnu_symbol_visibility : 'hidden',
433 )
434
435 libglib_dep = declare_dependency(
436   link_with : libglib,
437   dependencies : libintl_deps,
438   sources : glib_built_headers,
439   # We sadly need to export configinc here because everyone includes <glib/*.h>
440   include_directories : [configinc, glibinc])
441
442 pkg.generate(libglib,
443   libraries : [libintl_deps],
444   libraries_private : [win32_ldflags],
445   subdirs : ['glib-2.0'],
446   extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
447   variables : [
448     'bindir=' + '${prefix}' / get_option('bindir'),
449     'datadir=' + '${prefix}' / get_option('datadir'),
450     'glib_genmarshal=' + '${bindir}' / 'glib-genmarshal',
451     'gobject_query=' + '${bindir}' / 'gobject-query',
452     'glib_mkenums=' + '${bindir}' / 'glib-mkenums',
453     'glib_valgrind_suppressions=' + '${datadir}' /
454       valgrind_suppression_file_install_subdir /
455       fs.name(valgrind_suppression_file),
456   ],
457   version : glib_version,
458   install_dir : glib_pkgconfigreldir,
459   filebase : 'glib-2.0',
460   name : 'GLib',
461   description : 'C Utility Library',
462 )
463 meson.override_dependency('glib-2.0', libglib_dep)
464
465 # On Windows, glib needs a spawn helper for g_spawn* API
466 if host_system == 'windows'
467   if host_machine.cpu_family() == 'x86'
468     executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
469       install : true,
470       win_subsystem : 'windows',
471       include_directories : configinc,
472       dependencies : [libglib_dep])
473     executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
474       install : true,
475       c_args : ['-DHELPER_CONSOLE'],
476       include_directories : configinc,
477       dependencies : [libglib_dep])
478   else
479     executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
480       install : true,
481       win_subsystem : 'windows',
482       include_directories : configinc,
483       dependencies : [libglib_dep])
484     executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
485       install : true,
486       c_args : ['-DHELPER_CONSOLE'],
487       include_directories : configinc,
488       dependencies : [libglib_dep])
489   endif
490 else
491   gtester = executable('gtester', 'gtester.c',
492     install : true,
493     install_tag : 'bin-devel',
494     c_args : ['-UG_DISABLE_ASSERT'],
495     include_directories : configinc,
496     dependencies : [libglib_dep])
497
498   # Provide tools for others when we're a subproject and they use the Meson GNOME module
499   meson.override_find_program('gtester', gtester)
500 endif
501
502 report_conf = configuration_data()
503 report_conf.set('GLIB_VERSION', glib_version)
504 report_conf.set('PYTHON', python_name)
505 configure_file(
506   input: 'gtester-report.in',
507   output: 'gtester-report',
508   install_dir: get_option('bindir'),
509   install_tag : 'bin-devel',
510   configuration: report_conf,
511   install_mode: 'rwxr-xr-x'
512 )
513
514 install_data('glib_gdb.py',
515   install_dir : glib_pkgdatadir / 'gdb',
516   install_tag : 'devel',
517 )
518
519 # This is needed to make gdb find glib_gdb.py
520 env = environment()
521 env.prepend('PYTHONPATH', meson.current_source_dir())
522 meson.add_devenv(env)
523
524 gdb_conf = configuration_data()
525 gdb_conf.set('datadir', glib_datadir)
526 # This is also used in gobject/meson.build
527 if host_system != 'windows'
528   gdb_install = true
529 else
530   # FIXME: Cannot install on Windows because the path will contain a drive
531   # letter and colons are not allowed in paths.
532   gdb_install = false
533 endif
534
535 # XXX: We add a leading './' because glib_libdir is an absolute path and we
536 # need it to be a relative path so that join_paths appends it to the end.
537 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
538
539 configure_file(
540   input: 'libglib-gdb.py.in',
541   output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
542   configuration: gdb_conf,
543   install_dir: gdb_install_dir,
544   install_tag: 'devel',
545   install: gdb_install,
546 )
547
548 if enable_systemtap
549   glib_stp = configure_file(input : 'glib.stp.in',
550     output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
551     configuration : stp_cdata,
552     install_dir : tapset_install_dir,
553     install_tag : 'systemtap',
554   )
555 endif
556
557 if build_tests
558   subdir('tests')
559 endif