[gnome-dictionary] Add the Meson build system



commit ecaeaad3fb3b19ff690b5251df9f4d0eeb23defd
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Apr 11 11:32:55 2017 +0100

    Add the Meson build system
    
    We are going to move to Meson for 3.26.

 Makefile.am          |   12 ++++-
 data/meson.build     |   42 +++++++++++++++
 help/meson.build     |   51 +++++++++++++++++++
 libgdict/meson.build |   91 +++++++++++++++++++++++++++++++++
 meson.build          |  137 ++++++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt    |    1 +
 po/meson.build       |    1 +
 src/meson.build      |   43 ++++++++++++++++
 8 files changed, 377 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1bbb278..35a2d30 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,17 @@ SUBDIRS = libgdict src data help po
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
-EXTRA_DIST = TODO README AUTHORS COPYING.docs COPYING.libs
+meson_build = \
+       meson.build \
+       meson_options.txt \
+       data/meson.build \
+       help/meson.build \
+       libgdict/meson.build \
+       po/meson.build \
+       src/meson.build \
+       $()
+
+EXTRA_DIST = TODO README AUTHORS COPYING.docs COPYING.libs $(meson_build)
 
 MAINTAINERCLEANFILES = \
        $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL)      \
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..a22eaf6
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,42 @@
+i18n.merge_file ('desktop',
+                 input: 'org.gnome.Dictionary.desktop.in',
+                 output: 'org.gnome.Dictionary.desktop',
+                 install: true,
+                 install_dir: join_paths(gdict_datadir, 'applications'),
+                 po_dir: po_dir,
+                 type: 'desktop')
+
+i18n.merge_file ('desktop',
+                 input: 'org.gnome.Dictionary.appdata.xml.in',
+                 output: 'org.gnome.Dictionary.appdata.xml',
+                 install: true,
+                 install_dir: join_paths(gdict_datadir, 'appdata'),
+                 po_dir: po_dir)
+
+service_conf = configuration_data ()
+service_conf.set ('bindir', gdict_bindir)
+configure_file (input: 'org.gnome.Dictionary.service.in',
+                output: 'org.gnome.Dictionary.service',
+                configuration: service_conf,
+                install_dir: gdict_servicedir)
+
+install_data ('org.gnome.dictionary.gschema.xml',
+              install_dir: gdict_schemadir)
+
+
+# Dictionary sources
+sources = [
+  'default.desktop',
+  'spanish.desktop',
+  'thai.desktop',
+]
+
+foreach s: sources
+  i18n.merge_file('desktop',
+                  input: '@0@.in'.format(s),
+                  output: s,
+                  install: true,
+                  install_dir: join_paths(gdict_datadir, 'gdict-1.0', 'sources'),
+                  po_dir: po_dir,
+                  type: 'desktop')
+endforeach
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..2902cf1
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,51 @@
+gnome.yelp('gnome-dictionary',
+           sources: [
+             'definition.page',
+             'dictionary-select.page',
+             'find.page',
+             'index.page',
+             'introduction.page',
+             'keyboard-shortcuts.page',
+             'legal.xml',
+             'pref.page',
+             'print-font.page',
+             'print.page',
+             'prob-retrieving-definition.page',
+             'save-definition.page',
+             'similar-words.page',
+             'source-add-local.page',
+             'sources-default.page',
+             'sources-delete.page',
+             'sources-edit.page',
+             'sources.page',
+             'sources-select.page',
+             'text-copy.page',
+           ],
+           media: [
+             'figures/gnome-dictionary-icon.png',
+             'figures/gnome-dictionary.png',
+           ],
+           languages: [
+             'ca',
+             'cs',
+             'da',
+             'de',
+             'el',
+             'en_GB',
+             'es',
+             'eu',
+             'fi',
+             'fr',
+             'gl',
+             'hu',
+             'id',
+             'it',
+             'ko',
+             'oc',
+             'pt_BR',
+             'ru',
+             'sl',
+             'sv',
+             'uk',
+             'zh_CN',
+           ])
diff --git a/libgdict/meson.build b/libgdict/meson.build
new file mode 100644
index 0000000..45e401d
--- /dev/null
+++ b/libgdict/meson.build
@@ -0,0 +1,91 @@
+sources_h = [
+  'gdict-context.h',
+  'gdict-client-context.h',
+  'gdict-database-chooser.h',
+  'gdict-database-chooser-button.h',
+  'gdict-defbox.h',
+  'gdict-source-chooser.h',
+  'gdict-source-loader.h',
+  'gdict-source.h',
+  'gdict-speller.h',
+  'gdict-strategy-chooser.h',
+  'gdict-utils.h',
+]
+
+sources_h_priv = [
+  'gdict-context-private.h',
+  'gdict-debug.h',
+  'gdict-private.h',
+]
+
+sources_c = [
+  'gdict-context.c',
+  'gdict-client-context.c',
+  'gdict-database-chooser.c',
+  'gdict-database-chooser-button.c',
+  'gdict-defbox.c',
+  'gdict-source-chooser.c',
+  'gdict-source-loader.c',
+  'gdict-source.c',
+  'gdict-speller.c',
+  'gdict-strategy-chooser.c',
+  'gdict-utils.c',
+]
+
+libgdict_enums = gnome.mkenums('gdict-enum-types', sources: sources_h,
+                               h_template: 'gdict-enum-types.h.in',
+                               c_template: 'gdict-enum-types.c.in',
+                               install_header: false)
+libgdict_marshal = gnome.genmarshal('gdict-marshal',
+                                    sources: 'gdict-marshal.list',
+                                    prefix: 'gdict_marshal')
+
+libgdict_version = meson.project_version().split('.')
+libgdict_major = libgdict_version[0].to_int()
+libgdict_minor = libgdict_version[1].to_int()
+libgdict_micro = libgdict_version[2].to_int()
+
+libgdict_cflags = [
+  '-DHAVE_CONFIG_H',
+  '-D_GNU_SOURCE',
+  '-DG_LOG_DOMAIN="Gdict"',
+  '-DDATADIR="@0@"'.format(gdict_datadir),
+  '-DLIBDIR="@0@"'.format(gdict_libdir),
+  '-DSYSCONFDIR="@0@"'.format(gdict_sysconfdir),
+  '-DPREFIX="@0@"'.format(gdict_prefix),
+  '-DGNOMELOCALEDIR="@0@"'.format(join_paths(gdict_datadir, 'locale')),
+  '-DGDICTSOURCESDIR="@0@"'.format(join_paths(gdict_datadir, 'gdict-1.0', 'sources')),
+  '-DGDICT_ENABLE_INTERNALS=1',
+  '-DGDICT_MAJOR_VERSION=@0@'.format(libgdict_major),
+  '-DGDICT_MINOR_VERSION=@0@'.format(libgdict_minor),
+  '-DGDICT_MICRO_VERSION=@0@'.format(libgdict_micro),
+  '-DG_DISABLE_DEPRECATED',
+  '-DGDK_DISABLE_DEPRECATED',
+  '-UGTK_DISABLE_DEPRECATED',
+  '-DPANGO_DISABLE_DEPRECATED',
+  '-DG_DISABLE_SINGLE_INCLUDES',
+  '-DGTK_DISABLE_SINGLE_INCLUDES',
+]
+
+libgdict_ldflags = []
+if cc.get_id() == 'gcc'
+  libgdict_ldflags += [
+    '-Wl,-Bsymbolic-functions',
+    '-Wl,-z,relro',
+    '-Wl,-z,now',
+  ]
+endif
+
+libgdict_inc = include_directories('.')
+
+libgdict_lib = static_library('libgdict-1.0',
+                              sources: sources_h_priv + sources_c + libgdict_enums + libgdict_marshal,
+                              dependencies: [ gio_dep, gtk_dep ],
+                              include_directories: [ root_dir, libgdict_inc ],
+                              c_args: common_cflags + debug_cflags + libgdict_cflags,
+                              link_args: libgdict_ldflags,
+                              install: false)
+
+libgdict_dep = declare_dependency(link_with: libgdict_lib,
+                                 include_directories: [ libgdict_inc ],
+                                 dependencies: [ gio_dep, gtk_dep ])
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..2c12a4a
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,137 @@
+project('gnome-dictionary', 'c', version: '3.25.1',
+        default_options: [
+          'buildtype=debugoptimized',
+          'c_std=c99',
+          'warning_level=1',
+        ],
+        license: 'GPLv2+',
+        meson_version: '>= 0.39.1')
+
+# Paths for the pkg-config file
+gdict_prefix = get_option('prefix')
+gdict_bindir = join_paths(gdict_prefix, get_option('bindir'))
+gdict_libdir = join_paths(gdict_prefix, get_option('libdir'))
+gdict_datadir = join_paths(gdict_prefix, get_option('datadir'))
+gdict_includedir = join_paths(gdict_prefix, get_option('includedir'))
+gdict_libexecdir = join_paths(gdict_prefix, get_option('libexecdir'))
+gdict_mandir = join_paths(gdict_prefix, get_option('mandir'))
+gdict_sysconfdir = join_paths(gdict_prefix, get_option('sysconfdir'))
+gdict_schemadir = join_paths (gdict_datadir, 'glib-2.0', 'schemas')
+gdict_servicedir = join_paths (gdict_datadir, 'dbus-1', 'services')
+
+cc = meson.get_compiler('c')
+host_system = host_machine.system()
+
+conf = configuration_data()
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+conf.set_quoted('PACKAGE_STRING', '@0@-@1@'.format(meson.project_name(), meson.project_version()))
+conf.set_quoted('PACKAGE_DATADIR', gdict_datadir)
+conf.set_quoted('PACKAGE_LIBDIR', gdict_libdir)
+conf.set_quoted('PACKAGE_LOCALE_DIR', join_paths(gdict_datadir, 'locale'))
+conf.set_quoted('PACKAGE_LIBEXECDIR', gdict_libexecdir)
+conf.set('VERSION', 'PACKAGE_VERSION')
+conf.set('GETTEXT_PACKAGE', 'PACKAGE_NAME')
+conf.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
+conf.set10('ENABLE_NLS', true) # Always enabled
+conf.set('HAVE_UNISTD_H', cc.has_header('unistd.h'))
+
+# Compiler flags
+if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
+  test_cflags = [
+    '-fstrict-aliasing',
+    '-Wpointer-arith',
+    '-Wmissing-declarations',
+    '-Wformat=2',
+    '-Wstrict-prototypes',
+    '-Wmissing-prototypes',
+    '-Wnested-externs',
+    '-Wold-style-definition',
+    '-Wunused',
+    '-Wuninitialized',
+    '-Wshadow',
+    '-Wmissing-noreturn',
+    '-Wmissing-format-attribute',
+    '-Wredundant-decls',
+    '-Wlogical-op',
+    '-Wcast-align',
+    '-Wno-unused-local-typedefs',
+    '-Werror=implicit',
+    '-Werror=init-self',
+    '-Werror=main',
+    '-Werror=missing-braces',
+    '-Werror=return-type',
+    '-Werror=array-bounds',
+    '-Werror=write-strings'
+  ]
+else
+  test_cflags = []
+endif
+
+common_cflags = []
+foreach cflag: test_cflags
+  if cc.has_argument(cflag)
+    common_cflags += [ cflag ]
+  endif
+endforeach
+
+debug_cflags = []
+buildtype = get_option('buildtype')
+if buildtype == 'debug'
+  debug_cflags += [ '-DGDICT_ENABLE_DEBUG', ]
+elif buildtype == 'debugoptimized'
+  debug_cflags += [ '-DGDICT_ENABLE_DEBUG', '-DG_DISABLE_CAST_CHECKS', ]
+elif buildtype == 'release'
+  debug_cflags += [ '-DG_DISABLE_ASSERT', '-DG_DISABLE_CHECKS', '-DG_DISABLE_CAST_CHECKS', ]
+endif
+
+use_ipv6 = get_option('use_ipv6')
+if use_ipv6
+  ipv6_prog = '''
+#include <sys/socket.h>
+#include <sys/types.h>
+
+int main (void) {
+  struct sockaddr_storage ss;
+  socket(AF_INET6, SOCK_STREAM, 0);
+  return 0;
+}
+  '''
+  has_ipv6 = cc.compiles(ipv6_prog, name: 'AF_INET6 is available')
+  has_getaddrinfo = cc.has_function('getaddrinfo')
+
+  # Look for getaddrinfo in all the known places
+  if not has_getaddrinfo
+    found_getaddrinfo = false
+    foreach l: [ 'bsd', 'socket', 'inet' ]
+      dep = cc.find_library(l, required: false)
+      if not found_getaddrinfo and dep.found()
+        has_getaddrinfo = cc.has_function('getaddrinfo', dependencies: dep)
+        if has_getaddrinfo
+          add_project_link_arguments('-l@0@'.format(l), language: 'c')
+        endif
+      endif
+    endforeach
+  endif
+
+  use_ipv6 = has_ipv6 and has_getaddrinfo
+endif
+
+conf.set10('ENABLE_IPV6', use_ipv6)
+
+root_dir = include_directories('.')
+po_dir = join_paths(meson.current_source_dir(), 'po')
+
+configure_file(output: 'config.h', configuration: conf)
+
+gio_dep = dependency('gio-2.0', version: '>= 2.42.0')
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.21.2')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+subdir('libgdict')
+subdir('src')
+subdir('po')
+subdir('data')
+subdir('help')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..da0615b
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('use_ipv6', type: 'boolean', value: true, description: 'Enable IPv6 support')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..9f1c753
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext('gnome-dictionary', preset: 'glib')
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..82a8626
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,43 @@
+mathlib = cc.find_library('m', required: false)
+
+app_sources = [
+  'gdict-about.c',
+  'gdict-about.h',
+  'gdict-app.c',
+  'gdict-app.h',
+  'gdict-common.c',
+  'gdict-common.h',
+  'gdict-pref-dialog.c',
+  'gdict-pref-dialog.h',
+  'gdict-print.c',
+  'gdict-print.h',
+  'gdict-sidebar.c',
+  'gdict-sidebar.h',
+  'gdict-source-dialog.c',
+  'gdict-source-dialog.h',
+  'gdict-window.c',
+  'gdict-window.h',
+  'main.c',
+]
+
+resources = gnome.compile_resources ('gdict-resources',
+                                     'gdict.gresource.xml',
+                                     source_dir: '.',
+                                     c_name: 'gdict')
+
+executable('gnome-dictionary', app_sources + resources,
+           c_args: [
+             '-DHAVE_CONFIG_H',
+            '-DPREFIX="@0@"'.format(gdict_prefix),
+             '-DSYSCONFDIR="@0@"'.format(gdict_sysconfdir),
+             '-DLIBDIR="@0@"'.format(gdict_libdir),
+             '-DDATADIR="@0@"'.format(gdict_datadir),
+             '-DPKGDATADIR="@0@"'.format(join_paths(gdict_datadir, 'gnome-dictionary')),
+             '-DGNOMELOCALEDIR="@0@"'.format(join_paths(gdict_datadir, 'locale')),
+           ],
+           dependencies: libgdict_dep,
+           include_directories: [
+             root_dir,
+             include_directories('.'),
+           ],
+           install: true)


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