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