[gnome-bluetooth] build: Port to meson build system



commit 92b1faa10bb7431694b799733c5ff672d2f62a70
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Wed Aug 2 16:19:37 2017 +0200

    build: Port to meson build system
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785737

 Makefile.am                                   |    3 +-
 docs/reference/libgnome-bluetooth/Makefile.am |    2 +-
 docs/reference/libgnome-bluetooth/meson.build |   44 +++++
 icons/Makefile.am                             |    2 +-
 icons/meson.build                             |   35 ++++
 lib/Makefile.am                               |    4 +-
 lib/gnome-bluetooth.map                       |   73 +++++++++
 lib/meson.build                               |  212 +++++++++++++++++++++++++
 meson.build                                   |  189 ++++++++++++++++++++++
 meson_options.txt                             |    3 +
 meson_post_install.py                         |   18 ++
 po/meson.build                                |    1 +
 sendto/Makefile.am                            |    2 +-
 sendto/meson.build                            |   51 ++++++
 14 files changed, 634 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8fb8dfc..cdc3d35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,8 @@ SUBDIRS = icons lib sendto docs po
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-EXTRA_DIST = intltool-extract.in intltool-update.in intltool-merge.in ChangeLog.pre-2.27 gtk-doc.make
+EXTRA_DIST = intltool-extract.in intltool-update.in intltool-merge.in ChangeLog.pre-2.27 gtk-doc.make \
+       meson.build meson_options.txt meson_post_install.py po/meson.build
 
 AM_DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install \
        --disable-desktop-update --disable-mime-update --disable-icon-update \
diff --git a/docs/reference/libgnome-bluetooth/Makefile.am b/docs/reference/libgnome-bluetooth/Makefile.am
index 59a5eb4..8d57b30 100644
--- a/docs/reference/libgnome-bluetooth/Makefile.am
+++ b/docs/reference/libgnome-bluetooth/Makefile.am
@@ -90,7 +90,7 @@ include $(top_srcdir)/gtk-doc.make
 
 # Other files to distribute
 # e.g. EXTRA_DIST += version.xml.in
-EXTRA_DIST += version.xml.in
+EXTRA_DIST += version.xml.in meson.build
 
 # Files not to distribute
 # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
diff --git a/docs/reference/libgnome-bluetooth/meson.build b/docs/reference/libgnome-bluetooth/meson.build
new file mode 100644
index 0000000..0ce31a6
--- /dev/null
+++ b/docs/reference/libgnome-bluetooth/meson.build
@@ -0,0 +1,44 @@
+private_headers = [
+  'bluetooth-agent.h',
+  'bluetooth-chooser-private.h',
+  'bluetooth-client-glue.h',
+  'bluetooth-client-private.h',
+  'bluetooth-fdo-glue.h',
+  'bluetooth-settings-obexpush.h',
+  'bluetooth-settings-row.h',
+  'gnome-bluetooth-enum-types.h'
+]
+
+version_conf = configuration_data()
+version_conf.set('VERSION', gnomebt_version)
+
+version_xml = 'version.xml'
+
+configure_file(
+  input: version_xml + '.in',
+  output: version_xml,
+  configuration: version_conf
+)
+
+doc_path = join_paths(gnomebt_datadir, 'gtk-doc', 'html', meson.project_name())
+
+gnome.gtkdoc(
+  meson.project_name(),
+  main_sgml: meson.project_name() + '-docs.sgml',
+  src_dir: [
+    top_inc,
+    lib_inc
+  ],
+  dependencies: libgnome_bluetooth_dep,
+  scan_args: [
+    '--rebuild-types',
+    '--ignore-headers=' + ' '.join(private_headers),
+  ],
+  mkdb_args: [
+    '--sgml-mode',
+    '--output-format=xml'
+  ],
+  gobject_typesfile: meson.project_name() + '.types',
+  install: true,
+  install_dir: doc_path
+)
diff --git a/icons/Makefile.am b/icons/Makefile.am
index 33038ab..3c53243 100644
--- a/icons/Makefile.am
+++ b/icons/Makefile.am
@@ -34,7 +34,7 @@ noinst_DATA = hicolor_apps_16x16_bluetooth.svg \
                hicolor_status_32x32_bluetooth-disabled.svg \
                hicolor_status_48x48_bluetooth-disabled.svg
 
-EXTRA_DIST = $(icons) $(noinst_DATA)
+EXTRA_DIST = $(icons) $(noinst_DATA) meson.build
 
 MAINTAINERCLEANFILES = Makefile.in
 
diff --git a/icons/meson.build b/icons/meson.build
new file mode 100644
index 0000000..98690ee
--- /dev/null
+++ b/icons/meson.build
@@ -0,0 +1,35 @@
+icons_files = [
+  ['apps', 'bluetooth.png'],
+  ['status', 'bluetooth-active.png'],
+  ['status', 'bluetooth-disabled.png'],
+  ['status', 'bluetooth-paired.png']
+]
+
+icons_48x48_files = [
+  ['apps', 'bluetooth.png'],
+  ['status', 'bluetooth-active.png'],
+  ['status', 'bluetooth-disabled.png']
+]
+
+icons_scalable_files = [
+  ['apps', 'bluetooth.svg'],
+  ['status', 'bluetooth-paired.svg']
+]
+
+icons = [
+  ['16x16', icons_files],
+  ['22x22', icons_files],
+  ['24x24', icons_files],
+  ['32x32', icons_files],
+  ['48x48', icons_48x48_files],
+  ['scalable', icons_scalable_files]
+]
+
+foreach icon: icons
+  foreach icon_file: icon[1]
+    install_data(
+      '_'.join(['hicolor', icon_file[0], icon[0], icon_file[1]]),
+      install_dir: join_paths(gnomebt_icondir, icon[0], icon_file[0])
+    )
+  endforeach
+endforeach
diff --git a/lib/Makefile.am b/lib/Makefile.am
index c8468b8..436c116 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -10,7 +10,9 @@ bluetooth-settings-resources.c: bluetooth.gresource.xml $(resource_files)
 bluetooth-settings-resources.h: bluetooth.gresource.xml $(resource_files)
        $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name 
bluetooth_settings $<
 
-EXTRA_DIST += bluetooth.gresource.xml settings.ui bluetooth-pairing-dialog.ui bluetooth-settings-row.ui 
bluetooth-settings.css
+EXTRA_DIST += bluetooth.gresource.xml settings.ui bluetooth-pairing-dialog.ui bluetooth-settings-row.ui 
bluetooth-settings.css \
+       meson.build
+
 BUILT_SOURCES += bluetooth-settings-resources.c bluetooth-settings-resources.h
 
 # will be scanned for introspection annotation, but won't be installed
diff --git a/lib/gnome-bluetooth.map b/lib/gnome-bluetooth.map
new file mode 100644
index 0000000..bb99104
--- /dev/null
+++ b/lib/gnome-bluetooth.map
@@ -0,0 +1,73 @@
+{
+global:
+  bluetooth_chooser_dump_selected_device;
+  bluetooth_chooser_get_type;
+  bluetooth_chooser_new;
+  bluetooth_chooser_set_title;
+  bluetooth_chooser_get_selected_device;
+  bluetooth_chooser_get_selected_device_info;
+  bluetooth_chooser_get_selected_device_name;
+  bluetooth_chooser_get_selected_device_icon;
+  bluetooth_chooser_get_selected_device_type;
+  bluetooth_chooser_get_selected_device_is_connected;
+  bluetooth_chooser_get_model;
+  bluetooth_chooser_get_treeview;
+  bluetooth_chooser_get_scrolled_window;
+  bluetooth_chooser_start_discovery;
+  bluetooth_chooser_stop_discovery;
+  bluetooth_chooser_button_get_type;
+  bluetooth_chooser_button_new;
+  bluetooth_chooser_button_available;
+  bluetooth_client_setup_device;
+  bluetooth_client_setup_device_finish;
+  bluetooth_client_dump_device;
+  bluetooth_client_get_type;
+  bluetooth_client_new;
+  bluetooth_client_get_model;
+  bluetooth_client_get_filter_model;
+  bluetooth_client_get_adapter_model;
+  bluetooth_client_get_device_model;
+  bluetooth_client_connect_service;
+  bluetooth_client_connect_service_finish;
+  bluetooth_client_set_trusted;
+  bluetooth_client_get_device;
+  bluetooth_class_to_type;
+  bluetooth_type_to_string;
+  bluetooth_type_to_filter_string;
+  bluetooth_verify_address;
+  bluetooth_uuid_to_string;
+  bluetooth_send_to_address;
+  bluetooth_column_get_type;
+  bluetooth_category_get_type;
+  bluetooth_type_get_type;
+  bluetooth_status_get_type;
+  bluetooth_filter_widget_new;
+  bluetooth_filter_widget_set_title;
+  bluetooth_filter_widget_get_type;
+  bluetooth_filter_widget_bind_filter;
+  bluetooth_chooser_combo_get_type;
+  bluetooth_chooser_combo_new;
+  bluetooth_agent_new;
+  bluetooth_agent_set_pincode_func;
+  bluetooth_agent_register;
+  bluetooth_agent_unregister;
+  bluetooth_agent_set_confirm_func;
+  bluetooth_agent_set_passkey_func;
+  bluetooth_agent_set_cancel_func;
+  bluetooth_agent_error_quark;
+  bluetooth_agent_set_authorize_func;
+  bluetooth_agent_set_display_func;
+  bluetooth_agent_set_display_pincode_func;
+  bluetooth_agent_set_authorize_service_func;
+  bluetooth_agent_setup;
+  bluetooth_settings_widget_get_type;
+  bluetooth_settings_widget_new;
+  bluetooth_settings_widget_get_default_adapter_powered;
+  bluetooth_pairing_dialog_new;
+  bluetooth_pairing_dialog_get_type;
+  bluetooth_pairing_dialog_set_mode;
+  bluetooth_pairing_dialog_get_mode;
+  bluetooth_pairing_dialog_set_pin_entered;
+local:
+       *;
+};
diff --git a/lib/meson.build b/lib/meson.build
new file mode 100644
index 0000000..f8571ff
--- /dev/null
+++ b/lib/meson.build
@@ -0,0 +1,212 @@
+lib_inc = include_directories('.')
+
+enum_headers = files('bluetooth-enums.h')
+
+headers = enum_headers + files(
+  'bluetooth-client.h',
+  'bluetooth-chooser.h',
+  'bluetooth-chooser-button.h',
+  'bluetooth-chooser-combo.h',
+  'bluetooth-filter-widget.h',
+  'bluetooth-settings-widget.h',
+  'bluetooth-utils.h'
+)
+
+install_headers(
+  headers,
+  subdir: meson.project_name()
+)
+
+sources = files(
+  'bluetooth-agent.c',
+  'bluetooth-chooser.c',
+  'bluetooth-chooser-button.c',
+  'bluetooth-chooser-combo.c',
+  'bluetooth-client.c',
+  'bluetooth-filter-widget.c',
+  'bluetooth-pairing-dialog.c',
+  'bluetooth-settings-obexpush.c',
+  'bluetooth-settings-row.c',
+  'bluetooth-settings-widget.c',
+  'bluetooth-utils.c',
+  'pin.c'
+)
+
+built_sources = []
+
+resource_data = files(
+  'bluetooth-pairing-dialog.ui',
+  'bluetooth-settings.css',
+  'bluetooth-settings-row.ui',
+  'settings.ui'
+)
+
+built_sources += gnome.compile_resources(
+  'bluetooth-settings-resources',
+  'bluetooth.gresource.xml',
+  source_dir: '.',
+  c_name: 'bluetooth_settings',
+  dependencies: resource_data,
+  export: true
+)
+
+enum_types = 'gnome-bluetooth-enum-types'
+
+built_sources += gnome.mkenums(
+  enum_types + '.c',
+  sources: enum_headers,
+  fhead: '#include <bluetooth-enums.h>\n#include "gnome-bluetooth-enum-types.h"\n#include <glib-object.h>',
+  fprod: '\n/* enumerations from "@filename@" */',
+  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static 
const G@Type@Value values[] = {',
+  vprod: '      { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+  vtail: '      { 0, NULL, NULL }\n    };\n    etype = g_@type@_register_static ("@EnumName@", values);\n  
}\n  return etype;\n}\n'
+)
+
+built_sources += gnome.mkenums(
+  enum_types + '.h',
+  sources: enum_headers,
+  fhead: '#ifndef __GNOME_BLUETOOTH_ENUM_TYPES_H__\n#define __GNOME_BLUETOOTH_ENUM_TYPES_H__\n\n#include 
<glib-object.h>\n\nG_BEGIN_DECLS\n',
+  fprod: '/* enumerations from "@filename@" */\n',
+  vhead: 'GType @enum_name@_get_type (void);\n#define BLUETOOTH_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n',
+  ftail: 'G_END_DECLS\n\n#endif /* __GNOME_BLUETOOTH_ENUM_TYPES_H__ */'
+)
+
+client = 'bluetooth-client'
+
+built_sources += gnome.gdbus_codegen(
+  client + '-glue',
+  client + '.xml',
+  interface_prefix: 'org.bluez'
+)
+
+fdo = 'bluetooth-fdo'
+
+built_sources += gnome.gdbus_codegen(
+  fdo + '-glue',
+  fdo + '.xml',
+  interface_prefix: 'org.freedesktop.DBus'
+)
+
+deps = [
+  gtk_dep,
+  m_dep,
+  dependency('gio-unix-2.0'),
+  dependency('gmodule-2.0'),
+  dependency('libcanberra-gtk3'),
+  dependency('libnotify', version: '>= 0.7.0'),
+  dependency('libudev')
+]
+
+cflags = [
+  '-DPKGDATADIR="@0@"'.format(gnomebt_pkgdatadir),
+  '-DG_LOG_DOMAIN="Bluetooth"'
+]
+
+symbol_map = meson.project_name() + '.map'
+
+ldflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbol_map)
+ldflags = []
+
+if host_machine.system().contains('linux') and cc.has_argument(ldflag)
+  ldflags += ldflag
+endif
+
+libgnome_bluetooth = shared_library(
+  meson.project_name(),
+  sources: sources + built_sources,
+  version: libversion,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: cflags,
+  link_args: ldflags,
+  link_depends: symbol_map,
+  install: true,
+  install_dir: gnomebt_libdir
+)
+
+libgnome_bluetooth_dep = declare_dependency(
+  link_with: libgnome_bluetooth,
+  include_directories: lib_inc,
+  dependencies: deps
+)
+
+pkg.generate(
+  libraries: libgnome_bluetooth,
+  version: gnomebt_version,
+  name: gnomebt_api_name,
+  description: 'Widgets for Bluetooth device selection',
+  filebase: gnomebt_api_name,
+  subdirs: meson.project_name(),
+  requires: [
+    'gio-2.0',
+    'gtk+-3.0'
+  ],
+  requires_private: 'libudev',
+  variables: 'exec_prefix=' + gnomebt_libexecdir,
+  install_dir: join_paths(gnomebt_libdir, 'pkgconfig')
+)
+
+if enable_gir
+  gir_sources = sources + headers
+
+  gir_incs = [
+    'GModule-2.0',
+    'GObject-2.0',
+    'Gtk-3.0'
+  ]
+
+  gir_extra_args = '--warn-all'
+
+  gir_dir = join_paths(gnomebt_datadir, 'gir-' + gnomebt_gir_version)
+  typelib_dir = join_paths(gnomebt_libdir, 'girepository-' + gnomebt_gir_version)
+
+  gnome.generate_gir(
+    libgnome_bluetooth,
+    sources: gir_sources,
+    nsversion: gnomebt_api_version,
+    namespace: gnomebt_gir_ns,
+    symbol_prefix: 'bluetooth',
+    identifier_prefix: 'Bluetooth',
+    export_packages: gnomebt_api_name,
+    includes: gir_incs,
+    extra_args: gir_extra_args,
+    install: true,
+    install_dir_gir: gir_dir,
+    install_dir_typelib: typelib_dir,
+  )
+endif
+
+test_names = [
+  'test-agent',
+  'test-class',
+  'test-client',
+  'test-deviceselection',
+  'test-pairing-dialog',
+  'test-pin',
+  'test-settings'
+]
+
+foreach name: test_names
+  executable(
+    name,
+    [name + '.c'] + built_sources,
+    include_directories: top_inc,
+    dependencies: deps,
+    c_args: cflags,
+    link_with: libgnome_bluetooth
+  )
+endforeach
+
+database = 'pin-code-database.xml'
+
+install_data(
+  database,
+  install_dir: gnomebt_pkgdatadir
+)
+
+custom_target(
+  database,
+  input: database,
+  output: database + '.valid',
+  command: [find_program('xmllint'), '--output', '@OUTPUT@', '--valid', '@INPUT']
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..4bd5b63
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,189 @@
+project(
+  'gnome-bluetooth', 'c',
+  version: '3.20.1',
+  license: 'GPL2+',
+  default_options: [
+    'buildtype=debugoptimized',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.41.0'
+)
+
+gnomebt_version = meson.project_version()
+version_array = gnomebt_version.split('.')
+gnomebt_major_version = version_array[0].to_int()
+gnomebt_minor_version = version_array[1].to_int()
+gnomebt_micro_version = version_array[2].to_int()
+
+gnomebt_api_version = '1.0'
+gnomebt_api_name = '@0@-@1@'.format(meson.project_name(), gnomebt_api_version)
+
+gnomebt_gir_ns = 'GnomeBluetooth'
+gnomebt_gir_version = '1.0'
+
+gnomebt_gettext_package = meson.project_name() + '2'
+
+gnomebt_prefix = get_option('prefix')
+gnomebt_bindir = join_paths(gnomebt_prefix, get_option('bindir'))
+gnomebt_datadir = join_paths(gnomebt_prefix, get_option('datadir'))
+gnomebt_includedir = join_paths(gnomebt_prefix, get_option('includedir'))
+gnomebt_libdir = join_paths(gnomebt_prefix, get_option('libdir'))
+gnomebt_libexecdir = join_paths(gnomebt_prefix, get_option('libexecdir'))
+gnomebt_localedir = join_paths(gnomebt_prefix, get_option('localedir'))
+gnomebt_mandir = join_paths(gnomebt_prefix, get_option('mandir'))
+
+gnomebt_pkgdatadir = join_paths(gnomebt_datadir, meson.project_name())
+gnomebt_pkglibdir = join_paths(gnomebt_libdir, meson.project_name())
+
+gnomebt_icondir = join_paths(gnomebt_datadir, 'icons', 'hicolor')
+
+gnomebt_buildtype = get_option('buildtype')
+gnomebt_debug = gnomebt_buildtype.contains('debug')
+
+# options
+enable_gtk_doc = get_option('enable-gtk-doc')
+enable_gir = get_option('enable-introspection')
+
+# Before making a release, the GNOMEBT_LT_VERSION string should be modified.
+# The string is of the form C:R:A.
+# - If interfaces have been changed or added, but binary compatibility has
+#   been preserved, change to C+1:0:A+1
+# - If binary compatibility has been broken (eg removed or changed interfaces)
+#   change to C+1:0:0
+# - If the interface is the same as the previous version, change to C:R+1:A
+current = 13
+revision = 1
+age = 0
+
+libversion = '@0@.@1@.@2@'.format(current, age, revision)
+
+cc = meson.get_compiler('c')
+
+config_h = configuration_data()
+
+# defines
+set_defines = [
+  # package
+  ['PACKAGE', meson.project_name()],
+  ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + meson.project_name()],
+  ['PACKAGE_NAME', meson.project_name()],
+  ['PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), gnomebt_version)],
+  ['PACKAGE_TARNAME', meson.project_name()],
+  ['PACKAGE_URL', ''],
+  ['PACKAGE_VERSION', gnomebt_version],
+  ['VERSION', gnomebt_version],
+  # i18n
+  ['GETTEXT_PACKAGE', gnomebt_gettext_package],
+  ['LOCALEDIR', gnomebt_localedir]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# debug
+config_h.set('NDEBUG', not gnomebt_debug)
+config_h.set('GNOME_ENABLE_DEBUG', gnomebt_debug)
+
+# headers
+check_headers = [
+  ['HAVE_DLFCN_H', 'dlfcn.h'],
+  ['HAVE_INTTYPES_H', 'inttypes.h'],
+  ['HAVE_MEMORY_H', 'memory.h'],
+  ['HAVE_STDINT_H', 'stdint.h'],
+  ['HAVE_STDLIB_H', 'stdlib.h'],
+  ['HAVE_STRINGS_H', 'strings.h'],
+  ['HAVE_STRING_H', 'string.h'],
+  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
+  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
+  ['HAVE_UNISTD_H', 'unistd.h']
+]
+
+foreach header: check_headers
+  config_h.set(header[0], cc.has_header(header[1]))
+endforeach
+
+# compiler flags
+common_flags = [
+  '-DHAVE_CONFIG_H',
+  '-DBONOBO_DISABLE_DEPRECATED',
+  '-DBONOBO_DISABLE_SINGLE_INCLUDES',
+  '-DBONOBO_UI_DISABLE_DEPRECATED',
+  '-DBONOBO_UI_DISABLE_SINGLE_INCLUDES',
+  '-DGCONF_DISABLE_DEPRECATED',
+  '-DGCONF_DISABLE_SINGLE_INCLUDES',
+  '-DGNOME_DISABLE_DEPRECATED',
+  '-DGNOME_DISABLE_SINGLE_INCLUDES',
+  '-DGNOME_VFS_DISABLE_DEPRECATED',
+  '-DGNOME_VFS_DISABLE_SINGLE_INCLUDES',
+  '-DLIBGLADE_DISABLE_DEPRECATED',
+  '-DLIBGLADE_DISABLE_SINGLE_INCLUDES',
+  '-DLIBSOUP_DISABLE_DEPRECATED',
+  '-DLIBSOUP_DISABLE_SINGLE_INCLUDES',
+  '-DWNCK_DISABLE_DEPRECATED',
+  '-DWNCK_DISABLE_SINGLE_INCLUDES'
+]
+
+compiler_flags = []
+if gnomebt_debug
+  test_flags = [
+    '-Werror=format=2',
+    '-Werror=implicit-function-declaration',
+    '-Werror=init-self',
+    '-Werror=missing-prototypes',
+    '-Werror=missing-include-dirs',
+    '-Werror=pointer-arith',
+    '-Werror=return-type',
+    '-Wnested-externs',
+    '-Wstrict-prototypes'
+  ]
+
+  foreach flag: test_flags
+    if cc.has_argument(flag)
+      compiler_flags += [flag]
+    endif
+  endforeach
+endif
+
+add_project_arguments(common_flags + compiler_flags, language: 'c')
+
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.12.0')
+
+m_dep = cc.find_library('m')
+config_h.set('HAVE_LIBM', m_dep.found() and cc.has_function('sin', dependencies: m_dep))
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+pkg = import('pkgconfig')
+
+po_dir = join_paths(meson.source_root(), 'po')
+
+intltool_merge = find_program('intltool-merge')
+intltool_cache = join_paths(po_dir, '.intltool-merge-cache')
+
+top_inc = include_directories('.')
+
+subdir('icons')
+subdir('lib')
+subdir('sendto')
+
+if enable_gtk_doc
+  subdir('docs/reference/libgnome-bluetooth')
+endif
+
+subdir('po')
+
+meson.add_install_script('meson_post_install.py', get_option('enable-icon-update') ? 'icon-update' : '')
+
+output = '\nConfigure summary:\n\n'
+output += '        Compiler....................:  ' + cc.get_id() + '\n\n'
+output += '        Compiler Flags..............:  ' + ' '.join(compiler_flags) + '\n'
+output += '        Prefix......................:  ' + gnomebt_prefix + '\n'
+output += '        Documentation...............:  ' + enable_gtk_doc.to_string() + '\n'
+output += '        GObject-Introspection.......:  ' + enable_gir.to_string()
+message(output)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..8bee50b
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('enable-icon-update', type: 'boolean', value: true, description: 'Enable icon cache update')
+option('enable-gtk-doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
+option('enable-introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection 
(depends on GObject)')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..ffcc071
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import glob
+import os
+import re
+import subprocess
+import sys
+
+name_pattern = re.compile('hicolor_(?:apps|status)_(?:\d+x\d+|scalable)_(.*)')
+search_pattern = '/**/hicolor_*'
+
+icon_dir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'icons', 'hicolor')
+[os.rename(file, os.path.join(os.path.dirname(file), name_pattern.search(file).group(1)))
+ for file in glob.glob(icon_dir + search_pattern, recursive=True)]
+
+if not os.environ.get('DESTDIR') and sys.argv[1] == 'icon-update':
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icon_dir])
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..9423439
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(gnomebt_gettext_package, preset: 'glib')
diff --git a/sendto/Makefile.am b/sendto/Makefile.am
index 9ad7374..7d2caf5 100644
--- a/sendto/Makefile.am
+++ b/sendto/Makefile.am
@@ -24,7 +24,7 @@ desktop_in_files = bluetooth-sendto.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-EXTRA_DIST = $(man_MANS) $(desktop_in_in_files)
+EXTRA_DIST = $(man_MANS) $(desktop_in_in_files) meson.build
 DISTCLEANFILES = bluetooth-sendto.desktop
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/sendto/meson.build b/sendto/meson.build
new file mode 100644
index 0000000..de65c2a
--- /dev/null
+++ b/sendto/meson.build
@@ -0,0 +1,51 @@
+name = 'bluetooth-sendto'
+
+deps = [
+  gtk_dep,
+  dependency('gio-2.0')
+]
+
+cflags = [
+  '-DDATADIR="@0@"'.format(gnomebt_datadir),
+  '-DICONDIR="@0@"'.format(gnomebt_icondir),
+  '-DLOCALEDIR="@0@"'.format(gnomebt_localedir)
+]
+
+executable(
+  name,
+  'main.c',
+  include_directories: [
+    top_inc,
+    lib_inc
+  ],
+  dependencies: deps,
+  c_args: cflags,
+  link_with: libgnome_bluetooth,
+  install: true,
+  install_dir: gnomebt_bindir
+)
+
+install_man(
+  name + '.1',
+  install_dir: join_paths(gnomebt_mandir, 'man1')
+)
+
+desktop_conf = configuration_data()
+desktop_conf.set('VERSION', gnomebt_version)
+
+desktop_name = name + '.desktop'
+
+desktop_in = configure_file(
+  input: desktop_name + '.in.in',
+  output: desktop_name + '.in',
+  configuration: desktop_conf
+)
+
+custom_target(
+  desktop_name,
+  input: desktop_in,
+  output: desktop_name,
+  command: [intltool_merge, '-d', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@'],
+  install: true,
+  install_dir: join_paths(gnomebt_datadir, 'applications')
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]