• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
2  install_dir : join_paths(get_option('libdir'), 'glib-2.0/include'),
3  configuration : glibconfig_conf)
4
5subdir('libcharset')
6if not use_system_pcre
7  subdir('pcre')
8endif
9
10# TODO: gnulib_objects, pcre_objects and pcre_deps are a workaround for
11# <https://github.com/mesonbuild/meson/issues/3934> and
12# <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
13# on a meson version where those are fixed, revert the commit that
14# introduced this workaround.
15if use_system_printf
16  gnulib_lib = []
17  gnulib_objects = []
18  gnulib_libm_dependency = []
19  glib_conf.set ('gl_unused', '')
20  glib_conf.set ('gl_extern_inline', '')
21else
22  subdir ('gnulib/gl_extern_inline')
23  subdir ('gnulib/gl_cv_long_double_equals_double')
24  subdir ('gnulib/gl_cv_cc_double_expbit0')
25  subdir ('gnulib/gl_cv_func_printf_precision')
26  subdir ('gnulib/gl_cv_func_printf_enomem')
27  subdir ('gnulib/gl_cv_func_printf_flag_zero')
28  subdir ('gnulib/gl_cv_func_printf_flag_leftadjust')
29  subdir ('gnulib/gl_cv_func_printf_flag_grouping')
30  subdir ('gnulib/gl_cv_func_printf_directive_a')
31  subdir ('gnulib/gl_cv_func_printf_directive_f')
32  subdir ('gnulib/gl_cv_func_printf_directive_ls')
33  subdir ('gnulib/gl_cv_func_printf_long_double')
34  subdir ('gnulib/gl_cv_func_printf_infinite')
35  subdir ('gnulib/gl_cv_func_printf_infinite_long_double')
36
37  gl_unused = '''
38/* Define as a marker that can be attached to declarations that might not
39    be used.  This helps to reduce warnings, such as from
40    GCC -Wunused-parameter.  */
41#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
42# define _GL_UNUSED __attribute__ ((__unused__))
43#else
44# define _GL_UNUSED
45#endif
46'''
47  glib_conf.set ('gl_unused', gl_unused)
48  glib_conf.set ('gl_extern_inline', gl_extern_inline)
49
50  if (gl_cv_long_double_equals_double)
51    glib_conf.set ('HAVE_SAME_LONG_DOUBLE_AS_DOUBLE', 1)
52  endif
53
54  if (gl_cv_cc_double_expbit0_word >= 0 and
55      gl_cv_cc_double_expbit0_bit >= 0)
56    glib_conf.set('DBL_EXPBIT0_WORD', gl_cv_cc_double_expbit0_word)
57    glib_conf.set('DBL_EXPBIT0_BIT', gl_cv_cc_double_expbit0_bit)
58  endif
59
60  if not gl_cv_func_printf_precision
61    glib_conf.set('NEED_PRINTF_UNBOUNDED_PRECISION', 1)
62  endif
63
64  if not gl_cv_func_printf_enomem
65    glib_conf.set('NEED_PRINTF_ENOMEM', 1)
66  endif
67
68  if not gl_cv_func_printf_flag_leftadjust
69    glib_conf.set('NEED_PRINTF_FLAG_LEFTADJUST', 1)
70  endif
71
72  if not gl_cv_func_printf_flag_zero
73    glib_conf.set('NEED_PRINTF_FLAG_ZERO', 1)
74  endif
75
76  if not gl_cv_func_printf_flag_grouping
77    glib_conf.set('NEED_PRINTF_FLAG_GROUPING', 1)
78  endif
79
80  if not gl_cv_func_printf_directive_a
81    glib_conf.set('NEED_PRINTF_DIRECTIVE_A', 1)
82  endif
83
84  if not gl_cv_func_printf_directive_f
85    glib_conf.set('NEED_PRINTF_DIRECTIVE_F', 1)
86  endif
87
88  if not gl_cv_func_printf_directive_ls
89    glib_conf.set('NEED_PRINTF_DIRECTIVE_LS', 1)
90  endif
91
92  if (not gl_cv_func_printf_precision or
93      not gl_cv_func_printf_enomem)
94    glib_conf.set('NEED_PRINTF_DOUBLE', 1)
95    glib_conf.set('NEED_PRINTF_LONG_DOUBLE', 1)
96  endif
97
98  if not gl_cv_func_printf_infinite
99    glib_conf.set('NEED_PRINTF_INFINITE_DOUBLE', 1)
100  endif
101
102  if gl_cv_func_printf_long_double and gl_cv_func_printf_infinite_long_double != 'false'
103    glib_conf.set('NEED_PRINTF_INFINITE_LONG_DOUBLE', 1)
104  endif
105
106  subdir('gnulib')
107  gnulib_objects = [gnulib_lib.extract_all_objects()]
108endif
109
110glib_headers = files(
111  'glib.h',
112  'glib-unix.h',
113  'glib-object.h',
114)
115install_headers(glib_headers, subdir : 'glib-2.0')
116
117glib_deprecated_headers = files(
118  'deprecated/gallocator.h',
119  'deprecated/gcache.h',
120  'deprecated/gcompletion.h',
121  'deprecated/gmain.h',
122  'deprecated/grel.h',
123  'deprecated/gthread.h',
124)
125install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')
126
127glib_sub_headers = files(
128  'glib-autocleanups.h',
129  'galloca.h',
130  'garray.h',
131  'gasyncqueue.h',
132  'gatomic.h',
133  'gbacktrace.h',
134  'gbase64.h',
135  'gbitlock.h',
136  'gbookmarkfile.h',
137  'gbytes.h',
138  'gcharset.h',
139  'gchecksum.h',
140  'gconvert.h',
141  'gdataset.h',
142  'gdate.h',
143  'gdatetime.h',
144  'gdir.h',
145  'genviron.h',
146  'gerror.h',
147  'gfileutils.h',
148  'ggettext.h',
149  'ghash.h',
150  'ghmac.h',
151  'ghook.h',
152  'ghostutils.h',
153  'gi18n.h',
154  'gi18n-lib.h',
155  'giochannel.h',
156  'gkeyfile.h',
157  'glist.h',
158  'gmacros.h',
159  'gmain.h',
160  'gmappedfile.h',
161  'gmarkup.h',
162  'gmem.h',
163  'gmessages.h',
164  'gnode.h',
165  'goption.h',
166  'gpattern.h',
167  'gpoll.h',
168  'gprimes.h',
169  'gqsort.h',
170  'gquark.h',
171  'gqueue.h',
172  'grand.h',
173  'grcbox.h',
174  'grefcount.h',
175  'grefstring.h',
176  'gregex.h',
177  'gscanner.h',
178  'gsequence.h',
179  'gshell.h',
180  'gslice.h',
181  'gslist.h',
182  'gspawn.h',
183  'gstdio.h',
184  'gstrfuncs.h',
185  'gtestutils.h',
186  'gstring.h',
187  'gstringchunk.h',
188  'gthread.h',
189  'gthreadpool.h',
190  'gtimer.h',
191  'gtimezone.h',
192  'gtrashstack.h',
193  'gtree.h',
194  'gtypes.h',
195  'guuid.h',
196  'gunicode.h',
197  'gurifuncs.h',
198  'gutils.h',
199  'gvarianttype.h',
200  'gvariant.h',
201  'gversion.h',
202  'gversionmacros.h',
203  'gwin32.h',
204  'gprintf.h',
205)
206install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
207
208deprecated_sources = files(
209  'deprecated/gallocator.c',
210  'deprecated/gcache.c',
211  'deprecated/gcompletion.c',
212  'deprecated/grel.c',
213  'deprecated/gthread-deprecated.c'
214)
215
216glib_sources = files(
217  'garcbox.c',
218  'garray.c',
219  'gasyncqueue.c',
220  'gatomic.c',
221  'gbacktrace.c',
222  'gbase64.c',
223  'gbitlock.c',
224  'gbookmarkfile.c',
225  'gbytes.c',
226  'gcharset.c',
227  'gchecksum.c',
228  'gconvert.c',
229  'gdataset.c',
230  'gdate.c',
231  'gdatetime.c',
232  'gdir.c',
233  'genviron.c',
234  'gerror.c',
235  'gfileutils.c',
236  'ggettext.c',
237  'ghash.c',
238  'ghmac.c',
239  'ghook.c',
240  'ghostutils.c',
241  'giochannel.c',
242  'gkeyfile.c',
243  'glib-init.c',
244  'glib-private.c',
245  'glist.c',
246  'gmain.c',
247  'gmappedfile.c',
248  'gmarkup.c',
249  'gmem.c',
250  'gmessages.c',
251  'gnode.c',
252  'goption.c',
253  'gpattern.c',
254  'gpoll.c',
255  'gprimes.c',
256  'gqsort.c',
257  'gquark.c',
258  'gqueue.c',
259  'grand.c',
260  'grcbox.c',
261  'grefcount.c',
262  'grefstring.c',
263  'gregex.c',
264  'gscanner.c',
265  'gsequence.c',
266  'gshell.c',
267  'gslice.c',
268  'gslist.c',
269  'gstdio.c',
270  'gstrfuncs.c',
271  'gstring.c',
272  'gstringchunk.c',
273  'gtestutils.c',
274  'gthread.c',
275  'gthreadpool.c',
276  'gtimer.c',
277  'gtimezone.c',
278  'gtranslit.c',
279  'gtrashstack.c',
280  'gtree.c',
281  'guniprop.c',
282  'gutf8.c',
283  'gunibreak.c',
284  'gunicollate.c',
285  'gunidecomp.c',
286  'gurifuncs.c',
287  'gutils.c',
288  'gutilsprivate.h',
289  'guuid.c',
290  'gvariant.c',
291  'gvariant-core.c',
292  'gvariant-parser.c',
293  'gvariant-serialiser.c',
294  'gvarianttypeinfo.c',
295  'gvarianttype.c',
296  'gversion.c',
297  'gwakeup.c',
298  'gprintf.c',
299)
300
301if host_system == 'windows'
302  glib_win_rc = configure_file(
303    input: 'glib.rc.in',
304    output: 'glib.rc',
305    configuration: glibconfig_conf,
306  )
307  glib_win_res = windows.compile_resources(glib_win_rc)
308  glib_sources += [glib_win_res]
309  glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
310  platform_deps = [winsock2, cc.find_library('winmm')]
311  if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
312    glib_sources += files('dirent/wdirent.c')
313  endif
314else
315  glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
316  platform_deps = []
317endif
318
319if host_system == 'darwin'
320  glib_sources += files('gosxutils.m')
321endif
322
323glib_sources += files('gthread-@0@.c'.format(threads_implementation))
324
325if enable_dtrace
326  glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
327  glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
328else
329  glib_dtrace_obj = []
330  glib_dtrace_hdr = []
331endif
332
333pcre_static_args = []
334
335if use_pcre_static_flag
336  pcre_static_args = ['-DPCRE_STATIC']
337endif
338
339if use_system_pcre
340  pcre_deps = [pcre]
341  pcre_objects = []
342else
343  pcre_deps = []
344  pcre_objects = [libpcre.extract_all_objects()]
345endif
346
347glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
348libglib = library('glib-2.0',
349  glib_dtrace_obj, glib_dtrace_hdr,
350  sources : [deprecated_sources, glib_sources],
351  objects : [charset_lib.extract_all_objects()] + gnulib_objects + pcre_objects,
352  version : library_version,
353  soversion : soversion,
354  darwin_versions : darwin_versions,
355  install : true,
356  # intl.lib is not compatible with SAFESEH
357  link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
358  include_directories : configinc,
359  dependencies : pcre_deps + [thread_dep, libintl, librt] + libiconv + platform_deps + gnulib_libm_dependency,
360  c_args : glib_c_args,
361  objc_args : glib_c_args,
362)
363
364libglib_dep = declare_dependency(
365  link_with : libglib,
366  # thread_dep doesn't get pulled in from libglib atm,
367  # see https://github.com/mesonbuild/meson/issues/1426
368  dependencies : [thread_dep, libintl],
369  # We sadly need to export configinc here because everyone includes <glib/*.h>
370  include_directories : [configinc, glibinc])
371
372pkg.generate(libglib,
373  libraries : [libintl],
374  libraries_private : [osx_ldflags, win32_ldflags],
375  subdirs : ['glib-2.0'],
376  extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
377  variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
378               'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
379               'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
380               'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
381  version : glib_version,
382  install_dir : glib_pkgconfigreldir,
383  filebase : 'glib-2.0',
384  name : 'GLib',
385  description : 'C Utility Library',
386)
387
388# On Windows, glib needs a spawn helper for g_spawn* API
389if host_system == 'windows'
390  if host_machine.cpu_family() == 'x86'
391    executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
392      install : true,
393      gui_app : true,
394      include_directories : configinc,
395      dependencies : [libglib_dep])
396    executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
397      install : true,
398      c_args : ['-DHELPER_CONSOLE'],
399      include_directories : configinc,
400      dependencies : [libglib_dep])
401  else
402    executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
403      install : true,
404      gui_app : true,
405      include_directories : configinc,
406      dependencies : [libglib_dep])
407    executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
408      install : true,
409      c_args : ['-DHELPER_CONSOLE'],
410      include_directories : configinc,
411      dependencies : [libglib_dep])
412  endif
413else
414  gtester = executable('gtester', 'gtester.c',
415    install : true,
416    c_args : ['-UG_DISABLE_ASSERT'],
417    include_directories : configinc,
418    dependencies : [libglib_dep])
419endif
420
421report_conf = configuration_data()
422report_conf.set('GLIB_VERSION', glib_version)
423report_conf.set('PYTHON', python_name)
424configure_file(
425  input: 'gtester-report.in',
426  output: 'gtester-report',
427  install_dir: get_option('bindir'),
428  configuration: report_conf,
429  install_mode: 'rwxr-xr-x'
430)
431
432install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
433
434gdb_conf = configuration_data()
435gdb_conf.set('datadir', glib_datadir)
436# This is also used in gobject/meson.build
437if host_system != 'windows'
438  # XXX: We add a leading './' because glib_libdir is an absolute path and we
439  # need it to be a relative path so that join_paths appends it to the end.
440  gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
441else
442  # FIXME: Cannot install on Windows because the path will contain a drive
443  # letter and colons are not allowed in paths.
444  gdb_install_dir = false
445endif
446configure_file(
447  input: 'libglib-gdb.py.in',
448  output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
449  configuration: gdb_conf,
450  install_dir: gdb_install_dir,
451)
452
453if enable_systemtap
454  glib_stp = configure_file(input : 'glib.stp.in',
455    output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
456    configuration : stp_cdata,
457    install_dir : tapset_install_dir,
458  )
459endif
460
461if build_tests
462  subdir('tests')
463endif
464