meson.build 28.7 KB
Newer Older
1 2 3
gio_c_args = [
  '-DG_LOG_DOMAIN="GLib-GIO"',
  '-DGIO_COMPILATION',
4
  '-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
5 6
]

7 8
gio_c_args += glib_hidden_visibility_args

9 10
# FIXME: Install empty glib_giomodulesdir

11 12 13 14 15
gnetworking_h_conf = configuration_data()

gnetworking_h_wspiapi_include = ''
gnetworking_h_nameser_compat_include = ''

16
if host_system == 'windows'
17 18 19 20
  # <wspiapi.h> in the Windows SDK and in mingw-w64 has wrappers for
  # inline workarounds for getaddrinfo, getnameinfo and freeaddrinfo if
  # they aren't present at run-time (on Windows 2000).
  gnetworking_h_wspiapi_include = '#include <wspiapi.h>'
21 22 23
elif not host_system.contains('android')
  # Don't check for C_IN on Android since it does not define it in public
  # headers, we define it ourselves wherever necessary
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  if not cc.compiles('''#include <sys/types.h>
                        #include <arpa/nameser.h>
                        int qclass = C_IN;''',
                     name : 'C_IN in public headers (no arpa/nameser_compat.h needed)')
    if cc.compiles('''#include <sys/types.h>
                      #include <arpa/nameser.h>
                      #include <arpa/nameser_compat.h>
                      int qclass = C_IN;''',
                   name : 'arpa/nameser_compat.h needed for C_IN')
      gnetworking_h_nameser_compat_include = '#include <arpa/nameser_compat.h>'
    else
      error('Could not find required includes for ARPA C_IN')
    endif
  endif
endif

network_libs = [ ]
network_args = [ ]
42
if host_system != 'windows'
43 44 45 46 47 48 49 50 51 52 53
  # res_query()
  res_query_test = '''#include <resolv.h>
                      int main (int argc, char ** argv) {
                        return res_query("test", 0, 0, (void *)0, 0);
                      }'''
  res_query_test_full = '''#include <sys/types.h>
                           #include <netinet/in.h>
                           #include <arpa/nameser.h>
                        ''' + res_query_test
  if not cc.links(res_query_test_full, name : 'res_query()')
    if cc.links(res_query_test_full, args : '-lresolv', name : 'res_query() in -lresolv')
54
      network_libs += [ cc.find_library('resolv') ]
55 56
      network_args += [ '-lresolv' ]
    elif cc.links(res_query_test, args : '-lbind', name : 'res_query() in -lbind')
57
      network_libs += [ cc.find_library('bind') ]
58 59 60 61 62 63 64 65 66 67 68 69 70 71
      network_args += [ '-lbind' ]
    else
      error('Could not find res_query()')
    endif
  endif

  # socket()
  socket_test = '''#include <sys/types.h>
                   #include <sys/socket.h>
                   int main (int argc, char ** argv) {
                     return socket(1, 2, 3);
                   }'''
  if not cc.links(socket_test, name : 'socket()')
    if cc.links(socket_test, args : '-lsocket', name : 'socket() in -lsocket')
72
      network_libs += [ cc.find_library('socket') ]
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
      network_args += [ '-lsocket' ]
    else
      error('Could not find socket()')
    endif
  endif

  # res_init()
  if cc.links('''#include <sys/types.h>
                 #include <netinet/in.h>
                 #include <arpa/nameser.h>
                 #include <resolv.h>
                 int main (int argc, char ** argv) {
                   return res_init();
                 }''', args : network_args, name : 'res_init()')
    glib_conf.set('HAVE_RES_INIT', 1)
  endif

90 91 92 93 94 95 96
  # res_nclose()
  if cc.links('''#include <sys/types.h>
                 #include <netinet/in.h>
                 #include <arpa/nameser.h>
                 #include <resolv.h>
                 int main (int argc, char ** argv) {
                   struct __res_state res;
97 98
                   res_nclose(&res);
                   return 0;
99 100 101 102 103 104 105 106 107 108 109
                 }''', args : network_args, name : 'res_nclose()')
    glib_conf.set('HAVE_RES_NCLOSE', 1)
  endif

  # res_ndestroy()
  if cc.links('''#include <sys/types.h>
                 #include <netinet/in.h>
                 #include <arpa/nameser.h>
                 #include <resolv.h>
                 int main (int argc, char ** argv) {
                   struct __res_state res;
110 111
                   res_ndestroy(&res);
                   return 0;
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
                 }''', args : network_args, name : 'res_ndestroy()')
    glib_conf.set('HAVE_RES_NDESTROY', 1)
  endif

  # res_ninit()
  if cc.links('''#include <sys/types.h>
                 #include <netinet/in.h>
                 #include <arpa/nameser.h>
                 #include <resolv.h>
                 int main (int argc, char ** argv) {
                   struct __res_state res;
                   return res_ninit(&res);
                 }''', args : network_args, name : 'res_ninit()')
    glib_conf.set('HAVE_RES_NINIT', 1)
  endif

  # res_nquery()
  if cc.links('''#include <sys/types.h>
                 #include <netinet/in.h>
                 #include <arpa/nameser.h>
                 #include <resolv.h>
                 int main (int argc, char ** argv) {
                   struct __res_state res;
                   return res_nquery(&res, "test", 0, 0, (void *)0, 0);
                 }''', args : network_args, name : 'res_nquery()')
    glib_conf.set('HAVE_RES_NQUERY', 1)
  endif

140 141
  if cc.has_type('struct ip_mreqn', prefix : '#include <netinet/in.h>')
    glib_conf.set('HAVE_IP_MREQN', 1)
142
  endif
143 144 145 146 147 148 149 150 151 152 153 154

  if cc.compiles('''#include <sys/ioctl.h>
                    #include <net/if.h>
                    int main (int argc, char ** argv) {
                      struct ifreq ifr;
                      ioctl(0, SIOCGIFADDR, &ifr);
                      return 0;
                    }''',
                 name : 'ioctl with request SIOCGIFADDR')
    glib_conf.set('HAVE_SIOCGIFADDR', '/**/')
  endif

155 156 157 158 159
endif

if host_system.contains('android')
  # struct ip_mreq_source definition is broken on Android NDK <= r16
  # See https://bugzilla.gnome.org/show_bug.cgi?id=740791
160 161 162 163 164 165 166 167 168
  if not cc.compiles('''#include <netinet/in.h>
                        int main(int argc, char ** argv) {
                          struct ip_mreq_source mc_req_src;
                          mc_req_src.imr_interface.s_addr = 0;
                          return 0;
                        }''',
                        name : 'ip_mreq_source.imr_interface has s_addr member')
    glib_conf.set('BROKEN_IP_MREQ_SOURCE_STRUCT', 1)
  endif
169 170 171 172 173 174 175
endif

gnetworking_h_conf.set('WSPIAPI_INCLUDE', gnetworking_h_wspiapi_include)
gnetworking_h_conf.set('NAMESER_COMPAT_INCLUDE', gnetworking_h_nameser_compat_include)

gnetworking_h = configure_file(input : 'gnetworking.h.in',
                               output : 'gnetworking.h',
176
                               install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'),
177 178
                               configuration : gnetworking_h_conf)

179
gdbus_headers = files(
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
  'gdbusauthobserver.h',
  'gcredentials.h',
  'gdbusutils.h',
  'gdbuserror.h',
  'gdbusaddress.h',
  'gdbusconnection.h',
  'gdbusmessage.h',
  'gdbusnameowning.h',
  'gdbusnamewatching.h',
  'gdbusproxy.h',
  'gdbusintrospection.h',
  'gdbusmethodinvocation.h',
  'gdbusserver.h',
  'gdbusinterface.h',
  'gdbusinterfaceskeleton.h',
  'gdbusobject.h',
  'gdbusobjectskeleton.h',
  'gdbusobjectproxy.h',
  'gdbusobjectmanager.h',
  'gdbusobjectmanagerclient.h',
  'gdbusobjectmanagerserver.h',
  'gtestdbus.h',
202
)
203

204
gdbus_sources = files(
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
  'gdbusutils.c',
  'gdbusaddress.c',
  'gdbusauthobserver.c',
  'gdbusauth.c',
  'gdbusauthmechanism.c',
  'gdbusauthmechanismanon.c',
  'gdbusauthmechanismexternal.c',
  'gdbusauthmechanismsha1.c',
  'gdbuserror.c',
  'gdbusconnection.c',
  'gdbusmessage.c',
  'gdbusnameowning.c',
  'gdbusnamewatching.c',
  'gdbusproxy.c',
  'gdbusprivate.c',
  'gdbusintrospection.c',
  'gdbusmethodinvocation.c',
  'gdbusserver.c',
  'gdbusinterface.c',
  'gdbusinterfaceskeleton.c',
  'gdbusobject.c',
  'gdbusobjectskeleton.c',
  'gdbusobjectproxy.c',
  'gdbusobjectmanager.c',
  'gdbusobjectmanagerclient.c',
  'gdbusobjectmanagerserver.c',
  'gtestdbus.c',
232
)
233

234 235 236
# Generate gdbus-codegen
subdir('gdbus-2.0/codegen')

237 238 239
# Generate xdp-dbus.{c,h}
xdp_dbus_generated = custom_target('xdp-dbus',
    input : ['org.freedesktop.portal.Documents.xml',
240
             'org.freedesktop.portal.OpenURI.xml',
241 242
             'org.freedesktop.portal.ProxyResolver.xml'],
    output : ['xdp-dbus.h', 'xdp-dbus.c'],
243
    depend_files : gdbus_codegen_built_files,
244 245
    command : [python, gdbus_codegen,
               '--interface-prefix', 'org.freedesktop.portal.',
246 247
               '--output-directory', '@OUTDIR@',
               '--generate-c-code', 'xdp-dbus',
248 249 250 251 252
               '--c-namespace', 'GXdp',
               '--annotate', 'org.freedesktop.portal.Documents.Add()',
                             'org.gtk.GDBus.C.UnixFD', 'true',
               '--annotate', 'org.freedesktop.portal.Documents.AddNamed()',
                             'org.gtk.GDBus.C.UnixFD', 'true',
253 254 255 256
               '--annotate', 'org.freedesktop.portal.Documents.AddFull()',
                             'org.gtk.GDBus.C.UnixFD', 'true',
               '--annotate', 'org.freedesktop.portal.OpenURI.OpenFile()',
                             'org.gtk.GDBus.C.UnixFD', 'true',
257 258
               '@INPUT@'])

259 260 261 262
# Generate gdbus-generated.{c,h}
gdbus_daemon_generated = custom_target('gdbus-daemon-generated',
    input : ['dbus-daemon.xml'],
    output : ['gdbus-daemon-generated.h', 'gdbus-daemon-generated.c'],
263
    depend_files : gdbus_codegen_built_files,
264 265
    command : [python, gdbus_codegen,
               '--interface-prefix', 'org.',
266 267
               '--output-directory', '@OUTDIR@',
               '--generate-c-code', 'gdbus-daemon-generated',
268
               '--c-namespace', '_G', '@INPUT@'])
269

270
settings_headers = files(
271 272 273
  'gsettingsbackend.h',
  'gsettingsschema.h',
  'gsettings.h',
274
)
275

276
settings_sources = files(
277 278 279 280 281 282 283 284 285
  'gvdb/gvdb-reader.c',
  'gdelayedsettingsbackend.c',
  'gkeyfilesettingsbackend.c',
  'gmemorysettingsbackend.c',
  'gnullsettingsbackend.c',
  'gsettingsbackend.c',
  'gsettingsschema.c',
  'gsettings-mapping.c',
  'gsettings.c',
286
)
287

288
if host_system == 'windows'
289
  settings_sources += files('gregistrysettingsbackend.c')
290 291
endif

292
application_headers = files(
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
  'gapplication.h',
  'gapplicationcommandline.h',

  'gactiongroup.h',
  'gactionmap.h',
  'gsimpleactiongroup.h',
  'gremoteactiongroup.h',
  'gactiongroupexporter.h',
  'gdbusactiongroup.h',
  'gaction.h',
  'gpropertyaction.h',
  'gsimpleaction.h',

  'gmenumodel.h',
  'gmenu.h',
  'gmenuexporter.h',
  'gdbusmenumodel.h',
  'gnotification.h',
311
)
312

313
application_sources = files(
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
  'gapplication.c',
  'gapplicationcommandline.c',
  'gapplicationimpl-dbus.c',

  'gactiongroup.c',
  'gactionmap.c',
  'gsimpleactiongroup.c',
  'gremoteactiongroup.c',
  'gactiongroupexporter.c',
  'gdbusactiongroup.c',
  'gaction.c',
  'gpropertyaction.c',
  'gsimpleaction.c',

  'gmenumodel.c',
  'gmenu.c',
  'gmenuexporter.c',
  'gdbusmenumodel.c',
  'gnotification.c',
  'gnotificationbackend.c',
334
)
335

336
local_sources = files(
337 338 339 340 341 342 343 344 345 346 347 348 349
  'ghttpproxy.c',
  'glocalfile.c',
  'glocalfileenumerator.c',
  'glocalfileinfo.c',
  'glocalfileinputstream.c',
  'glocalfilemonitor.c',
  'glocalfileoutputstream.c',
  'glocalfileiostream.c',
  'glocalvfs.c',
  'gsocks4proxy.c',
  'gsocks4aproxy.c',
  'gsocks5proxy.c',
  'thumbnail-verify.c',
350
)
351

352 353
platform_deps = []
internal_deps = []
354 355 356 357 358 359
# TODO: internal_objects is a workaround for
# <https://github.com/mesonbuild/meson/issues/3934> and
# <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
# on a meson version where those are fixed, revert the commit that
# introduced this workaround.
internal_objects = []
360
appinfo_sources = []
361
contenttype_sources = []
362
portal_sources = []
363
unix_sources = []
364 365 366 367 368 369 370
win32_sources = []

# This is also used by tests/gdbus-daemon, so use files() to include the path
gdbus_daemon_sources = [
  files('gdbusdaemon.c'),
  gdbus_daemon_generated,
]
371

372
if host_system != 'windows'
373
  unix_sources = files(
374 375 376 377 378 379 380 381 382 383 384 385 386 387
    'gfiledescriptorbased.c',
    'gunixconnection.c',
    'gunixcredentialsmessage.c',
    'gunixfdlist.c',
    'gunixfdmessage.c',
    'gunixmount.c',
    'gunixmounts.c',
    'gunixsocketaddress.c',
    'gunixvolume.c',
    'gunixvolumemonitor.c',
    'gunixinputstream.c',
    'gunixoutputstream.c',
    'gfdonotificationbackend.c',
    'ggtknotificationbackend.c',
388
  )
389

390
  portal_sources = [files(
391
    'gdocumentportal.c',
392
    'gopenuriportal.c',
393 394 395
    'gnetworkmonitorportal.c',
    'gproxyresolverportal.c',
    'gportalsupport.c',
396
    'gportalnotificationbackend.c'),
397 398 399
    xdp_dbus_generated
  ]

400
  gio_unix_include_headers = files(
401 402 403 404 405 406 407 408 409
    'gfiledescriptorbased.h',
    'gunixconnection.h',
    'gunixcredentialsmessage.h',
    'gunixmounts.h',
    'gunixfdlist.h',
    'gunixfdmessage.h',
    'gunixinputstream.h',
    'gunixoutputstream.h',
    'gunixsocketaddress.h',
410
  )
411 412

  if glib_have_cocoa
413 414 415
    settings_sources += files('gnextstepsettingsbackend.m')
    contenttype_sources += files('gosxcontenttype.m')
    appinfo_sources += files('gosxappinfo.m')
416
    if glib_have_os_x_9_or_later
417
      unix_sources += files('gcocoanotificationbackend.m')
418 419
    endif
  else
420 421 422
    contenttype_sources += files('gcontenttype.c')
    appinfo_sources += files('gdesktopappinfo.c')
    gio_unix_include_headers += files('gdesktopappinfo.h')
423 424 425 426 427 428

    executable('gio-launch-desktop', 'gio-launch-desktop.c',
      install : true,
      c_args : gio_c_args,
      # intl.lib is not compatible with SAFESEH
      link_args : noseh_link_args)
429 430
  endif

431 432
  subdir('xdgmime')
  internal_deps += [xdgmime_lib]
433
  internal_objects += [xdgmime_lib.extract_all_objects()]
434

435 436 437
  install_headers(gio_unix_include_headers, subdir : 'gio-unix-2.0/gio')

  if glib_conf.has('HAVE_NETLINK')
438
    unix_sources += files(
439 440
      'gnetworkmonitornetlink.c',
      'gnetworkmonitornm.c',
441
    )
442
  endif
443
else
444 445
  appinfo_sources += files('gwin32appinfo.c')
  contenttype_sources += files('gcontenttype-win32.c')
446 447
  platform_deps += [cc.find_library('shlwapi'),
                    cc.find_library('dnsapi'),
448
                    iphlpapi_dep,
449
                    winsock2]
450
  win32_sources += files(
451 452 453 454 455
    'gwin32registrykey.c',
    'gwin32mount.c',
    'gwin32volumemonitor.c',
    'gwin32inputstream.c',
    'gwin32outputstream.c',
456 457
    'gwin32networkmonitor.c',
    'gwin32networkmonitor.h',
458
    'gwin32notificationbackend.c',
459
  )
460

461 462 463 464 465 466 467 468
  gio_win_rc = configure_file(
    input: 'gio.rc.in',
    output: 'gio.rc',
    configuration: glibconfig_conf,
  )
  gio_win_res = windows.compile_resources(gio_win_rc)
  win32_sources += [gio_win_res]

469
  gio_win32_include_headers = files(
470 471
    'gwin32inputstream.h',
    'gwin32outputstream.h',
472
  )
473 474 475
  install_headers(gio_win32_include_headers, subdir : 'gio-win32-2.0/gio')
endif

476
gio_sources = files(
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
  'gappinfo.c',
  'gasynchelper.c',
  'gasyncinitable.c',
  'gasyncresult.c',
  'gbufferedinputstream.c',
  'gbufferedoutputstream.c',
  'gbytesicon.c',
  'gcancellable.c',
  'gcharsetconverter.c',
  'gcontextspecificgroup.c',
  'gconverter.c',
  'gconverterinputstream.c',
  'gconverteroutputstream.c',
  'gcredentials.c',
  'gdatagrambased.c',
  'gdatainputstream.c',
  'gdataoutputstream.c',
  'gdrive.c',
  'gdummyfile.c',
  'gdummyproxyresolver.c',
  'gdummytlsbackend.c',
  'gemblem.c',
  'gemblemedicon.c',
  'gfile.c',
  'gfileattribute.c',
  'gfileenumerator.c',
  'gfileicon.c',
  'gfileinfo.c',
  'gfileinputstream.c',
  'gfilemonitor.c',
  'gfilenamecompleter.c',
  'gfileoutputstream.c',
  'gfileiostream.c',
  'gfilterinputstream.c',
  'gfilteroutputstream.c',
  'gicon.c',
  'ginetaddress.c',
  'ginetaddressmask.c',
  'ginetsocketaddress.c',
  'ginitable.c',
  'ginputstream.c',
  'gioerror.c',
  'giomodule.c',
520
  'giomodule-priv.c',
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
  'gioscheduler.c',
  'giostream.c',
  'gloadableicon.c',
  'gmount.c',
  'gmemoryinputstream.c',
  'gmemoryoutputstream.c',
  'gmountoperation.c',
  'gnativevolumemonitor.c',
  'gnativesocketaddress.c',
  'gnetworkaddress.c',
  'gnetworking.c',
  'gnetworkmonitor.c',
  'gnetworkmonitorbase.c',
  'gnetworkservice.c',
  'goutputstream.c',
  'gpermission.c',
  'gpollableinputstream.c',
  'gpollableoutputstream.c',
  'gpollableutils.c',
  'gpollfilemonitor.c',
  'gproxy.c',
  'gproxyaddress.c',
  'gproxyaddressenumerator.c',
  'gproxyresolver.c',
  'gresolver.c',
  'gresource.c',
  'gresourcefile.c',
  'gseekable.c',
  'gsimpleasyncresult.c',
  'gsimpleiostream.c',
  'gsimplepermission.c',
  'gsocket.c',
  'gsocketaddress.c',
  'gsocketaddressenumerator.c',
  'gsocketclient.c',
  'gsocketconnectable.c',
  'gsocketconnection.c',
  'gsocketcontrolmessage.c',
  'gsocketinputstream.c',
  'gsocketlistener.c',
  'gsocketoutputstream.c',
  'gsubprocesslauncher.c',
  'gsubprocess.c',
  'gsocketservice.c',
  'gsrvtarget.c',
  'gsimpleproxyresolver.c',
  'gtask.c',
  'gtcpconnection.c',
  'gtcpwrapperconnection.c',
  'gthreadedsocketservice.c',
  'gthemedicon.c',
  'gthreadedresolver.c',
  'gthreadedresolver.h',
  'gtlsbackend.c',
  'gtlscertificate.c',
  'gtlsclientconnection.c',
  'gtlsconnection.c',
  'gtlsdatabase.c',
  'gtlsfiledatabase.c',
  'gtlsinteraction.c',
  'gtlspassword.c',
  'gtlsserverconnection.c',
  'gdtlsconnection.c',
  'gdtlsclientconnection.c',
  'gdtlsserverconnection.c',
  'gunionvolumemonitor.c',
  'gvfs.c',
  'gvolume.c',
  'gvolumemonitor.c',
  'gzlibcompressor.c',
  'gzlibdecompressor.c',
  'glistmodel.c',
  'gliststore.c',
594
)
595 596

gio_sources += appinfo_sources
597
gio_sources += contenttype_sources
598
gio_sources += gdbus_daemon_sources
599
gio_sources += unix_sources
600
gio_sources += win32_sources
601 602 603
gio_sources += application_sources
gio_sources += settings_sources
gio_sources += gdbus_sources
604
gio_sources += portal_sources
605 606
gio_sources += local_sources

607
MISSING_STUFF = '''
608 609 610 611 612 613 614 615 616 617 618
# This is read by gobject-introspection/misc/ and gtk-doc
gio-public-headers.txt: Makefile
  '$(AM_V_GEN) echo $(gioinclude_HEADERS) $(giowin32include_HEADERS) $(giounixinclude_HEADERS) > $@.tmp && mv $@.tmp $@

gio.def: libgio-2.0.la
  '$(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

gio-2.0.lib: libgio-2.0.la gio.def
  '$(AM_V_GEN) lib.exe -machine:@LIB_EXE_MACHINE_FLAG@ -name:libgio-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(builddir)/gio.def -out:$@
'''

619
gio_headers = files(
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
  'gappinfo.h',
  'gasyncinitable.h',
  'gasyncresult.h',
  'gbufferedinputstream.h',
  'gbufferedoutputstream.h',
  'gbytesicon.h',
  'gcancellable.h',
  'gcontenttype.h',
  'gcharsetconverter.h',
  'gconverter.h',
  'gconverterinputstream.h',
  'gconverteroutputstream.h',
  'gdatagrambased.h',
  'gdatainputstream.h',
  'gdataoutputstream.h',
  'gdrive.h',
  'gemblem.h',
  'gemblemedicon.h',
  'gfile.h',
  'gfileattribute.h',
  'gfileenumerator.h',
  'gfileicon.h',
  'gfileinfo.h',
  'gfileinputstream.h',
  'gfilemonitor.h',
  'gfilenamecompleter.h',
  'gfileoutputstream.h',
  'gfileiostream.h',
  'gfilterinputstream.h',
  'gfilteroutputstream.h',
  'gicon.h',
  'ginetaddress.h',
  'ginetaddressmask.h',
  'ginetsocketaddress.h',
  'ginputstream.h',
  'ginitable.h',
  'gio.h',
  'gio-autocleanups.h',
  'giotypes.h',
  'gioenums.h',
  'gioerror.h',
  'giomodule.h',
  'gioscheduler.h',
  'giostream.h',
  'gloadableicon.h',
  'gmount.h',
  'gmemoryinputstream.h',
  'gmemoryoutputstream.h',
  'gmountoperation.h',
  'gnativevolumemonitor.h',
  'gnetworkaddress.h',
  'gnetworkmonitor.h',
  'gnetworkservice.h',
  'goutputstream.h',
  'gpermission.h',
  'gpollableinputstream.h',
  'gpollableoutputstream.h',
  'gpollableutils.h',
  'gproxyaddress.h',
  'gproxy.h',
  'gproxyaddressenumerator.h',
  'gproxyresolver.h',
  'gresolver.h',
  'gresource.h',
  'gseekable.h',
  'gsimpleasyncresult.h',
  'gsimpleiostream.h',
  'gsimplepermission.h',
  'gsocket.h',
  'gsocketaddress.h',
  'gsocketaddressenumerator.h',
  'gsocketclient.h',
  'gsocketconnectable.h',
  'gsocketconnection.h',
  'gsocketcontrolmessage.h',
  'gsocketlistener.h',
  'gsocketservice.h',
  'gsrvtarget.h',
  'gsimpleproxyresolver.h',
  'gtask.h',
  'gsubprocess.h',
  'gsubprocesslauncher.h',
  'gtcpconnection.h',
  'gtcpwrapperconnection.h',
  'gthreadedsocketservice.h',
  'gthemedicon.h',
  'gtlsbackend.h',
  'gtlscertificate.h',
  'gtlsclientconnection.h',
  'gtlsconnection.h',
  'gtlsdatabase.h',
  'gtlsfiledatabase.h',
  'gtlsinteraction.h',
  'gtlspassword.h',
  'gtlsserverconnection.h',
  'gdtlsconnection.h',
  'gdtlsclientconnection.h',
  'gdtlsserverconnection.h',
  'gvfs.h',
  'gvolume.h',
  'gvolumemonitor.h',
  'gzlibcompressor.h',
  'gzlibdecompressor.h',
  'glistmodel.h',
  'gliststore.h',
725
)
726

727 728 729 730 731
gio_headers += application_headers
gio_headers += settings_headers
gio_headers += gdbus_headers
install_headers(gio_headers, subdir : 'glib-2.0/gio/')

732 733
# We can't use gnome.mkenums() because the GNOME module looks for glib-mkenums
# in PATH, which means you can't bootstrap glib with its own glib-mkenums.
734 735
gioenumtypes_h = custom_target('gioenumtypes_h',
  output : 'gioenumtypes.h',
736
  capture : true,
737 738
  input : gio_headers,
  install : true,
739
  install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'),
740
  command : [python, glib_mkenums,
741
             '--template', files('gioenumtypes.h.template'),
742
             '@INPUT@', gnetworking_h])
743 744 745

gioenumtypes_c = custom_target('gioenumtypes_c',
  output : 'gioenumtypes.c',
746
  capture : true,
747
  input : gio_headers,
748
  depends : [gioenumtypes_h],
749
  command : [python, glib_mkenums,
750
             '--template', files('gioenumtypes.c.template'),
751 752 753 754 755 756 757 758
             '@INPUT@', gnetworking_h])

gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h])

# inotify
if glib_conf.has('HAVE_SYS_INOTIFY_H') and have_func_inotify_init1
  subdir('inotify')
  internal_deps += [ inotify_lib ]
759
  internal_objects += [inotify_lib.extract_all_objects()]
760 761 762 763 764 765
endif

# kevent
if have_func_kqueue and have_func_kevent
  subdir('kqueue')
  internal_deps += [ kqueue_lib ]
766
  internal_objects += [kqueue_lib.extract_all_objects()]
767 768 769 770 771
endif

if host_system == 'windows'
  subdir('win32')
  internal_deps += [ giowin32_lib ]
772
  internal_objects += [giowin32_lib.extract_all_objects()]
773
endif
774

775 776 777 778
if have_bash
  install_data([
    'completion/gapplication',
    'completion/gdbus',
779
    'completion/gio',
780 781 782 783 784
    'completion/gsettings',
    'completion/gresource'
  ],
  install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'))
endif
785

786 787 788 789 790 791 792 793
if enable_dtrace
  gio_dtrace_obj = dtrace_obj_gen.process('gio_probes.d')
  gio_dtrace_hdr = dtrace_hdr_gen.process('gio_probes.d')
else
  gio_dtrace_obj = []
  gio_dtrace_hdr = []
endif

794
libgio = library('gio-2.0',
795
  gioenumtypes_h, gioenumtypes_c, gnetworking_h, gio_sources,
796
  gio_dtrace_hdr, gio_dtrace_obj,
797
  objects : internal_objects,
798 799
  version : library_version,
  soversion : soversion,
800
  darwin_versions : darwin_versions,
801
  install : true,
802
  include_directories : [configinc, gioinc],
803
  #  '$(gio_win32_res_ldflag)',
804
  dependencies : [libz_dep, libdl_dep, libmount_dep, libglib_dep,
805 806
                  libgobject_dep, libgmodule_dep, selinux_dep, xattr_dep,
                  platform_deps, network_libs],
807
  c_args : gio_c_args,
808
  objc_args : gio_c_args,
809
  # intl.lib is not compatible with SAFESEH
810
  link_args : [noseh_link_args, glib_link_flags],
811 812
)

813 814 815 816 817
giomodulesdir = get_option('gio_module_dir')
if giomodulesdir == ''
  giomodulesdir = join_paths('${libdir}', 'gio', 'modules')
endif

818 819
schemas_subdir = join_paths('glib-2.0', 'schemas')

820
pkg.generate(libgio,
821
  libraries_private : [osx_ldflags],
822
  requires : ['glib-2.0', 'gobject-2.0'],
823 824 825
  variables : ['datadir=' + join_paths('${prefix}', get_option('datadir')),
               'schemasdir=' + join_paths('${datadir}', schemas_subdir),
               'bindir=' + join_paths('${prefix}', get_option('bindir')),
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
               'giomoduledir=' + giomodulesdir,
               'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'),
               'glib_compile_resources=' + join_paths('${bindir}', 'glib-compile-resources'),
               'gdbus_codegen=' + join_paths('${bindir}', 'gdbus-codegen')],
  version : glib_version,
  install_dir : glib_pkgconfigreldir,
  filebase : 'gio-2.0',
  name : 'GIO',
  description : 'glib I/O library',
)

if host_system == 'windows'
  pkg.generate(requires : ['gobject-2.0', 'gmodule-no-export-2.0', 'gio-2.0'],
    subdirs : ['gio-win32-2.0'],
    version : glib_version,
    install_dir : glib_pkgconfigreldir,
    filebase : 'gio-windows-2.0',
    name : 'GIO Windows specific APIs',
    description : 'Windows specific headers for glib I/O library',
  )
else
  pkg.generate(requires : ['gobject-2.0', 'gio-2.0'],
    subdirs : ['gio-unix-2.0'],
    version : glib_version,
    install_dir : glib_pkgconfigreldir,
    filebase : 'gio-unix-2.0',
    name : 'GIO unix specific APIs',
    description : 'unix specific headers for glib I/O library',
  )
endif

857
libgio_dep = declare_dependency(link_with : libgio,
858 859
  dependencies : [libgmodule_dep, libgobject_dep, gioenumtypes_dep],
  include_directories : [gioinc])
860

861 862 863 864 865 866 867 868 869
if host_system == 'windows'
  # Hack till https://github.com/mesonbuild/meson/issues/2324 is fixed
  libgiounix_dep = dependency('', required : false)
  libgiowin32_dep = libgio_dep
else
  libgiowin32_dep = dependency('', required : false)
  libgiounix_dep = libgio_dep
endif

870
# Dependencies used by executables below
871
have_libelf = false
872 873
libelf = dependency('libelf', version : '>= 0.8.12', required : false)
if libelf.found()
874 875 876 877 878 879 880 881 882 883 884 885 886 887
  have_libelf = true
else
  # This fallback is necessary on *BSD. elfutils isn't the only libelf
  # implementation, and *BSD usually includes their own libelf as a system
  # library which doesn't have a corresponding .pc file.
  libelf = cc.find_library('elf', required : false)
  have_libelf = libelf.found()
  have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf)
  have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf)
  have_libelf = have_libelf and cc.has_function('elf_getshdrnum', dependencies : libelf)
  have_libelf = have_libelf and cc.has_header('libelf.h')
endif

if have_libelf
888
  glib_conf.set('HAVE_LIBELF', 1)
889 890
else
  libelf = []
891
endif
892 893

gconstructor_as_data_h = custom_target('gconstructor_as_data.h',
894
    input : ['data-to-c.py', files('../glib/gconstructor.h')],
895 896 897 898
    output : ['gconstructor_as_data.h'],
    command : [python, '@INPUT0@', '@INPUT1@', 'gconstructor_code', '@OUTPUT@'])

# Several installed executables
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
gio_tool_sources = [
  'gio-tool.c',
  'gio-tool.h',
  'gio-tool-cat.c',
  'gio-tool-copy.c',
  'gio-tool-info.c',
  'gio-tool-list.c',
  'gio-tool-mime.c',
  'gio-tool-mkdir.c',
  'gio-tool-monitor.c',
  'gio-tool-mount.c',
  'gio-tool-move.c',
  'gio-tool-open.c',
  'gio-tool-rename.c',
  'gio-tool-remove.c',
  'gio-tool-save.c',
  'gio-tool-set.c',
  'gio-tool-trash.c',
  'gio-tool-tree.c',
]

executable('gio', gio_tool_sources,
  install : true,
922
  c_args : gio_c_args,
923 924
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
925
  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
926

927
executable('gresource', 'gresource-tool.c',
928 929 930
  install : true,
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
931
  dependencies : [libelf, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
932

933
gio_querymodules = executable('gio-querymodules', 'gio-querymodules.c', 'giomodule-priv.c',
934
  install : true,
935
  c_args : gio_c_args,
936 937 938
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
939

940
glib_compile_schemas = executable('glib-compile-schemas',
941 942 943 944
  [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-schemas.c'],
  install : true,
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
945
  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
946

947
glib_compile_resources = executable('glib-compile-resources',
948 949
  [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-resources.c'],
  install : true,
950
  c_args : gio_c_args,
951 952
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
953
  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
954 955 956

executable('gsettings', 'gsettings-tool.c',
  install : true,
957
  c_args : gio_c_args,
958 959
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
960
  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
961
install_data('gschema.dtd',
962
  install_dir : join_paths(get_option('datadir'), schemas_subdir))
963 964

install_data(['gschema.loc', 'gschema.its'],
965
  install_dir : join_paths(get_option('datadir'), 'gettext/its'))
966 967 968

executable('gdbus', 'gdbus-tool.c',
  install : true,
969
  c_args : gio_c_args,
970 971
  # intl.lib is not compatible with SAFESEH
  link_args : noseh_link_args,
972
  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
973

974
if host_system != 'windows' and not glib_have_cocoa
975 976
  executable('gapplication', 'gapplication-tool.c',
    install : true,
977
    c_args : gio_c_args,
978 979
    # intl.lib is not compatible with SAFESEH
    link_args : noseh_link_args,
980
    dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
981 982
endif

983 984 985 986 987 988 989 990
if enable_systemtap
  gio_stp = configure_file(input : 'gio.stp.in',
    output : '@0@.stp'.format(libgio.full_path().split('/').get(-1)),
    configuration : stp_cdata,
    install_dir : tapset_install_dir,
    install : true)
endif

991
subdir('fam')
LRN's avatar
LRN committed
992
subdir('tests')