4b2c8f2caf9679dc186d97690f795b0793317da5
[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 pkg.generate(libraries : libgio,
808   libraries_private : [osx_ldflags],
809   requires : ['glib-2.0', 'gobject-2.0'],
810   variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
811                'giomoduledir=' + giomodulesdir,
812                'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'),
813                'glib_compile_resources=' + join_paths('${bindir}', 'glib-compile-resources'),
814                'gdbus_codegen=' + join_paths('${bindir}', 'gdbus-codegen')],
815   version : glib_version,
816   install_dir : glib_pkgconfigreldir,
817   filebase : 'gio-2.0',
818   name : 'GIO',
819   description : 'glib I/O library',
820 )
821
822 if host_system == 'windows'
823   pkg.generate(requires : ['gobject-2.0', 'gmodule-no-export-2.0', 'gio-2.0'],
824     subdirs : ['gio-win32-2.0'],
825     version : glib_version,
826     install_dir : glib_pkgconfigreldir,
827     filebase : 'gio-windows-2.0',
828     name : 'GIO Windows specific APIs',
829     description : 'Windows specific headers for glib I/O library',
830   )
831 else
832   pkg.generate(requires : ['gobject-2.0', 'gio-2.0'],
833     subdirs : ['gio-unix-2.0'],
834     version : glib_version,
835     install_dir : glib_pkgconfigreldir,
836     filebase : 'gio-unix-2.0',
837     name : 'GIO unix specific APIs',
838     description : 'unix specific headers for glib I/O library',
839   )
840 endif
841
842 libgio_dep = declare_dependency(link_with : libgio,
843   dependencies : [gioenumtypes_dep],
844   # We sadly need to export configinc here because everyone includes <gio/*.h>
845   include_directories : [configinc, gioinc])
846
847 if host_system == 'windows'
848   # Hack till https://github.com/mesonbuild/meson/issues/2324 is fixed
849   libgiounix_dep = dependency('', required : false)
850   libgiowin32_dep = libgio_dep
851 else
852   libgiowin32_dep = dependency('', required : false)
853   libgiounix_dep = libgio_dep
854 endif
855
856 # Dependencies used by executables below
857 have_libelf = false
858 libelf = dependency('libelf', version : '>= 0.8.12', required : false)
859 if libelf.found()
860   have_libelf = true
861 else
862   # This fallback is necessary on *BSD. elfutils isn't the only libelf
863   # implementation, and *BSD usually includes their own libelf as a system
864   # library which doesn't have a corresponding .pc file.
865   libelf = cc.find_library('elf', required : false)
866   have_libelf = libelf.found()
867   have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf)
868   have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf)
869   have_libelf = have_libelf and cc.has_function('elf_getshdrnum', dependencies : libelf)
870   have_libelf = have_libelf and cc.has_header('libelf.h')
871 endif
872
873 if have_libelf
874   glib_conf.set('HAVE_LIBELF', 1)
875 else
876   libelf = []
877 endif
878
879 gconstructor_as_data_h = custom_target('gconstructor_as_data.h',
880     input : ['data-to-c.py', files('../glib/gconstructor.h')],
881     output : ['gconstructor_as_data.h'],
882     command : [python, '@INPUT0@', '@INPUT1@', 'gconstructor_code', '@OUTPUT@'])
883
884 # Several installed executables
885 gio_tool_sources = [
886   'gio-tool.c',
887   'gio-tool.h',
888   'gio-tool-cat.c',
889   'gio-tool-copy.c',
890   'gio-tool-info.c',
891   'gio-tool-list.c',
892   'gio-tool-mime.c',
893   'gio-tool-mkdir.c',
894   'gio-tool-monitor.c',
895   'gio-tool-mount.c',
896   'gio-tool-move.c',
897   'gio-tool-open.c',
898   'gio-tool-rename.c',
899   'gio-tool-remove.c',
900   'gio-tool-save.c',
901   'gio-tool-set.c',
902   'gio-tool-trash.c',
903   'gio-tool-tree.c',
904 ]
905
906 executable('gio', gio_tool_sources,
907   install : true,
908   c_args : gio_c_args,
909   # intl.lib is not compatible with SAFESEH
910   link_args : noseh_link_args,
911   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
912
913 executable('gresource', 'gresource-tool.c',
914   install : true,
915   # intl.lib is not compatible with SAFESEH
916   link_args : noseh_link_args,
917   dependencies : [libelf, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
918
919 gio_querymodules = executable('gio-querymodules', 'gio-querymodules.c', 'giomodule-priv.c',
920   install : true,
921   c_args : gio_c_args,
922   # intl.lib is not compatible with SAFESEH
923   link_args : noseh_link_args,
924   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
925
926 glib_compile_schemas = executable('glib-compile-schemas',
927   [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-schemas.c'],
928   install : true,
929   # intl.lib is not compatible with SAFESEH
930   link_args : noseh_link_args,
931   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
932
933 glib_compile_resources = executable('glib-compile-resources',
934   [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-resources.c'],
935   install : true,
936   c_args : gio_c_args,
937   # intl.lib is not compatible with SAFESEH
938   link_args : noseh_link_args,
939   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
940
941 executable('gsettings', 'gsettings-tool.c',
942   install : true,
943   c_args : gio_c_args,
944   # intl.lib is not compatible with SAFESEH
945   link_args : noseh_link_args,
946   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
947 install_data('gschema.dtd',
948   install_dir : join_paths(get_option('datadir'), 'glib-2.0/schemas'))
949
950 install_data(['gschema.loc', 'gschema.its'],
951   install_dir : join_paths(get_option('datadir'), 'gettext/its'))
952
953 executable('gdbus', 'gdbus-tool.c',
954   install : true,
955   c_args : gio_c_args,
956   # intl.lib is not compatible with SAFESEH
957   link_args : noseh_link_args,
958   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
959
960 if host_system != 'windows' and not glib_have_cocoa
961   executable('gapplication', 'gapplication-tool.c',
962     install : true,
963     c_args : gio_c_args,
964     # intl.lib is not compatible with SAFESEH
965     link_args : noseh_link_args,
966     dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
967 endif
968
969 if enable_systemtap
970   gio_stp = configure_file(input : 'gio.stp.in',
971     output : '@0@.stp'.format(libgio.full_path().split('/').get(-1)),
972     configuration : stp_cdata,
973     install_dir : tapset_install_dir,
974     install : true)
975 endif
976
977 subdir('fam')
978
979 if host_system != 'windows'
980   subdir('tests')
981 endif