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