Imported Upstream version 2.55.0
[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 = [
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 = [
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 = [
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   'gregex.h',
80   'gscanner.h',
81   'gsequence.h',
82   'gshell.h',
83   'gslice.h',
84   'gslist.h',
85   'gspawn.h',
86   'gstdio.h',
87   'gstrfuncs.h',
88   'gtestutils.h',
89   'gstring.h',
90   'gstringchunk.h',
91   'gthread.h',
92   'gthreadpool.h',
93   'gtimer.h',
94   'gtimezone.h',
95   'gtrashstack.h',
96   'gtree.h',
97   'gtypes.h',
98   'guuid.h',
99   'gunicode.h',
100   'gurifuncs.h',
101   'gutils.h',
102   'gvarianttype.h',
103   'gvariant.h',
104   'gversion.h',
105   'gversionmacros.h',
106   'gwin32.h',
107   'gprintf.h',
108 ]
109 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
110
111 deprecated_sources = [
112   'deprecated/gallocator.c',
113   'deprecated/gcache.c',
114   'deprecated/gcompletion.c',
115   'deprecated/grel.c',
116   'deprecated/gthread-deprecated.c'
117 ]
118
119 glib_sources = [
120   'garray.c',
121   'gasyncqueue.c',
122   'gatomic.c',
123   'gbacktrace.c',
124   'gbase64.c',
125   'gbitlock.c',
126   'gbookmarkfile.c',
127   'gbytes.c',
128   'gcharset.c',
129   'gchecksum.c',
130   'gconvert.c',
131   'gdataset.c',
132   'gdate.c',
133   'gdatetime.c',
134   'gdir.c',
135   'genviron.c',
136   'gerror.c',
137   'gfileutils.c',
138   'ggettext.c',
139   'ghash.c',
140   'ghmac.c',
141   'ghook.c',
142   'ghostutils.c',
143   'giochannel.c',
144   'gkeyfile.c',
145   'glib-init.c',
146   'glib-private.c',
147   'glist.c',
148   'gmain.c',
149   'gmappedfile.c',
150   'gmarkup.c',
151   'gmem.c',
152   'gmessages.c',
153   'gnode.c',
154   'goption.c',
155   'gpattern.c',
156   'gpoll.c',
157   'gprimes.c',
158   'gqsort.c',
159   'gquark.c',
160   'gqueue.c',
161   'grand.c',
162   'gregex.c',
163   'gscanner.c',
164   'gsequence.c',
165   'gshell.c',
166   'gslice.c',
167   'gslist.c',
168   'gstdio.c',
169   'gstrfuncs.c',
170   'gstring.c',
171   'gstringchunk.c',
172   'gtestutils.c',
173   'gthread.c',
174   'gthreadpool.c',
175   'gtimer.c',
176   'gtimezone.c',
177   'gtranslit.c',
178   'gtrashstack.c',
179   'gtree.c',
180   'guniprop.c',
181   'gutf8.c',
182   'gunibreak.c',
183   'gunicollate.c',
184   'gunidecomp.c',
185   'gurifuncs.c',
186   'gutils.c',
187   'guuid.c',
188   'gvariant.c',
189   'gvariant-core.c',
190   'gvariant-parser.c',
191   'gvariant-serialiser.c',
192   'gvarianttypeinfo.c',
193   'gvarianttype.c',
194   'gversion.c',
195   'gwakeup.c',
196   'gprintf.c',
197 ]
198
199 if host_system == 'windows'
200   thread_src = ['gthread-win32.c']
201   plat_src = ['gwin32.c', 'gspawn-win32.c', 'giowin32.c']
202   platform_deps = [winsock2, cc.find_library('winmm')]
203 else
204   thread_src = ['gthread-posix.c']
205   plat_src = ['glib-unix.c', 'gspawn.c', 'giounix.c']
206   platform_deps = []
207 endif
208
209 if enable_dtrace
210   glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
211   glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
212 else
213   glib_dtrace_obj = []
214   glib_dtrace_hdr = []
215 endif
216
217 pcre_static_args = []
218
219 if use_pcre_static_flag
220   pcre_static_args = ['-DPCRE_STATIC']
221 endif
222
223 libglib = shared_library('glib-2.0',
224   glib_dtrace_obj, glib_dtrace_hdr,
225   sources : [deprecated_sources, glib_sources, thread_src, plat_src],
226   version : library_version,
227   soversion : soversion,
228   install : true,
229   # intl.lib is not compatible with SAFESEH
230   link_args : noseh_link_args,
231   include_directories : configinc,
232   link_with : [charset_lib, gnulib_lib],
233   dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps,
234   c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
235 )
236
237 libglib_dep = declare_dependency(link_with : libglib,
238   # We sadly need to export configinc here because everyone includes <glib/*.h>
239   include_directories : [configinc, glibinc])
240
241 # On Windows, glib needs a spawn helper for g_spawn* API
242 if host_system == 'windows'
243   if host_machine.cpu_family() == 'x86'
244     executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
245       install : true,
246       gui_app : true,
247       c_args : ['-DHAVE_CONFIG_H=1'],
248       include_directories : configinc,
249       dependencies : [libintl, libglib_dep])
250     executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
251       install : true,
252       c_args : ['-DHAVE_CONFIG_H=1', '-DHELPER_CONSOLE'],
253       include_directories : configinc,
254       dependencies : [libintl, libglib_dep])
255   else
256     executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
257       install : true,
258       gui_app : true,
259       c_args : ['-DHAVE_CONFIG_H=1'],
260       include_directories : configinc,
261       dependencies : [libintl, libglib_dep])
262     executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
263       install : true,
264       c_args : ['-DHAVE_CONFIG_H=1', '-DHELPER_CONSOLE'],
265       include_directories : configinc,
266       dependencies : [libintl, libglib_dep])
267   endif
268 else
269   gtester = executable('gtester', 'gtester.c',
270     install : true,
271     c_args : ['-DHAVE_CONFIG_H=1'],
272     include_directories : configinc,
273     dependencies : [libglib_dep])
274 endif
275
276 install_data('gtester-report', install_dir : get_option('bindir'))
277
278 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
279
280 gdb_conf = configuration_data()
281 gdb_conf.set('datadir', glib_datadir)
282 # This is also used in gobject/meson.build
283 if host_system != 'windows'
284   # XXX: We add a leading './' because glib_libdir is an absolute path and we
285   # need it to be a relative path so that join_paths appends it to the end.
286   gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
287 else
288   # FIXME: Cannot install on Windows because the path will contain a drive
289   # letter and colons are not allowed in paths.
290   gdb_install_dir = false
291 endif
292 configure_file(
293   input: 'libglib-gdb.py.in',
294   output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
295   configuration: gdb_conf,
296   install_dir: gdb_install_dir,
297 )
298
299 if enable_systemtap
300   glib_stp = configure_file(input : 'glib.stp.in',
301     output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
302     configuration : stp_cdata,
303     install_dir : tapset_install_dir,
304     install : true)
305 endif
306
307 # gtester doesn't work on native windows
308 if cc.get_id() != 'msvc'
309   subdir('tests')
310 endif