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