summaryrefslogtreecommitdiff
path: root/glib/meson.build
blob: 036d1f4d60726beb681338fcf5cfd2b24325f17e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
  install : true,
  install_dir : join_paths(get_option('libdir'), 'glib-2.0/include'),
  configuration : glibconfig_conf)

subdir('libcharset')
if not use_system_pcre
  subdir('pcre')
endif
if have_good_vsnprintf and have_good_snprintf
  gnulib_lib = []
else
  subdir('gnulib')
endif

glib_headers = files(
  'glib.h',
  'glib-unix.h',
  'glib-object.h',
)
install_headers(glib_headers, subdir : 'glib-2.0')

glib_deprecated_headers = files(
  'deprecated/gallocator.h',
  'deprecated/gcache.h',
  'deprecated/gcompletion.h',
  'deprecated/gmain.h',
  'deprecated/grel.h',
  'deprecated/gthread.h',
)
install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')

glib_sub_headers = files(
  'glib-autocleanups.h',
  'galloca.h',
  'garray.h',
  'gasyncqueue.h',
  'gatomic.h',
  'gbacktrace.h',
  'gbase64.h',
  'gbitlock.h',
  'gbookmarkfile.h',
  'gbytes.h',
  'gcharset.h',
  'gchecksum.h',
  'gconvert.h',
  'gdataset.h',
  'gdate.h',
  'gdatetime.h',
  'gdir.h',
  'genviron.h',
  'gerror.h',
  'gfileutils.h',
  'ggettext.h',
  'ghash.h',
  'ghmac.h',
  'ghook.h',
  'ghostutils.h',
  'gi18n.h',
  'gi18n-lib.h',
  'giochannel.h',
  'gkeyfile.h',
  'glist.h',
  'gmacros.h',
  'gmain.h',
  'gmappedfile.h',
  'gmarkup.h',
  'gmem.h',
  'gmessages.h',
  'gnode.h',
  'goption.h',
  'gpattern.h',
  'gpoll.h',
  'gprimes.h',
  'gqsort.h',
  'gquark.h',
  'gqueue.h',
  'grand.h',
  'gregex.h',
  'gscanner.h',
  'gsequence.h',
  'gshell.h',
  'gslice.h',
  'gslist.h',
  'gspawn.h',
  'gstdio.h',
  'gstrfuncs.h',
  'gtestutils.h',
  'gstring.h',
  'gstringchunk.h',
  'gthread.h',
  'gthreadpool.h',
  'gtimer.h',
  'gtimezone.h',
  'gtrashstack.h',
  'gtree.h',
  'gtypes.h',
  'guuid.h',
  'gunicode.h',
  'gurifuncs.h',
  'gutils.h',
  'gvarianttype.h',
  'gvariant.h',
  'gversion.h',
  'gversionmacros.h',
  'gwin32.h',
  'gprintf.h',
)
install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')

deprecated_sources = files(
  'deprecated/gallocator.c',
  'deprecated/gcache.c',
  'deprecated/gcompletion.c',
  'deprecated/grel.c',
  'deprecated/gthread-deprecated.c'
)

glib_sources = files(
  'garray.c',
  'gasyncqueue.c',
  'gatomic.c',
  'gbacktrace.c',
  'gbase64.c',
  'gbitlock.c',
  'gbookmarkfile.c',
  'gbytes.c',
  'gcharset.c',
  'gchecksum.c',
  'gconvert.c',
  'gdataset.c',
  'gdate.c',
  'gdatetime.c',
  'gdir.c',
  'genviron.c',
  'gerror.c',
  'gfileutils.c',
  'ggettext.c',
  'ghash.c',
  'ghmac.c',
  'ghook.c',
  'ghostutils.c',
  'giochannel.c',
  'gkeyfile.c',
  'glib-init.c',
  'glib-private.c',
  'glist.c',
  'gmain.c',
  'gmappedfile.c',
  'gmarkup.c',
  'gmem.c',
  'gmessages.c',
  'gnode.c',
  'goption.c',
  'gpattern.c',
  'gpoll.c',
  'gprimes.c',
  'gqsort.c',
  'gquark.c',
  'gqueue.c',
  'grand.c',
  'gregex.c',
  'gscanner.c',
  'gsequence.c',
  'gshell.c',
  'gslice.c',
  'gslist.c',
  'gstdio.c',
  'gstrfuncs.c',
  'gstring.c',
  'gstringchunk.c',
  'gtestutils.c',
  'gthread.c',
  'gthreadpool.c',
  'gtimer.c',
  'gtimezone.c',
  'gtranslit.c',
  'gtrashstack.c',
  'gtree.c',
  'guniprop.c',
  'gutf8.c',
  'gunibreak.c',
  'gunicollate.c',
  'gunidecomp.c',
  'gurifuncs.c',
  'gutils.c',
  'guuid.c',
  'gvariant.c',
  'gvariant-core.c',
  'gvariant-parser.c',
  'gvariant-serialiser.c',
  'gvarianttypeinfo.c',
  'gvarianttype.c',
  'gversion.c',
  'gwakeup.c',
  'gprintf.c',
)

if host_system == 'windows'
  glib_win_rc = configure_file(
    input: 'glib.rc.in',
    output: 'glib.rc',
    configuration: glibconfig_conf,
  )
  glib_win_res = windows.compile_resources(glib_win_rc)
  glib_sources += [glib_win_res]
  glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
  platform_deps = [winsock2, cc.find_library('winmm')]
else
  glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
  platform_deps = []
endif

glib_sources += files('gthread-@0@.c'.format(threads_implementation))

if enable_dtrace
  glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
  glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
else
  glib_dtrace_obj = []
  glib_dtrace_hdr = []
endif

pcre_static_args = []

if use_pcre_static_flag
  pcre_static_args = ['-DPCRE_STATIC']
endif

libglib = library('glib-2.0',
  glib_dtrace_obj, glib_dtrace_hdr,
  sources : [deprecated_sources, glib_sources],
  version : library_version,
  soversion : soversion,
  install : true,
  # intl.lib is not compatible with SAFESEH
  link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
  include_directories : configinc,
  link_with : [charset_lib, gnulib_lib],
  dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps,
  c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
)

libglib_dep = declare_dependency(
  link_with : libglib,
  # thread_dep doesn't get pulled in from libglib atm,
  # see https://github.com/mesonbuild/meson/issues/1426
  dependencies : [thread_dep, libintl],
  # We sadly need to export configinc here because everyone includes <glib/*.h>
  include_directories : [configinc, glibinc])

pkg.generate(libraries : [libglib, libintl],
  libraries_private : [osx_ldflags, win32_ldflags],
  subdirs : ['glib-2.0'],
  extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
  variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
               'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
               'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
               'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
  version : glib_version,
  install_dir : glib_pkgconfigreldir,
  filebase : 'glib-2.0',
  name : 'GLib',
  description : 'C Utility Library',
)

# On Windows, glib needs a spawn helper for g_spawn* API
if host_system == 'windows'
  if host_machine.cpu_family() == 'x86'
    executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
      install : true,
      gui_app : true,
      include_directories : configinc,
      dependencies : [libglib_dep])
    executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
      install : true,
      c_args : ['-DHELPER_CONSOLE'],
      include_directories : configinc,
      dependencies : [libglib_dep])
  else
    executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
      install : true,
      gui_app : true,
      include_directories : configinc,
      dependencies : [libglib_dep])
    executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
      install : true,
      c_args : ['-DHELPER_CONSOLE'],
      include_directories : configinc,
      dependencies : [libglib_dep])
  endif
else
  gtester = executable('gtester', 'gtester.c',
    install : true,
    include_directories : configinc,
    dependencies : [libglib_dep])
endif

install_data('gtester-report', install_dir : get_option('bindir'))

install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))

gdb_conf = configuration_data()
gdb_conf.set('datadir', glib_datadir)
# This is also used in gobject/meson.build
if host_system != 'windows'
  # XXX: We add a leading './' because glib_libdir is an absolute path and we
  # need it to be a relative path so that join_paths appends it to the end.
  gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
else
  # FIXME: Cannot install on Windows because the path will contain a drive
  # letter and colons are not allowed in paths.
  gdb_install_dir = false
endif
configure_file(
  input: 'libglib-gdb.py.in',
  output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
  configuration: gdb_conf,
  install_dir: gdb_install_dir,
)

if enable_systemtap
  glib_stp = configure_file(input : 'glib.stp.in',
    output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
    configuration : stp_cdata,
    install_dir : tapset_install_dir,
    install : true)
endif

subdir('tests')