Merge branch 'upstream' into tizen
[platform/upstream/glib.git] / gio / meson.build
index b274b50..8ba4595 100644 (file)
@@ -2,6 +2,7 @@ gio_c_args = [
   '-DG_LOG_DOMAIN="GLib-GIO"',
   '-DGIO_COMPILATION',
   '-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
+  '-DLOCALSTATEDIR="@0@"'.format(glib_localstatedir),
 ]
 
 gio_c_args += glib_hidden_visibility_args
@@ -10,15 +11,9 @@ gio_c_args += glib_hidden_visibility_args
 
 gnetworking_h_conf = configuration_data()
 
-gnetworking_h_wspiapi_include = ''
 gnetworking_h_nameser_compat_include = ''
 
-if host_system == 'windows'
-  # <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>'
-elif not host_system.contains('android')
+if host_system not in ['windows', 'android']
   # Don't check for C_IN on Android since it does not define it in public
   # headers, we define it ourselves wherever necessary
   if not cc.compiles('''#include <sys/types.h>
@@ -56,6 +51,9 @@ if host_system != 'windows'
     elif cc.links(res_query_test, args : '-lbind', name : 'res_query() in -lbind')
       network_libs += [ cc.find_library('bind') ]
       network_args += [ '-lbind' ]
+    elif cc.links(res_query_test, args : '-lsocket', name : 'res_query() in -lsocket')
+      network_libs += [ cc.find_library('socket') ]
+      network_args += [ '-lsocket' ]
     else
       error('Could not find res_query()')
     endif
@@ -154,7 +152,7 @@ if host_system != 'windows'
 
 endif
 
-if host_system.contains('android')
+if host_system == 'android'
   # struct ip_mreq_source definition is broken on Android NDK <= r16
   # See https://bugzilla.gnome.org/show_bug.cgi?id=740791
   if not cc.compiles('''#include <netinet/in.h>
@@ -168,7 +166,6 @@ if host_system.contains('android')
   endif
 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',
@@ -254,16 +251,6 @@ xdp_dbus_generated = custom_target('xdp-dbus',
                '--output-directory', '@OUTDIR@',
                '--generate-c-code', 'xdp-dbus',
                '--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',
-               '--annotate', 'org.freedesktop.portal.Documents.AddFull()',
-                             'org.gtk.GDBus.C.UnixFD', 'true',
-               '--annotate', 'org.freedesktop.portal.OpenURI.OpenFile()',
-                             'org.gtk.GDBus.C.UnixFD', 'true',
-               '--annotate', 'org.freedesktop.portal.Trash.TrashFile()',
-                             'org.gtk.GDBus.C.UnixFD', 'true',
                '@INPUT@'])
 
 # Generate gdbus-generated.{c,h}
@@ -382,6 +369,7 @@ gdbus_daemon_sources = [
 if host_system != 'windows'
   unix_sources = files(
     'gfiledescriptorbased.c',
+    'giounix-private.c',
     'gunixconnection.c',
     'gunixcredentialsmessage.c',
     'gunixfdlist.c',
@@ -400,7 +388,9 @@ if host_system != 'windows'
   portal_sources = [files(
     'gdocumentportal.c',
     'gopenuriportal.c',
+    'gmemorymonitorportal.c',
     'gnetworkmonitorportal.c',
+    'gpowerprofilemonitorportal.c',
     'gproxyresolverportal.c',
     'gtrashportal.c',
     'gportalsupport.c',
@@ -432,12 +422,6 @@ if host_system != 'windows'
     contenttype_sources += files('gcontenttype.c')
     appinfo_sources += files('gdesktopappinfo.c')
     gio_unix_include_headers += files('gdesktopappinfo.h')
-
-    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)
   endif
 
   subdir('xdgmime')
@@ -459,12 +443,16 @@ else
                     cc.find_library('dnsapi'),
                     iphlpapi_dep,
                     winsock2]
+  platform_deps += uwp_gio_deps
+
   win32_sources += files(
     'gwin32registrykey.c',
     'gwin32mount.c',
     'gwin32volumemonitor.c',
     'gwin32inputstream.c',
     'gwin32outputstream.c',
+    'gwin32file-sync-stream.c',
+    'gwin32packageparser.c',
     'gwin32networkmonitor.c',
     'gwin32networkmonitor.h',
     'gwin32notificationbackend.c',
@@ -535,6 +523,8 @@ gio_sources = files(
   'gloadableicon.c',
   'gmarshal-internal.c',
   'gmount.c',
+  'gmemorymonitor.c',
+  'gmemorymonitordbus.c',
   'gmemoryinputstream.c',
   'gmemoryoutputstream.c',
   'gmountoperation.c',
@@ -551,6 +541,8 @@ gio_sources = files(
   'gpollableoutputstream.c',
   'gpollableutils.c',
   'gpollfilemonitor.c',
+  'gpowerprofilemonitor.c',
+  'gpowerprofilemonitordbus.c',
   'gproxy.c',
   'gproxyaddress.c',
   'gproxyaddressenumerator.c',
@@ -604,6 +596,7 @@ gio_sources = files(
   'gzlibdecompressor.c',
   'glistmodel.c',
   'gliststore.c',
+  '../glib/gtrace.c',
 )
 
 gio_sources += appinfo_sources
@@ -677,6 +670,7 @@ gio_headers = files(
   'gloadableicon.h',
   'gmount.h',
   'gmemoryinputstream.h',
+  'gmemorymonitor.h',
   'gmemoryoutputstream.h',
   'gmountoperation.h',
   'gnativesocketaddress.h',
@@ -689,6 +683,7 @@ gio_headers = files(
   'gpollableinputstream.h',
   'gpollableoutputstream.h',
   'gpollableutils.h',
+  'gpowerprofilemonitor.h',
   'gproxy.h',
   'gproxyaddress.h',
   'gproxyaddressenumerator.h',
@@ -788,6 +783,17 @@ if host_system == 'windows'
 endif
 
 if have_bash
+  bash_comp_inst_dir = ''
+  if bash_comp_dep.found()
+    bash_comp_dir_override = bash_comp_dep.version().version_compare('>= 2.10') ? ['datadir', get_option('datadir')] : ['prefix', get_option('prefix')]
+    bash_comp_inst_dir = bash_comp_dep.get_pkgconfig_variable('completionsdir', define_variable: bash_comp_dir_override)
+  endif
+
+  if bash_comp_inst_dir == ''
+    message('Found bash-completion but the .pc file did not set \'completionsdir\', fallback to a predefined path')
+    bash_comp_inst_dir = join_paths(get_option('datadir'), 'bash-completion/completions')
+  endif
+
   install_data([
     'completion/gapplication',
     'completion/gdbus',
@@ -795,7 +801,7 @@ if have_bash
     'completion/gsettings',
     'completion/gresource'
   ],
-  install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'))
+  install_dir: bash_comp_inst_dir)
 endif
 
 if enable_dtrace
@@ -828,27 +834,32 @@ libgio = library('gio-2.0',
   #  '$(gio_win32_res_ldflag)',
   dependencies : [libz_dep, libdl_dep, libmount_dep, libglib_dep,
                   libgobject_dep, libgmodule_dep, selinux_dep, xattr_dep,
-                  platform_deps, network_libs, libdbuspolicy_dep],
+                  platform_deps, network_libs, libdbuspolicy_dep, libsysprof_capture_dep],
   c_args : gio_c_args,
   objc_args : gio_c_args,
   # intl.lib is not compatible with SAFESEH
   link_args : [noseh_link_args, glib_link_flags],
 )
 
-giomodulesdir = get_option('gio_module_dir')
-if giomodulesdir == ''
-  giomodulesdir = join_paths('${libdir}', 'gio', 'modules')
+if get_option('gio_module_dir') != ''
+  pkgconfig_giomodulesdir = join_paths('${prefix}', get_option('gio_module_dir'))
+else
+  pkgconfig_giomodulesdir = join_paths('${libdir}', 'gio', 'modules')
 endif
 
 schemas_subdir = join_paths('glib-2.0', 'schemas')
 
+libgio_dep = declare_dependency(link_with : libgio,
+  dependencies : [libgmodule_dep, libgobject_dep, gioenumtypes_dep],
+  include_directories : [gioinc])
+
 pkg.generate(libgio,
   libraries_private : [osx_ldflags],
   requires : ['glib-2.0', 'gobject-2.0'],
   variables : ['datadir=' + join_paths('${prefix}', get_option('datadir')),
                'schemasdir=' + join_paths('${datadir}', schemas_subdir),
                'bindir=' + join_paths('${prefix}', get_option('bindir')),
-               'giomoduledir=' + giomodulesdir,
+               'giomoduledir=' + pkgconfig_giomodulesdir,
                'gio=' + join_paths('${bindir}', 'gio'),
                'gio_querymodules=' + join_paths('${bindir}', 'gio-querymodules'),
                'glib_compile_schemas=' + join_paths('${bindir}', 'glib-compile-schemas'),
@@ -864,6 +875,11 @@ pkg.generate(libgio,
   description : 'glib I/O library',
 )
 
+if meson.version().version_compare('>=0.54.0')
+  meson.override_dependency('gio-2.0', libgio_dep)
+endif
+
+
 if host_system == 'windows'
   pkg.generate(requires : ['gobject-2.0', 'gmodule-no-export-2.0', 'gio-2.0'],
     subdirs : ['gio-win32-2.0'],
@@ -873,6 +889,9 @@ if host_system == 'windows'
     name : 'GIO Windows specific APIs',
     description : 'Windows specific headers for glib I/O library',
   )
+  if meson.version().version_compare('>=0.54.0')
+    meson.override_dependency('gio-win32-2.0', libgio_dep)
+  endif
 else
   pkg.generate(requires : ['gobject-2.0', 'gio-2.0'],
     subdirs : ['gio-unix-2.0'],
@@ -882,12 +901,11 @@ else
     name : 'GIO unix specific APIs',
     description : 'unix specific headers for glib I/O library',
   )
+  if meson.version().version_compare('>=0.54.0')
+    meson.override_dependency('gio-unix-2.0', libgio_dep)
+  endif
 endif
 
-libgio_dep = declare_dependency(link_with : libgio,
-  dependencies : [libgmodule_dep, libgobject_dep, gioenumtypes_dep],
-  include_directories : [gioinc])
-
 if host_system == 'windows'
   # Hack till https://github.com/mesonbuild/meson/issues/2324 is fixed
   libgiounix_dep = dependency('', required : false)
@@ -899,14 +917,14 @@ endif
 
 # Dependencies used by executables below
 have_libelf = false
-libelf = dependency('libelf', version : '>= 0.8.12', required : false)
+libelf = dependency('libelf', version : '>= 0.8.12', required : get_option ('libelf'))
 if libelf.found()
   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)
+  libelf = cc.find_library('elf', required : get_option ('libelf'))
   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)
@@ -932,6 +950,7 @@ gio_tool_sources = [
   'gio-tool-cat.c',
   'gio-tool-copy.c',
   'gio-tool-info.c',
+  'gio-tool-launch.c',
   'gio-tool-list.c',
   'gio-tool-mime.c',
   'gio-tool-mkdir.c',
@@ -968,7 +987,7 @@ gio_querymodules = executable('gio-querymodules', 'gio-querymodules.c', 'giomodu
   dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
 
 glib_compile_schemas = executable('glib-compile-schemas',
-  [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-schemas.c'],
+  ['gvdb/gvdb-builder.c', 'glib-compile-schemas.c'],
   install : true,
   # intl.lib is not compatible with SAFESEH
   link_args : noseh_link_args,
@@ -988,6 +1007,7 @@ glib_compile_resources = executable('glib-compile-resources',
 if not meson.is_cross_build()
   meson.override_find_program('glib-compile-schemas', glib_compile_schemas)
   meson.override_find_program('glib-compile-resources', glib_compile_resources)
+  meson.override_find_program('gio-querymodules', gio_querymodules)
 endif
 
 executable('gsettings', 'gsettings-tool.c',