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