Imported Upstream version 2.58.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
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   'guuid.c',
203   'gvariant.c',
204   'gvariant-core.c',
205   'gvariant-parser.c',
206   'gvariant-serialiser.c',
207   'gvarianttypeinfo.c',
208   'gvarianttype.c',
209   'gversion.c',
210   'gwakeup.c',
211   'gprintf.c',
212 )
213
214 if host_system == 'windows'
215   glib_win_rc = configure_file(
216     input: 'glib.rc.in',
217     output: 'glib.rc',
218     configuration: glibconfig_conf,
219   )
220   glib_win_res = windows.compile_resources(glib_win_rc)
221   glib_sources += [glib_win_res]
222   glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
223   platform_deps = [winsock2, cc.find_library('winmm')]
224 else
225   glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
226   platform_deps = []
227 endif
228
229 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
230
231 if enable_dtrace
232   glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
233   glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
234 else
235   glib_dtrace_obj = []
236   glib_dtrace_hdr = []
237 endif
238
239 pcre_static_args = []
240
241 if use_pcre_static_flag
242   pcre_static_args = ['-DPCRE_STATIC']
243 endif
244
245 if use_system_pcre
246   pcre_deps = [pcre]
247   pcre_objects = []
248 else
249   pcre_deps = []
250   pcre_objects = [libpcre.extract_all_objects()]
251 endif
252
253 libglib = library('glib-2.0',
254   glib_dtrace_obj, glib_dtrace_hdr,
255   sources : [deprecated_sources, glib_sources],
256   objects : [charset_lib.extract_all_objects()] + gnulib_objects + pcre_objects,
257   version : library_version,
258   soversion : soversion,
259   install : true,
260   # intl.lib is not compatible with SAFESEH
261   link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
262   include_directories : configinc,
263   dependencies : pcre_deps + [thread_dep, libintl, librt] + libiconv + platform_deps,
264   c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
265 )
266
267 libglib_dep = declare_dependency(
268   link_with : libglib,
269   # thread_dep doesn't get pulled in from libglib atm,
270   # see https://github.com/mesonbuild/meson/issues/1426
271   dependencies : [thread_dep, libintl],
272   # We sadly need to export configinc here because everyone includes <glib/*.h>
273   include_directories : [configinc, glibinc])
274
275 pkg.generate(libraries : [libglib, libintl],
276   libraries_private : [osx_ldflags, win32_ldflags],
277   subdirs : ['glib-2.0'],
278   extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
279   variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
280                'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
281                'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
282                'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
283   version : glib_version,
284   install_dir : glib_pkgconfigreldir,
285   filebase : 'glib-2.0',
286   name : 'GLib',
287   description : 'C Utility Library',
288 )
289
290 # On Windows, glib needs a spawn helper for g_spawn* API
291 if host_system == 'windows'
292   if host_machine.cpu_family() == 'x86'
293     executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
294       install : true,
295       gui_app : true,
296       include_directories : configinc,
297       dependencies : [libglib_dep])
298     executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
299       install : true,
300       c_args : ['-DHELPER_CONSOLE'],
301       include_directories : configinc,
302       dependencies : [libglib_dep])
303   else
304     executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
305       install : true,
306       gui_app : true,
307       include_directories : configinc,
308       dependencies : [libglib_dep])
309     executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
310       install : true,
311       c_args : ['-DHELPER_CONSOLE'],
312       include_directories : configinc,
313       dependencies : [libglib_dep])
314   endif
315 else
316   gtester = executable('gtester', 'gtester.c',
317     install : true,
318     include_directories : configinc,
319     dependencies : [libglib_dep])
320 endif
321
322 report_conf = configuration_data()
323 report_conf.set('GLIB_VERSION', glib_version)
324 report_conf.set('PYTHON', python_name)
325 configure_file(
326   input: 'gtester-report.in',
327   output: 'gtester-report',
328   install_dir: get_option('bindir'),
329   configuration: report_conf,
330   install_mode: 'rwxr-xr-x'
331 )
332
333 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
334
335 gdb_conf = configuration_data()
336 gdb_conf.set('datadir', glib_datadir)
337 # This is also used in gobject/meson.build
338 if host_system != 'windows'
339   # XXX: We add a leading './' because glib_libdir is an absolute path and we
340   # need it to be a relative path so that join_paths appends it to the end.
341   gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
342 else
343   # FIXME: Cannot install on Windows because the path will contain a drive
344   # letter and colons are not allowed in paths.
345   gdb_install_dir = false
346 endif
347 configure_file(
348   input: 'libglib-gdb.py.in',
349   output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
350   configuration: gdb_conf,
351   install_dir: gdb_install_dir,
352 )
353
354 if enable_systemtap
355   glib_stp = configure_file(input : 'glib.stp.in',
356     output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
357     configuration : stp_cdata,
358     install_dir : tapset_install_dir,
359     install : true)
360 endif
361
362 subdir('tests')