Merge branch 'upstream' into tizen
[platform/upstream/glib.git] / gio / meson.build
1 gio_c_args = [
2   '-DG_LOG_DOMAIN="GLib-GIO"',
3   '-DGIO_COMPILATION',
4   '-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
5   '-DLOCALSTATEDIR="@0@"'.format(glib_localstatedir),
6 ]
7
8 gio_c_args += glib_hidden_visibility_args
9
10 # FIXME: Install empty glib_giomodulesdir
11
12 gnetworking_h_conf = configuration_data()
13
14 gnetworking_h_nameser_compat_include = ''
15
16 if host_system not in ['windows', 'android']
17   # Don't check for C_IN on Android since it does not define it in public
18   # headers, we define it ourselves wherever necessary
19   if not cc.compiles('''#include <sys/types.h>
20                         #include <arpa/nameser.h>
21                         int qclass = C_IN;''',
22                      name : 'C_IN in public headers (no arpa/nameser_compat.h needed)')
23     if cc.compiles('''#include <sys/types.h>
24                       #include <arpa/nameser.h>
25                       #include <arpa/nameser_compat.h>
26                       int qclass = C_IN;''',
27                    name : 'arpa/nameser_compat.h needed for C_IN')
28       gnetworking_h_nameser_compat_include = '#include <arpa/nameser_compat.h>'
29     else
30       error('Could not find required includes for ARPA C_IN')
31     endif
32   endif
33 endif
34
35 network_libs = [ ]
36 network_args = [ ]
37 if host_system != 'windows'
38   # res_query()
39   res_query_test = '''#include <resolv.h>
40                       int main (int argc, char ** argv) {
41                         return res_query("test", 0, 0, (void *)0, 0);
42                       }'''
43   res_query_test_full = '''#include <sys/types.h>
44                            #include <netinet/in.h>
45                            #include <arpa/nameser.h>
46                         ''' + res_query_test
47   if not cc.links(res_query_test_full, name : 'res_query()')
48     if cc.links(res_query_test_full, args : '-lresolv', name : 'res_query() in -lresolv')
49       network_libs += [ cc.find_library('resolv') ]
50       network_args += [ '-lresolv' ]
51     elif cc.links(res_query_test, args : '-lbind', name : 'res_query() in -lbind')
52       network_libs += [ cc.find_library('bind') ]
53       network_args += [ '-lbind' ]
54     elif cc.links(res_query_test, args : '-lsocket', name : 'res_query() in -lsocket')
55       network_libs += [ cc.find_library('socket') ]
56       network_args += [ '-lsocket' ]
57     else
58       error('Could not find res_query()')
59     endif
60   endif
61
62   # socket()
63   socket_test = '''#include <sys/types.h>
64                    #include <sys/socket.h>
65                    int main (int argc, char ** argv) {
66                      return socket(1, 2, 3);
67                    }'''
68   if not cc.links(socket_test, name : 'socket()')
69     if cc.links(socket_test, args : '-lsocket', name : 'socket() in -lsocket')
70       network_libs += [ cc.find_library('socket') ]
71       network_args += [ '-lsocket' ]
72     else
73       error('Could not find socket()')
74     endif
75   endif
76
77   # res_init()
78   if cc.links('''#include <sys/types.h>
79                  #include <netinet/in.h>
80                  #include <arpa/nameser.h>
81                  #include <resolv.h>
82                  int main (int argc, char ** argv) {
83                    return res_init();
84                  }''', args : network_args, name : 'res_init()')
85     glib_conf.set('HAVE_RES_INIT', 1)
86   endif
87
88   # res_nclose()
89   if cc.links('''#include <sys/types.h>
90                  #include <netinet/in.h>
91                  #include <arpa/nameser.h>
92                  #include <resolv.h>
93                  int main (int argc, char ** argv) {
94                    struct __res_state res;
95                    res_nclose(&res);
96                    return 0;
97                  }''', args : network_args, name : 'res_nclose()')
98     glib_conf.set('HAVE_RES_NCLOSE', 1)
99   endif
100
101   # res_ndestroy()
102   if cc.links('''#include <sys/types.h>
103                  #include <netinet/in.h>
104                  #include <arpa/nameser.h>
105                  #include <resolv.h>
106                  int main (int argc, char ** argv) {
107                    struct __res_state res;
108                    res_ndestroy(&res);
109                    return 0;
110                  }''', args : network_args, name : 'res_ndestroy()')
111     glib_conf.set('HAVE_RES_NDESTROY', 1)
112   endif
113
114   # res_ninit()
115   if cc.links('''#include <sys/types.h>
116                  #include <netinet/in.h>
117                  #include <arpa/nameser.h>
118                  #include <resolv.h>
119                  int main (int argc, char ** argv) {
120                    struct __res_state res;
121                    return res_ninit(&res);
122                  }''', args : network_args, name : 'res_ninit()')
123     glib_conf.set('HAVE_RES_NINIT', 1)
124   endif
125
126   # res_nquery()
127   if cc.links('''#include <sys/types.h>
128                  #include <netinet/in.h>
129                  #include <arpa/nameser.h>
130                  #include <resolv.h>
131                  int main (int argc, char ** argv) {
132                    struct __res_state res;
133                    return res_nquery(&res, "test", 0, 0, (void *)0, 0);
134                  }''', args : network_args, name : 'res_nquery()')
135     glib_conf.set('HAVE_RES_NQUERY', 1)
136   endif
137
138   if cc.has_type('struct ip_mreqn', prefix : '#include <netinet/in.h>')
139     glib_conf.set('HAVE_IP_MREQN', 1)
140   endif
141
142   if cc.compiles('''#include <sys/ioctl.h>
143                     #include <net/if.h>
144                     int main (int argc, char ** argv) {
145                       struct ifreq ifr;
146                       ioctl(0, SIOCGIFADDR, &ifr);
147                       return 0;
148                     }''',
149                  name : 'ioctl with request SIOCGIFADDR')
150     glib_conf.set('HAVE_SIOCGIFADDR', '/**/')
151   endif
152
153 endif
154
155 if host_system == 'android'
156   # struct ip_mreq_source definition is broken on Android NDK <= r16
157   # See https://bugzilla.gnome.org/show_bug.cgi?id=740791
158   if not cc.compiles('''#include <netinet/in.h>
159                         int main(int argc, char ** argv) {
160                           struct ip_mreq_source mc_req_src;
161                           mc_req_src.imr_interface.s_addr = 0;
162                           return 0;
163                         }''',
164                         name : 'ip_mreq_source.imr_interface has s_addr member')
165     glib_conf.set('BROKEN_IP_MREQ_SOURCE_STRUCT', 1)
166   endif
167 endif
168
169 gnetworking_h_conf.set('NAMESER_COMPAT_INCLUDE', gnetworking_h_nameser_compat_include)
170
171 gnetworking_h = configure_file(input : 'gnetworking.h.in',
172                                output : 'gnetworking.h',
173                                install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'),
174                                configuration : gnetworking_h_conf)
175
176 gdbus_headers = files(
177   'gdbusauthobserver.h',
178   'gcredentials.h',
179   'gdbusutils.h',
180   'gdbuserror.h',
181   'gdbusaddress.h',
182   'gdbusconnection.h',
183   'gdbusmessage.h',
184   'gdbusnameowning.h',
185   'gdbusnamewatching.h',
186   'gdbusproxy.h',
187   'gdbusintrospection.h',
188   'gdbusmethodinvocation.h',
189   'gdbusserver.h',
190   'gdbusinterface.h',
191   'gdbusinterfaceskeleton.h',
192   'gdbusobject.h',
193   'gdbusobjectskeleton.h',
194   'gdbusobjectproxy.h',
195   'gdbusobjectmanager.h',
196   'gdbusobjectmanagerclient.h',
197   'gdbusobjectmanagerserver.h',
198   'gtestdbus.h',
199 )
200
201 gdbus_sources = files(
202   'gdbusutils.c',
203   'gdbusaddress.c',
204   'gdbusauthobserver.c',
205   'gdbusauth.c',
206   'gdbusauthmechanism.c',
207   'gdbusauthmechanismanon.c',
208   'gdbusauthmechanismexternal.c',
209   'gdbusauthmechanismsha1.c',
210   'gdbuserror.c',
211   'gdbusconnection.c',
212   'gdbusmessage.c',
213   'gdbusnameowning.c',
214   'gdbusnamewatching.c',
215   'gdbusproxy.c',
216   'gdbusprivate.c',
217   'gdbusintrospection.c',
218   'gdbusmethodinvocation.c',
219   'gdbusserver.c',
220   'gdbusinterface.c',
221   'gdbusinterfaceskeleton.c',
222   'gdbusobject.c',
223   'gdbusobjectskeleton.c',
224   'gdbusobjectproxy.c',
225   'gdbusobjectmanager.c',
226   'gdbusobjectmanagerclient.c',
227   'gdbusobjectmanagerserver.c',
228   'gtestdbus.c',
229 )
230
231 if get_option('kdbus')
232 gdbus_sources += files(
233   'gkdbus.c',
234   'gkdbusfakedaemon.c',
235 )
236 endif
237
238 # Generate gdbus-codegen
239 subdir('gdbus-2.0/codegen')
240
241 # Generate xdp-dbus.{c,h}
242 xdp_dbus_generated = custom_target('xdp-dbus',
243     input : ['org.freedesktop.portal.Documents.xml',
244              'org.freedesktop.portal.OpenURI.xml',
245              'org.freedesktop.portal.ProxyResolver.xml',
246              'org.freedesktop.portal.Trash.xml'],
247     output : ['xdp-dbus.h', 'xdp-dbus.c'],
248     depend_files : gdbus_codegen_built_files,
249     command : [python, gdbus_codegen,
250                '--interface-prefix', 'org.freedesktop.portal.',
251                '--output-directory', '@OUTDIR@',
252                '--generate-c-code', 'xdp-dbus',
253                '--c-namespace', 'GXdp',
254                '@INPUT@'])
255
256 # Generate gdbus-generated.{c,h}
257 gdbus_daemon_generated = custom_target('gdbus-daemon-generated',
258     input : ['dbus-daemon.xml'],
259     output : ['gdbus-daemon-generated.h', 'gdbus-daemon-generated.c'],
260     depend_files : gdbus_codegen_built_files,
261     command : [python, gdbus_codegen,
262                '--interface-prefix', 'org.',
263                '--output-directory', '@OUTDIR@',
264                '--generate-c-code', 'gdbus-daemon-generated',
265                '--c-namespace', '_G', '@INPUT@'])
266
267 settings_headers = files(
268   'gsettingsbackend.h',
269   'gsettingsschema.h',
270   'gsettings.h',
271 )
272
273 settings_sources = files(
274   'gvdb/gvdb-reader.c',
275   'gdelayedsettingsbackend.c',
276   'gkeyfilesettingsbackend.c',
277   'gmemorysettingsbackend.c',
278   'gnullsettingsbackend.c',
279   'gsettingsbackend.c',
280   'gsettingsschema.c',
281   'gsettings-mapping.c',
282   'gsettings.c',
283 )
284
285 if host_system == 'windows'
286   settings_sources += files('gregistrysettingsbackend.c')
287 endif
288
289 application_headers = files(
290   'gapplication.h',
291   'gapplicationcommandline.h',
292
293   'gactiongroup.h',
294   'gactionmap.h',
295   'gsimpleactiongroup.h',
296   'gremoteactiongroup.h',
297   'gactiongroupexporter.h',
298   'gdbusactiongroup.h',
299   'gaction.h',
300   'gpropertyaction.h',
301   'gsimpleaction.h',
302
303   'gmenumodel.h',
304   'gmenu.h',
305   'gmenuexporter.h',
306   'gdbusmenumodel.h',
307   'gnotification.h',
308 )
309
310 application_sources = files(
311   'gapplication.c',
312   'gapplicationcommandline.c',
313   'gapplicationimpl-dbus.c',
314
315   'gactiongroup.c',
316   'gactionmap.c',
317   'gsimpleactiongroup.c',
318   'gremoteactiongroup.c',
319   'gactiongroupexporter.c',
320   'gdbusactiongroup.c',
321   'gaction.c',
322   'gpropertyaction.c',
323   'gsimpleaction.c',
324
325   'gmenumodel.c',
326   'gmenu.c',
327   'gmenuexporter.c',
328   'gdbusmenumodel.c',
329   'gnotification.c',
330   'gnotificationbackend.c',
331 )
332
333 local_sources = files(
334   'ghttpproxy.c',
335   'glocalfile.c',
336   'glocalfileenumerator.c',
337   'glocalfileinfo.c',
338   'glocalfileinputstream.c',
339   'glocalfilemonitor.c',
340   'glocalfileoutputstream.c',
341   'glocalfileiostream.c',
342   'glocalvfs.c',
343   'gsocks4proxy.c',
344   'gsocks4aproxy.c',
345   'gsocks5proxy.c',
346   'thumbnail-verify.c',
347 )
348
349 platform_deps = []
350 internal_deps = []
351 # TODO: internal_objects is a workaround for
352 # <https://github.com/mesonbuild/meson/issues/3934> and
353 # <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
354 # on a meson version where those are fixed, revert the commit that
355 # introduced this workaround.
356 internal_objects = []
357 appinfo_sources = []
358 contenttype_sources = []
359 portal_sources = []
360 unix_sources = []
361 win32_sources = []
362
363 # This is also used by tests/gdbus-daemon, so use files() to include the path
364 gdbus_daemon_sources = [
365   files('gdbusdaemon.c'),
366   gdbus_daemon_generated,
367 ]
368
369 if host_system != 'windows'
370   unix_sources = files(
371     'gfiledescriptorbased.c',
372     'giounix-private.c',
373     'gunixconnection.c',
374     'gunixcredentialsmessage.c',
375     'gunixfdlist.c',
376     'gunixfdmessage.c',
377     'gunixmount.c',
378     'gunixmounts.c',
379     'gunixsocketaddress.c',
380     'gunixvolume.c',
381     'gunixvolumemonitor.c',
382     'gunixinputstream.c',
383     'gunixoutputstream.c',
384     'gfdonotificationbackend.c',
385     'ggtknotificationbackend.c',
386   )
387
388   portal_sources = [files(
389     'gdocumentportal.c',
390     'gopenuriportal.c',
391     'gmemorymonitorportal.c',
392     'gnetworkmonitorportal.c',
393     'gpowerprofilemonitorportal.c',
394     'gproxyresolverportal.c',
395     'gtrashportal.c',
396     'gportalsupport.c',
397     'gportalnotificationbackend.c'),
398     xdp_dbus_generated
399   ]
400
401   gio_unix_include_headers = files(
402     'gfiledescriptorbased.h',
403     'gunixconnection.h',
404     'gunixcredentialsmessage.h',
405     'gunixmounts.h',
406     'gunixfdlist.h',
407     'gunixfdmessage.h',
408     'gunixinputstream.h',
409     'gunixoutputstream.h',
410     'gunixsocketaddress.h',
411   )
412
413   if glib_have_cocoa
414     settings_sources += files('gnextstepsettingsbackend.m')
415     contenttype_sources += files('gosxcontenttype.m')
416     appinfo_sources += files('gosxappinfo.m')
417     if glib_have_os_x_9_or_later
418       unix_sources += files('gcocoanotificationbackend.m')
419     endif
420     application_headers += files('gosxappinfo.h')
421   else
422     contenttype_sources += files('gcontenttype.c')
423     appinfo_sources += files('gdesktopappinfo.c')
424     gio_unix_include_headers += files('gdesktopappinfo.h')
425   endif
426
427   subdir('xdgmime')
428   internal_deps += [xdgmime_lib]
429   internal_objects += [xdgmime_lib.extract_all_objects()]
430
431   install_headers(gio_unix_include_headers, subdir : 'gio-unix-2.0/gio')
432
433   if glib_conf.has('HAVE_NETLINK')
434     unix_sources += files(
435       'gnetworkmonitornetlink.c',
436       'gnetworkmonitornm.c',
437     )
438   endif
439 else
440   appinfo_sources += files('gwin32appinfo.c')
441   contenttype_sources += files('gcontenttype-win32.c')
442   platform_deps += [cc.find_library('shlwapi'),
443                     cc.find_library('dnsapi'),
444                     iphlpapi_dep,
445                     winsock2]
446   platform_deps += uwp_gio_deps
447
448   win32_sources += files(
449     'gwin32registrykey.c',
450     'gwin32mount.c',
451     'gwin32volumemonitor.c',
452     'gwin32inputstream.c',
453     'gwin32outputstream.c',
454     'gwin32file-sync-stream.c',
455     'gwin32packageparser.c',
456     'gwin32networkmonitor.c',
457     'gwin32networkmonitor.h',
458     'gwin32notificationbackend.c',
459   )
460
461   gio_win_rc = configure_file(
462     input: 'gio.rc.in',
463     output: 'gio.rc',
464     configuration: glibconfig_conf,
465   )
466   gio_win_res = windows.compile_resources(gio_win_rc)
467   win32_sources += [gio_win_res]
468
469   gio_win32_include_headers = files(
470     'gwin32inputstream.h',
471     'gwin32outputstream.h',
472   )
473   install_headers(gio_win32_include_headers, subdir : 'gio-win32-2.0/gio')
474 endif
475
476 gio_sources = files(
477   'gappinfo.c',
478   'gasynchelper.c',
479   'gasyncinitable.c',
480   'gasyncresult.c',
481   'gbufferedinputstream.c',
482   'gbufferedoutputstream.c',
483   'gbytesicon.c',
484   'gcancellable.c',
485   'gcharsetconverter.c',
486   'gcontextspecificgroup.c',
487   'gconverter.c',
488   'gconverterinputstream.c',
489   'gconverteroutputstream.c',
490   'gcredentials.c',
491   'gdatagrambased.c',
492   'gdatainputstream.c',
493   'gdataoutputstream.c',
494   'gdrive.c',
495   'gdummyfile.c',
496   'gdummyproxyresolver.c',
497   'gdummytlsbackend.c',
498   'gemblem.c',
499   'gemblemedicon.c',
500   'gfile.c',
501   'gfileattribute.c',
502   'gfileenumerator.c',
503   'gfileicon.c',
504   'gfileinfo.c',
505   'gfileinputstream.c',
506   'gfilemonitor.c',
507   'gfilenamecompleter.c',
508   'gfileoutputstream.c',
509   'gfileiostream.c',
510   'gfilterinputstream.c',
511   'gfilteroutputstream.c',
512   'gicon.c',
513   'ginetaddress.c',
514   'ginetaddressmask.c',
515   'ginetsocketaddress.c',
516   'ginitable.c',
517   'ginputstream.c',
518   'gioerror.c',
519   'giomodule.c',
520   'giomodule-priv.c',
521   'gioscheduler.c',
522   'giostream.c',
523   'gloadableicon.c',
524   'gmarshal-internal.c',
525   'gmount.c',
526   'gmemorymonitor.c',
527   'gmemorymonitordbus.c',
528   'gmemoryinputstream.c',
529   'gmemoryoutputstream.c',
530   'gmountoperation.c',
531   'gnativesocketaddress.c',
532   'gnativevolumemonitor.c',
533   'gnetworkaddress.c',
534   'gnetworking.c',
535   'gnetworkmonitor.c',
536   'gnetworkmonitorbase.c',
537   'gnetworkservice.c',
538   'goutputstream.c',
539   'gpermission.c',
540   'gpollableinputstream.c',
541   'gpollableoutputstream.c',
542   'gpollableutils.c',
543   'gpollfilemonitor.c',
544   'gpowerprofilemonitor.c',
545   'gpowerprofilemonitordbus.c',
546   'gproxy.c',
547   'gproxyaddress.c',
548   'gproxyaddressenumerator.c',
549   'gproxyresolver.c',
550   'gresolver.c',
551   'gresource.c',
552   'gresourcefile.c',
553   'gseekable.c',
554   'gsimpleasyncresult.c',
555   'gsimpleiostream.c',
556   'gsimplepermission.c',
557   'gsimpleproxyresolver.c',
558   'gsocket.c',
559   'gsocketaddress.c',
560   'gsocketaddressenumerator.c',
561   'gsocketclient.c',
562   'gsocketconnectable.c',
563   'gsocketconnection.c',
564   'gsocketcontrolmessage.c',
565   'gsocketinputstream.c',
566   'gsocketlistener.c',
567   'gsocketoutputstream.c',
568   'gsocketservice.c',
569   'gsrvtarget.c',
570   'gsubprocesslauncher.c',
571   'gsubprocess.c',
572   'gtask.c',
573   'gtcpconnection.c',
574   'gtcpwrapperconnection.c',
575   'gthemedicon.c',
576   'gthreadedsocketservice.c',
577   'gthreadedresolver.c',
578   'gthreadedresolver.h',
579   'gtlsbackend.c',
580   'gtlscertificate.c',
581   'gtlsclientconnection.c',
582   'gtlsconnection.c',
583   'gtlsdatabase.c',
584   'gtlsfiledatabase.c',
585   'gtlsinteraction.c',
586   'gtlspassword.c',
587   'gtlsserverconnection.c',
588   'gdtlsconnection.c',
589   'gdtlsclientconnection.c',
590   'gdtlsserverconnection.c',
591   'gunionvolumemonitor.c',
592   'gvfs.c',
593   'gvolume.c',
594   'gvolumemonitor.c',
595   'gzlibcompressor.c',
596   'gzlibdecompressor.c',
597   'glistmodel.c',
598   'gliststore.c',
599   '../glib/gtrace.c',
600 )
601
602 gio_sources += appinfo_sources
603 gio_sources += contenttype_sources
604 gio_sources += gdbus_daemon_sources
605 gio_sources += unix_sources
606 gio_sources += win32_sources
607 gio_sources += application_sources
608 gio_sources += settings_sources
609 gio_sources += gdbus_sources
610 gio_sources += portal_sources
611 gio_sources += local_sources
612
613 MISSING_STUFF = '''
614 # This is read by gobject-introspection/misc/ and gtk-doc
615 gio-public-headers.txt: Makefile
616   '$(AM_V_GEN) echo $(gioinclude_HEADERS) $(giowin32include_HEADERS) $(giounixinclude_HEADERS) > $@.tmp && mv $@.tmp $@
617
618 gio.def: libgio-2.0.la
619   '$(AM_V_GEN) dumpbin.exe -exports .libs/libgio-2.0-0.dll | awk 'BEGIN { print "EXPORTS" } / +[[:digit:]]+ +[[:xdigit:]]+ +[[:xdigit:]]+/{ print $$4 }' > gio.def.tmp && mv gio.def.tmp gio.def
620
621 gio-2.0.lib: libgio-2.0.la gio.def
622   '$(AM_V_GEN) lib.exe -machine:@LIB_EXE_MACHINE_FLAG@ -name:libgio-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(builddir)/gio.def -out:$@
623 '''
624
625 gio_headers = files(
626   'gappinfo.h',
627   'gasyncinitable.h',
628   'gasyncresult.h',
629   'gbufferedinputstream.h',
630   'gbufferedoutputstream.h',
631   'gbytesicon.h',
632   'gcancellable.h',
633   'gcontenttype.h',
634   'gcharsetconverter.h',
635   'gconverter.h',
636   'gconverterinputstream.h',
637   'gconverteroutputstream.h',
638   'gdatagrambased.h',
639   'gdatainputstream.h',
640   'gdataoutputstream.h',
641   'gdrive.h',
642   'gemblem.h',
643   'gemblemedicon.h',
644   'gfile.h',
645   'gfileattribute.h',
646   'gfileenumerator.h',
647   'gfileicon.h',
648   'gfileinfo.h',
649   'gfileinputstream.h',
650   'gfilemonitor.h',
651   'gfilenamecompleter.h',
652   'gfileoutputstream.h',
653   'gfileiostream.h',
654   'gfilterinputstream.h',
655   'gfilteroutputstream.h',
656   'gicon.h',
657   'ginetaddress.h',
658   'ginetaddressmask.h',
659   'ginetsocketaddress.h',
660   'ginitable.h',
661   'ginputstream.h',
662   'gio.h',
663   'gio-autocleanups.h',
664   'gioenums.h',
665   'gioerror.h',
666   'giomodule.h',
667   'gioscheduler.h',
668   'giostream.h',
669   'giotypes.h',
670   'gloadableicon.h',
671   'gmount.h',
672   'gmemoryinputstream.h',
673   'gmemorymonitor.h',
674   'gmemoryoutputstream.h',
675   'gmountoperation.h',
676   'gnativesocketaddress.h',
677   'gnativevolumemonitor.h',
678   'gnetworkaddress.h',
679   'gnetworkmonitor.h',
680   'gnetworkservice.h',
681   'goutputstream.h',
682   'gpermission.h',
683   'gpollableinputstream.h',
684   'gpollableoutputstream.h',
685   'gpollableutils.h',
686   'gpowerprofilemonitor.h',
687   'gproxy.h',
688   'gproxyaddress.h',
689   'gproxyaddressenumerator.h',
690   'gproxyresolver.h',
691   'gresolver.h',
692   'gresource.h',
693   'gseekable.h',
694   'gsimpleasyncresult.h',
695   'gsimpleiostream.h',
696   'gsimplepermission.h',
697   'gsimpleproxyresolver.h',
698   'gsocket.h',
699   'gsocketaddress.h',
700   'gsocketaddressenumerator.h',
701   'gsocketclient.h',
702   'gsocketconnectable.h',
703   'gsocketconnection.h',
704   'gsocketcontrolmessage.h',
705   'gsocketlistener.h',
706   'gsocketservice.h',
707   'gsrvtarget.h',
708   'gsubprocess.h',
709   'gsubprocesslauncher.h',
710   'gtask.h',
711   'gtcpconnection.h',
712   'gtcpwrapperconnection.h',
713   'gthemedicon.h',
714   'gthreadedsocketservice.h',
715   'gtlsbackend.h',
716   'gtlscertificate.h',
717   'gtlsclientconnection.h',
718   'gtlsconnection.h',
719   'gtlsdatabase.h',
720   'gtlsfiledatabase.h',
721   'gtlsinteraction.h',
722   'gtlspassword.h',
723   'gtlsserverconnection.h',
724   'gdtlsconnection.h',
725   'gdtlsclientconnection.h',
726   'gdtlsserverconnection.h',
727   'gvfs.h',
728   'gvolume.h',
729   'gvolumemonitor.h',
730   'gzlibcompressor.h',
731   'gzlibdecompressor.h',
732   'glistmodel.h',
733   'gliststore.h',
734   'tizen_header_glib.h',
735 )
736
737 gio_headers += application_headers
738 gio_headers += settings_headers
739 gio_headers += gdbus_headers
740 install_headers(gio_headers, subdir : 'glib-2.0/gio/')
741
742 # We can't use gnome.mkenums() because the GNOME module looks for glib-mkenums
743 # in PATH, which means you can't bootstrap glib with its own glib-mkenums.
744 gioenumtypes_h = custom_target('gioenumtypes_h',
745   output : 'gioenumtypes.h',
746   capture : true,
747   input : gio_headers,
748   install : true,
749   install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'),
750   command : [python, glib_mkenums,
751              '--template', files('gioenumtypes.h.template'),
752              '@INPUT@', gnetworking_h])
753
754 gioenumtypes_c = custom_target('gioenumtypes_c',
755   output : 'gioenumtypes.c',
756   capture : true,
757   input : gio_headers,
758   depends : [gioenumtypes_h],
759   command : [python, glib_mkenums,
760              '--template', files('gioenumtypes.c.template'),
761              '@INPUT@', gnetworking_h])
762
763 gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, glib_enumtypes_h])
764
765 # inotify
766 if glib_conf.has('HAVE_SYS_INOTIFY_H') and have_func_inotify_init1
767   subdir('inotify')
768   internal_deps += [ inotify_lib ]
769   internal_objects += [inotify_lib.extract_all_objects()]
770 endif
771
772 # kevent
773 if have_func_kqueue and have_func_kevent
774   subdir('kqueue')
775   internal_deps += [ kqueue_lib ]
776   internal_objects += [kqueue_lib.extract_all_objects()]
777 endif
778
779 if host_system == 'windows'
780   subdir('win32')
781   internal_deps += [ giowin32_lib ]
782   internal_objects += [giowin32_lib.extract_all_objects()]
783 endif
784
785 if have_bash
786   bash_comp_inst_dir = ''
787   if bash_comp_dep.found()
788     bash_comp_dir_override = bash_comp_dep.version().version_compare('>= 2.10') ? ['datadir', get_option('datadir')] : ['prefix', get_option('prefix')]
789     bash_comp_inst_dir = bash_comp_dep.get_pkgconfig_variable('completionsdir', define_variable: bash_comp_dir_override)
790   endif
791
792   if bash_comp_inst_dir == ''
793     message('Found bash-completion but the .pc file did not set \'completionsdir\', fallback to a predefined path')
794     bash_comp_inst_dir = join_paths(get_option('datadir'), 'bash-completion/completions')
795   endif
796
797   install_data([
798     'completion/gapplication',
799     'completion/gdbus',
800     'completion/gio',
801     'completion/gsettings',
802     'completion/gresource'
803   ],
804   install_dir: bash_comp_inst_dir)
805 endif
806
807 if enable_dtrace
808   gio_dtrace_obj = dtrace_obj_gen.process('gio_probes.d')
809   gio_dtrace_hdr = dtrace_hdr_gen.process('gio_probes.d')
810 else
811   gio_dtrace_obj = []
812   gio_dtrace_hdr = []
813 endif
814
815 if get_option('kdbus')
816   gio_c_args += '-DKDBUS'
817 endif
818
819 libdbuspolicy_dep = dependency('', required : false)
820 if get_option('libdbuspolicy')
821   libdbuspolicy_dep = dependency('libdbuspolicy1', version : '>=1', required : true)
822   gio_c_args += '-DLIBDBUSPOLICY'
823 endif
824
825 libgio = library('gio-2.0',
826   gioenumtypes_h, gioenumtypes_c, gnetworking_h, gio_sources,
827   gio_dtrace_hdr, gio_dtrace_obj,
828   objects : internal_objects,
829   version : library_version,
830   soversion : soversion,
831   darwin_versions : darwin_versions,
832   install : true,
833   include_directories : [configinc, gioinc],
834   #  '$(gio_win32_res_ldflag)',
835   dependencies : [libz_dep, libdl_dep, libmount_dep, libglib_dep,
836                   libgobject_dep, libgmodule_dep, selinux_dep, xattr_dep,
837                   platform_deps, network_libs, libdbuspolicy_dep, libsysprof_capture_dep],
838   c_args : gio_c_args,
839   objc_args : gio_c_args,
840   # intl.lib is not compatible with SAFESEH
841   link_args : [noseh_link_args, glib_link_flags],
842 )
843
844 if get_option('gio_module_dir') != ''
845   pkgconfig_giomodulesdir = join_paths('${prefix}', get_option('gio_module_dir'))
846 else
847   pkgconfig_giomodulesdir = join_paths('${libdir}', 'gio', 'modules')
848 endif
849
850 schemas_subdir = join_paths('glib-2.0', 'schemas')
851
852 libgio_dep = declare_dependency(link_with : libgio,
853   dependencies : [libgmodule_dep, libgobject_dep, gioenumtypes_dep],
854   include_directories : [gioinc])
855
856 pkg.generate(libgio,
857   libraries_private : [osx_ldflags],
858   requires : ['glib-2.0', 'gobject-2.0'],
859   variables : ['datadir=' + join_paths('${prefix}', get_option('datadir')),
860                'schemasdir=' + join_paths('${datadir}', schemas_subdir),
861                'bindir=' + join_paths('${prefix}', get_option('bindir')),
862                'giomoduledir=' + pkgconfig_giomodulesdir,
863                'gio=' + join_paths('${bindir}', 'gio'),
864                'gio_querymodules=' + join_paths('${bindir}', 'gio-querymodules'),
865                'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'),
866                'glib_compile_resources=' + join_paths('${bindir}', 'glib-compile-resources'),
867                'gdbus=' + join_paths('${bindir}', 'gdbus'),
868                'gdbus_codegen=' + join_paths('${bindir}', 'gdbus-codegen'),
869                'gresource=' + join_paths('${bindir}', 'gresource'),
870                'gsettings=' + join_paths('${bindir}', 'gsettings')],
871   version : glib_version,
872   install_dir : glib_pkgconfigreldir,
873   filebase : 'gio-2.0',
874   name : 'GIO',
875   description : 'glib I/O library',
876 )
877
878 if meson.version().version_compare('>=0.54.0')
879   meson.override_dependency('gio-2.0', libgio_dep)
880 endif
881
882
883 if host_system == 'windows'
884   pkg.generate(requires : ['gobject-2.0', 'gmodule-no-export-2.0', 'gio-2.0'],
885     subdirs : ['gio-win32-2.0'],
886     version : glib_version,
887     install_dir : glib_pkgconfigreldir,
888     filebase : 'gio-windows-2.0',
889     name : 'GIO Windows specific APIs',
890     description : 'Windows specific headers for glib I/O library',
891   )
892   if meson.version().version_compare('>=0.54.0')
893     meson.override_dependency('gio-win32-2.0', libgio_dep)
894   endif
895 else
896   pkg.generate(requires : ['gobject-2.0', 'gio-2.0'],
897     subdirs : ['gio-unix-2.0'],
898     version : glib_version,
899     install_dir : glib_pkgconfigreldir,
900     filebase : 'gio-unix-2.0',
901     name : 'GIO unix specific APIs',
902     description : 'unix specific headers for glib I/O library',
903   )
904   if meson.version().version_compare('>=0.54.0')
905     meson.override_dependency('gio-unix-2.0', libgio_dep)
906   endif
907 endif
908
909 if host_system == 'windows'
910   # Hack till https://github.com/mesonbuild/meson/issues/2324 is fixed
911   libgiounix_dep = dependency('', required : false)
912   libgiowin32_dep = libgio_dep
913 else
914   libgiowin32_dep = dependency('', required : false)
915   libgiounix_dep = libgio_dep
916 endif
917
918 # Dependencies used by executables below
919 have_libelf = false
920 libelf = dependency('libelf', version : '>= 0.8.12', required : get_option ('libelf'))
921 if libelf.found()
922   have_libelf = true
923 else
924   # This fallback is necessary on *BSD. elfutils isn't the only libelf
925   # implementation, and *BSD usually includes their own libelf as a system
926   # library which doesn't have a corresponding .pc file.
927   libelf = cc.find_library('elf', required : get_option ('libelf'))
928   have_libelf = libelf.found()
929   have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf)
930   have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf)
931   have_libelf = have_libelf and cc.has_function('elf_getshdrnum', dependencies : libelf)
932   have_libelf = have_libelf and cc.has_header('libelf.h')
933 endif
934
935 if have_libelf
936   glib_conf.set('HAVE_LIBELF', 1)
937 else
938   libelf = []
939 endif
940
941 gconstructor_as_data_h = custom_target('gconstructor_as_data.h',
942     input : ['data-to-c.py', files('../glib/gconstructor.h')],
943     output : ['gconstructor_as_data.h'],
944     command : [python, '@INPUT0@', '@INPUT1@', 'gconstructor_code', '@OUTPUT@'])
945
946 # Several installed executables
947 gio_tool_sources = [
948   'gio-tool.c',
949   'gio-tool.h',
950   'gio-tool-cat.c',
951   'gio-tool-copy.c',
952   'gio-tool-info.c',
953   'gio-tool-launch.c',
954   'gio-tool-list.c',
955   'gio-tool-mime.c',
956   'gio-tool-mkdir.c',
957   'gio-tool-monitor.c',
958   'gio-tool-mount.c',
959   'gio-tool-move.c',
960   'gio-tool-open.c',
961   'gio-tool-rename.c',
962   'gio-tool-remove.c',
963   'gio-tool-save.c',
964   'gio-tool-set.c',
965   'gio-tool-trash.c',
966   'gio-tool-tree.c',
967 ]
968
969 executable('gio', gio_tool_sources,
970   install : true,
971   c_args : gio_c_args,
972   # intl.lib is not compatible with SAFESEH
973   link_args : noseh_link_args,
974   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
975
976 executable('gresource', 'gresource-tool.c',
977   install : true,
978   # intl.lib is not compatible with SAFESEH
979   link_args : noseh_link_args,
980   dependencies : [libelf, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
981
982 gio_querymodules = executable('gio-querymodules', 'gio-querymodules.c', 'giomodule-priv.c',
983   install : true,
984   c_args : gio_c_args,
985   # intl.lib is not compatible with SAFESEH
986   link_args : noseh_link_args,
987   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
988
989 glib_compile_schemas = executable('glib-compile-schemas',
990   ['gvdb/gvdb-builder.c', 'glib-compile-schemas.c'],
991   install : true,
992   # intl.lib is not compatible with SAFESEH
993   link_args : noseh_link_args,
994   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
995
996 glib_compile_resources = executable('glib-compile-resources',
997   [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-resources.c'],
998   install : true,
999   c_args : gio_c_args,
1000   # intl.lib is not compatible with SAFESEH
1001   link_args : noseh_link_args,
1002   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
1003
1004 # Cannot override those programs in cross compilation case because they are
1005 # native executables that cannot be run on the build machine.
1006 # See https://gitlab.gnome.org/GNOME/glib/issues/1859.
1007 if not meson.is_cross_build()
1008   meson.override_find_program('glib-compile-schemas', glib_compile_schemas)
1009   meson.override_find_program('glib-compile-resources', glib_compile_resources)
1010   meson.override_find_program('gio-querymodules', gio_querymodules)
1011 endif
1012
1013 executable('gsettings', 'gsettings-tool.c',
1014   install : true,
1015   c_args : gio_c_args,
1016   # intl.lib is not compatible with SAFESEH
1017   link_args : noseh_link_args,
1018   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
1019 install_data('gschema.dtd',
1020   install_dir : join_paths(get_option('datadir'), schemas_subdir))
1021
1022 install_data(['gschema.loc', 'gschema.its'],
1023   install_dir : join_paths(get_option('datadir'), 'gettext/its'))
1024
1025 executable('gdbus', 'gdbus-tool.c',
1026   install : true,
1027   c_args : gio_c_args,
1028   # intl.lib is not compatible with SAFESEH
1029   link_args : noseh_link_args,
1030   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
1031
1032 if host_system != 'windows' and not glib_have_cocoa
1033   executable('gapplication', 'gapplication-tool.c',
1034     install : true,
1035     c_args : gio_c_args,
1036     # intl.lib is not compatible with SAFESEH
1037     link_args : noseh_link_args,
1038     dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
1039 endif
1040
1041 if enable_systemtap
1042   gio_stp = configure_file(input : 'gio.stp.in',
1043     output : '@0@.stp'.format(libgio.full_path().split('/').get(-1)),
1044     configuration : stp_cdata,
1045     install_dir : tapset_install_dir,
1046   )
1047 endif
1048
1049 subdir('fam')
1050 if build_tests
1051     subdir('tests')
1052 endif
1053
1054 # The following is an example for building internal marshallers that are used
1055 # by GIO. We cannot guarantee glib-genmarshal availability while building GLib
1056 # so they are pre-generated and placed into gmarshal-internal.[ch].
1057 #
1058 # gmarshal_internal = gnome.genmarshal('gmarshal-internal',
1059 #   sources: 'gmarshal-internal.list',
1060 #   prefix: '_g_cclosure_marshal',
1061 #   valist_marshallers: true,
1062 #   internal: true,
1063 # )