[devhelp/wip/meson: 5/6] build: Port to meson build system



commit fe2e710f3457a5e85da4339289bb24dff2f099f3
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Jun 15 13:06:37 2017 +0200

    build: Port to meson build system
    
    meson is a build system focused on speed an ease of use, which
    helps speeding up the software development. This patch adds meson
    support along autotools.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783819

 Makefile.am                              |    7 +-
 data/Makefile.am                         |    1 +
 data/dtd/meson.build                     |    4 +
 data/icons/Makefile.am                   |    3 +-
 data/icons/meson.build                   |   16 +++
 data/meson.build                         |   72 ++++++++++
 data/org.gnome.Devhelp.service.in        |    3 +
 docs/reference/Makefile.am               |    1 +
 docs/reference/meson.build               |   38 +++++
 docs/reference/xml/gtkdocentities.ent.in |    7 +
 docs/reference/xml/meson.build           |   17 +++
 meson.build                              |  217 ++++++++++++++++++++++++++++++
 meson_options.txt                        |    2 +
 meson_post_install.py                    |   19 +++
 misc/gedit-plugin/Makefile.am            |    4 +-
 misc/gedit-plugin/meson.build            |   18 +++
 po/meson.build                           |    1 +
 src/Makefile.am                          |    2 +
 src/devhelp.map                          |    6 +
 src/meson.build                          |  190 ++++++++++++++++++++++++++
 20 files changed, 625 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 37daf17..1411629 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,12 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
        --enable-introspection  \
        --enable-appstream-util
 
-EXTRA_DIST = devhelp.doap
+EXTRA_DIST = \
+       devhelp.doap \
+       meson.build \
+       meson_options.txt \
+       meson_post_install.py \
+       po/meson.build
 
 MAINTAINERCLEANFILES = \
        $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \
diff --git a/data/Makefile.am b/data/Makefile.am
index cce2e36..027b677 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -40,6 +40,7 @@ org.gnome.Devhelp.service: Makefile
 man_MANS = devhelp.1
 
 EXTRA_DIST =                   \
+       meson.build             \
        libdevhelp-3.0.pc.in    \
        $(desktop_in_files)     \
        $(gsettings_SCHEMAS)    \
diff --git a/data/dtd/meson.build b/data/dtd/meson.build
new file mode 100644
index 0000000..e27d198
--- /dev/null
+++ b/data/dtd/meson.build
@@ -0,0 +1,4 @@
+install_data(
+  'devhelp-1.dtd',
+  install_dir: join_paths(devhelp_pkgdatadir, 'dtd')
+)
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 722b21e..b955379 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -40,6 +40,7 @@ EXTRA_DIST = \
        $(icon48_DATA)          \
        $(icon256_DATA)         \
        $(iconscalable_DATA)    \
-       devhelp.svg
+       devhelp.svg             \
+       meson.build
 
 -include $(top_srcdir)/git.mk
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..f80f465
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,16 @@
+icons = [
+  ['16x16', 'devhelp.png'],
+  ['22x22', 'devhelp.png'],
+  ['24x24', 'devhelp.png'],
+  ['32x32', 'devhelp.png'],
+  ['48x48', 'devhelp.png'],
+  ['256x256', 'devhelp.png'],
+  ['symbolic', 'devhelp-symbolic.svg']
+]
+
+foreach icon: icons
+  install_data(
+    join_paths(icon[0], icon[1]),
+    install_dir: join_paths(devhelp_datadir, 'icons', 'hicolor', icon[0], 'apps')
+  )
+endforeach
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..d991129
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,72 @@
+subdir('dtd')
+subdir('icons')
+
+info_name = 'org.gnome.Devhelp.metainfo.xml'
+
+i18n.merge_file(
+  info_name,
+  input: 'org.gnome.Devhelp.appdata.xml.in',
+  output: info_name,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(devhelp_datadir, 'metainfo')
+)
+
+desktop = 'org.gnome.Devhelp.desktop'
+
+desktop_conf = configuration_data()
+desktop_conf.set('VERSION', devhelp_version)
+
+desktop_in = configure_file(
+  input: desktop + '.in.in',
+  output: desktop + '.in',
+  configuration: desktop_conf
+)
+
+i18n.merge_file(
+  desktop,
+  type: 'desktop',
+  input: desktop_in,
+  output: desktop,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(devhelp_datadir, 'applications')
+)
+
+service_conf = configuration_data()
+service_conf.set('bindir', devhelp_bindir)
+
+service = 'org.gnome.Devhelp.service'
+
+configure_file(
+  input: service + '.in',
+  output: service,
+  install: true,
+  install_dir: join_paths(devhelp_datadir, 'dbus-1', 'services'),
+  configuration: service_conf
+)
+
+assistant_data = files(
+  'assistant.js',
+  'assistant.css'
+)
+
+install_data(
+  assistant_data,
+  install_dir: join_paths(devhelp_pkgdatadir, 'assistant')
+)
+
+install_data(
+  'org.gnome.devhelp.gschema.xml',
+  install_dir: join_paths(devhelp_datadir, 'glib-2.0', 'schemas')
+)
+
+install_data(
+  'devhelp.convert',
+  install_dir: join_paths(devhelp_datadir, 'GConf', 'gsettings')
+)
+
+install_data(
+  'devhelp.1',
+  install_dir: join_paths(devhelp_mandir, 'man1')
+)
diff --git a/data/org.gnome.Devhelp.service.in b/data/org.gnome.Devhelp.service.in
new file mode 100644
index 0000000..3555cfd
--- /dev/null
+++ b/data/org.gnome.Devhelp.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.Devhelp
+Exec=@bindir@/devhelp --gapplication-service
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 1aa6a29..0e4bd11 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -1,3 +1,4 @@
+EXTRA_DIST = meson.build
 
 # The name of the module, e.g. 'glib'.
 DOC_MODULE = devhelp
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..c02e9c1
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,38 @@
+subdir('xml')
+
+private_headers = [
+  'dh-app.h',
+  'dh-assistant.h',
+  'dh-enum-types-app.h',
+  'dh-error.h',
+  'dh-language.h',
+  'dh-parser.h',
+  'dh-preferences.h',
+  'dh-settings.h',
+  'dh-util.h',
+  'dh-window.h'
+]
+
+webkit_prefix = webkit2gtk_dep.get_pkgconfig_variable('prefix')
+webkit_doc_path = join_paths(webkit_prefix, 'share', 'gtk-doc', 'html')
+
+doc_path = join_paths(devhelp_datadir, 'gtk-doc', 'html', libdevhelp_name)
+
+gnome.gtkdoc(
+  devhelp_name,
+  main_xml: devhelp_name + '-docs.xml',
+  src_dir: src_inc,
+  dependencies: libdevhelp_dep,
+  scan_args: [
+    '--rebuild-types',
+    '--ignore-headers=' + ' '.join(private_headers)
+  ],
+  mkdb_args: [
+    '--xml-mode',
+    '--output-format=xml'
+  ],
+  gobject_typesfile: devhelp_name + '.types',
+  fixxref_args: '--extra-dir=' + join_paths(webkit_doc_path, 'webkit2gtk-4.0'),
+  install: true,
+  install_dir: doc_path
+)
diff --git a/docs/reference/xml/gtkdocentities.ent.in b/docs/reference/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..fd86c16
--- /dev/null
+++ b/docs/reference/xml/gtkdocentities.ent.in
@@ -0,0 +1,7 @@
+<!ENTITY package "@PACKAGE@">
+<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@">
+<!ENTITY package_name "@PACKAGE_NAME@">
+<!ENTITY package_string "@PACKAGE_STRING@">
+<!ENTITY package_tarname "@PACKAGE_TARNAME@">
+<!ENTITY package_url "@PACKAGE_URL@">
+<!ENTITY package_version "@PACKAGE_VERSION@">
diff --git a/docs/reference/xml/meson.build b/docs/reference/xml/meson.build
new file mode 100644
index 0000000..a383dd5
--- /dev/null
+++ b/docs/reference/xml/meson.build
@@ -0,0 +1,17 @@
+ent_conf = configuration_data()
+
+ent_conf.set('PACKAGE', package)
+ent_conf.set('PACKAGE_BUGREPORT', package_bugreport)
+ent_conf.set('PACKAGE_NAME', package_name)
+ent_conf.set('PACKAGE_STRING', package_string)
+ent_conf.set('PACKAGE_TARNAME', package_tarname)
+ent_conf.set('PACKAGE_URL', package_url)
+ent_conf.set('PACKAGE_VERSION', package_version)
+
+ent = 'gtkdocentities.ent'
+
+configure_file(
+  input: ent + '.in',
+  output: ent,
+  configuration: ent_conf
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..8bcb88b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,217 @@
+project(
+  'Devhelp', 'c',
+  version: '3.26.0',
+  license: 'GPL2+',
+  default_options: [
+    'b_lundef=true',
+    'buildtype=debugoptimized',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.42.0'
+)
+
+devhelp_name = meson.project_name().to_lower()
+
+devhelp_version = meson.project_version()
+version_array = devhelp_version.split('.')
+devhelp_major_version = version_array[0].to_int()
+devhelp_minor_version = version_array[1].to_int()
+devhelp_micro_version = version_array[2].to_int()
+
+devhelp_api_version = '@0@.0'.format(devhelp_major_version)
+devhelp_api_name = '@0@-@1@'.format(devhelp_name, devhelp_api_version)
+
+devhelp_gir_version = '1.0'
+
+devhelp_prefix = get_option('prefix')
+devhelp_bindir = join_paths(devhelp_prefix, get_option('bindir'))
+devhelp_datadir = join_paths(devhelp_prefix, get_option('datadir'))
+devhelp_includedir = join_paths(devhelp_prefix, get_option('includedir'))
+devhelp_libdir = join_paths(devhelp_prefix, get_option('libdir'))
+devhelp_localedir = join_paths(devhelp_prefix, get_option('localedir'))
+devhelp_mandir = join_paths(devhelp_prefix, get_option('mandir'))
+
+devhelp_pkgdatadir = join_paths(devhelp_datadir, devhelp_name)
+devhelp_pkgincludedir = join_paths(devhelp_includedir, devhelp_api_name)
+
+# LT Version numbers, remember to change them just *before* a release.
+# A good time to update it is for the GNOME x.y.90 version, at API freeze,
+# so that packagers have the time to update the package.
+#   (Interfaces removed:    CURRENT++, AGE=0, REVISION=0)
+#   (Interfaces added:      CURRENT++, AGE++, REVISION=0)
+#   (No interfaces changed:                   REVISION++)
+libdevhelp_current = 4
+libdevhelp_revision = 0
+libdevhelp_age = 0
+libdevhelp_version = '@0@.@1@.@2@'.format(libdevhelp_current, libdevhelp_revision, libdevhelp_age)
+
+libdevhelp_name = '@0@-@1@'.format(devhelp_name, devhelp_major_version)
+
+devhelp_debug = get_option('buildtype').contains('debug')
+
+# package
+package = devhelp_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(), devhelp_version)
+package_tarname = devhelp_name
+package_url = 'https://wiki.gnome.org/Apps/Devhelp'
+package_version = devhelp_version
+
+cc = meson.get_compiler('c')
+
+config_h = configuration_data()
+
+# defines
+set_defines = [
+  # package
+  ['PACKAGE', package],
+  ['PACKAGE_BUGREPORT', package_bugreport],
+  ['PACKAGE_NAME', package_name],
+  ['PACKAGE_STRING', package_string],
+  ['PACKAGE_TARNAME', package_tarname],
+  ['PACKAGE_URL', package_url],
+  ['PACKAGE_VERSION', package_version],
+  ['VERSION', package_version],
+  # i18n
+  ['GETTEXT_PACKAGE', devhelp_name]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# 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
+
+# functions
+check_functions = [
+  # i18n
+  ['HAVE_DCGETTEXT', 'dcgettext'],
+  ['HAVE_GETTEXT', 'gettext'],
+  ['HAVE_ICONV', 'iconv']
+]
+
+if host_machine.system().contains('darwin')
+  check_functions += [
+    ['HAVE_CFLOCALECOPYCURRENT', 'CFLocaleCopyCurrent'],
+    ['HAVE_CFPREFERENCESCOPYAPPVALUE', 'CFPreferencesCopyAppValue']
+  ]
+endif
+
+foreach func: check_functions
+  config_h.set(func[0], cc.has_function(func[1]))
+endforeach
+
+# compiler flags
+common_flags = ['-DHAVE_CONFIG_H']
+
+if devhelp_debug
+  test_cflags = [
+    '-fno-strict-aliasing',
+    '-Wcast-align',
+    '-Wdeclaration-after-statement',
+    '-Wformat-nonliteral',
+    '-Wformat=2',
+    '-Winit-self',
+    '-Winline',
+    '-Wmissing-declarations',
+    '-Wmissing-format-attribute',
+    '-Wmissing-include-dirs',
+    '-Wmissing-noreturn',
+    '-Wmissing-prototypes',
+    '-Wnested-externs',
+    '-Wno-error=missing-field-initializers',
+    '-Wno-error=unused-parameter',
+    '-Wno-missing-field-initializers',
+    '-Wno-unused-parameter',
+    '-Wold-style-definition',
+    '-Wpacked',
+    '-Wpointer-arith',
+    '-Wredundant-decls',
+    '-Wshadow',
+    '-Wstrict-prototypes',
+    '-Wswitch-enum',
+    '-Wundef',
+    '-Wunused-but-set-variable',
+    '-Wwrite-strings'
+  ]
+
+  foreach cflag: test_cflags
+    if cc.has_argument(cflag)
+      common_flags += [cflag]
+    endif
+  endforeach
+endif
+
+add_project_arguments(common_flags, language: 'c')
+
+gio_req_version = '>= 2.38'
+gtk_req_version = '>= 3.22'
+webkit2gtk_req_version = '>= 2.6'
+
+webkit2gtk_dep = dependency('webkit2gtk-4.0', version: webkit2gtk_req_version)
+
+devhelp_deps = [
+  webkit2gtk_dep,
+  dependency('gio-2.0', version: gio_req_version),
+  dependency('gsettings-desktop-schemas'),
+  dependency('gtk+-3.0', version: gtk_req_version),
+  cc.find_library('m', required: true)
+]
+
+enable_introspection = get_option('enable-introspection')
+
+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')
+
+top_inc = include_directories('.')
+
+subdir('po')
+subdir('src')
+subdir('data')
+
+subdir('misc/gedit-plugin')
+
+enable_gtk_doc = get_option('enable-gtk-doc')
+if enable_gtk_doc
+  subdir('docs/reference')
+endif
+
+meson.add_install_script(
+  'meson_post_install.py',
+  devhelp_datadir
+)
+
+# Print a summary of the configuration
+output = 'Configuration:\n\n'
+output += '        ' + meson.project_name() +  ' version ' + devhelp_version + '\n\n'
+output += '        Source code location:  ' + meson.source_root() + '\n'
+output += '        Prefix:                ' + devhelp_prefix + '\n'
+output += '        Compiler:              ' + cc.get_id() + '\n'
+output += '        API documentation:     ' + enable_gtk_doc.to_string() + '\n'
+output += '        GObject introspection: ' + enable_introspection.to_string()
+message(output)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..253fb68
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+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..3a0ce33
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+if not os.environ.get('DESTDIR'):
+  icondir = os.path.join(sys.argv[1], 'icons', 'hicolor')
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+  schemadir = os.path.join(sys.argv[1], 'glib-2.0', 'schemas')
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
+
+  install_prefix = os.environ['MESON_INSTALL_PREFIX']
+  print('Byte-compiling python modules...')
+  subprocess.call(['pycompile', install_prefix])
+  subprocess.call(['python', '-O', '-m', 'compileall', '-f', '-q', install_prefix])
diff --git a/misc/gedit-plugin/Makefile.am b/misc/gedit-plugin/Makefile.am
index ca97af3..ffc2c24 100644
--- a/misc/gedit-plugin/Makefile.am
+++ b/misc/gedit-plugin/Makefile.am
@@ -9,6 +9,8 @@ plugin_PYTHON = devhelp.py
 plugin_DATA = $(PLUGIN_FILE)
 
 CLEANFILES = $(PLUGIN_FILE)
-EXTRA_DIST = $(DESKTOP_IN_FILES)
+EXTRA_DIST =                   \
+       $(DESKTOP_IN_FILES)     \
+       meson.build
 
 -include $(top_srcdir)/git.mk
diff --git a/misc/gedit-plugin/meson.build b/misc/gedit-plugin/meson.build
new file mode 100644
index 0000000..7045d05
--- /dev/null
+++ b/misc/gedit-plugin/meson.build
@@ -0,0 +1,18 @@
+plugin_dir = join_paths(devhelp_libdir, 'gedit', 'plugins')
+
+install_data(
+  devhelp_name + '.py',
+  install_dir: plugin_dir
+)
+
+plugin = devhelp_name + '.plugin'
+
+i18n.merge_file(
+  plugin,
+  type: 'desktop',
+  input: plugin + '.desktop.in',
+  output: plugin,
+  po_dir: po_dir,
+  install: true,
+  install_dir: plugin_dir
+)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..3ca995d
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(devhelp_name, preset: 'glib')
diff --git a/src/Makefile.am b/src/Makefile.am
index 4664b36..d82a26f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -182,6 +182,8 @@ EXTRA_DIST =                                \
        dh-enum-types-app.c.template    \
        dh-enum-types-app.h.template    \
        dh.gresource.xml                \
+       meson.build                     \
+       devhelp.map                     \
        $(resource_files)               \
        $(NULL)
 
diff --git a/src/devhelp.map b/src/devhelp.map
new file mode 100644
index 0000000..9ca3a5d
--- /dev/null
+++ b/src/devhelp.map
@@ -0,0 +1,6 @@
+{
+global:
+  dh_*;
+local:
+       *;
+};
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..1f9aae3
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,190 @@
+src_inc = include_directories('.')
+
+libdevhelp_headers = files(
+  'devhelp.h',
+  'dh-assistant-view.h',
+  'dh-book.h',
+  'dh-book-manager.h',
+  'dh-book-tree.h',
+  'dh-init.h',
+  'dh-keyword-model.h',
+  'dh-link.h',
+  'dh-sidebar.h'
+)
+
+install_headers(
+  libdevhelp_headers,
+  subdir: join_paths(devhelp_api_name, devhelp_name)
+)
+
+libdevhelp_sources = files(
+  'dh-assistant-view.c',
+  'dh-book.c',
+  'dh-book-manager.c',
+  'dh-book-tree.c',
+  'dh-init.c',
+  'dh-keyword-model.c',
+  'dh-link.c',
+  'dh-sidebar.c'
+)
+
+enum = 'dh-enum-types'
+
+libdevhelp_sources += gnome.mkenums(
+  enum,
+  sources: libdevhelp_headers,
+  c_template: enum + '.c.template',
+  h_template: enum + '.h.template',
+  install_header: true,
+  install_dir: join_paths(devhelp_pkgincludedir, devhelp_name)
+)
+
+headers = files(
+  'dh-error.h',
+  'dh-language.h',
+  'dh-parser.h',
+  'dh-preferences.h',
+  'dh-settings.h',
+  'dh-util.h'
+)
+
+sources = files(
+  'dh-error.c',
+  'dh-language.c',
+  'dh-parser.c',
+  'dh-preferences.c',
+  'dh-util.c',
+  'dh-settings.c'
+)
+
+resource_files = files(
+  'devhelp-menu.ui',
+  'dh-assistant.ui',
+  'dh-preferences.ui',
+  'dh-window.ui',
+  'help-overlay.ui'
+)
+
+sources += gnome.compile_resources(
+  'dh-resources',
+  'dh.gresource.xml',
+  source_dir: '.',
+  c_name: 'dh',
+  dependencies: resource_files,
+  export: true
+)
+
+cflags = [
+  '-DLOCALEDIR="@0@"'.format(devhelp_localedir),
+  '-DDATADIR="@0@"'.format(devhelp_datadir),
+  '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
+  '-DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES'
+]
+
+symbol_map = 'devhelp.map'
+
+test_ldflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbol_map)
+
+ldflags = []
+
+if host_machine.system().contains('linux') and cc.has_argument(test_ldflag)
+  ldflags += test_ldflag
+endif
+
+libdevhelp = shared_library(
+  libdevhelp_name,
+  sources: libdevhelp_sources + sources,
+  version: libdevhelp_version,
+  include_directories: top_inc,
+  dependencies: devhelp_deps,
+  c_args: cflags,
+  link_args: ldflags,
+  link_depends: symbol_map,
+  install: true,
+  install_dir: devhelp_libdir
+)
+
+libdevhelp_dep = declare_dependency(
+  link_with: libdevhelp,
+  include_directories: src_inc,
+  dependencies: devhelp_deps
+)
+
+pkg.generate(
+  libraries: libdevhelp,
+  version: devhelp_version,
+  name: devhelp_name,
+  description: devhelp_name,
+  filebase: 'lib' + devhelp_api_name,
+  subdirs: devhelp_pkgincludedir,
+  requires: [
+    'gio-2.0 ' + gio_req_version,
+    'gtk+-3.0 ' + gtk_req_version,
+    'webkit2gtk-4.0 ' + webkit2gtk_req_version
+  ],
+  requires_private: 'gsettings-desktop-schemas',
+  variables: 'exec_prefix=' + devhelp_prefix,
+  install_dir: join_paths(devhelp_libdir, 'pkgconfig')
+)
+
+headers = files(
+  'dh-app.h',
+  'dh-assistant.h',
+  'dh-window.h'
+)
+
+sources = files(
+  'dh-app.c',
+  'dh-assistant.c',
+  'dh-main.c',
+  'dh-window.c'
+)
+
+enum = 'dh-enum-types-app'
+
+sources += gnome.mkenums(
+  enum,
+  sources: headers,
+  c_template: enum + '.c.template',
+  h_template: enum + '.h.template'
+)
+
+executable(
+  devhelp_name,
+  sources,
+  include_directories: top_inc,
+  dependencies: libdevhelp_dep,
+  install: true,
+  install_dir: devhelp_bindir
+)
+
+if enable_introspection
+  gir_incs = [
+    'Gtk-3.0',
+    'WebKit2-4.0'
+  ]
+
+  gir_extra_args = [
+    '--c-include="devhelp/devhelp.h"',
+    '--warn-all'
+  ]
+
+  gir_dir = join_paths(devhelp_datadir, 'gir-' + devhelp_gir_version)
+  typelib_dir = join_paths(devhelp_libdir, 'girepository-' + devhelp_gir_version)
+
+  gnome.generate_gir(
+    libdevhelp,
+    sources: libdevhelp_sources + libdevhelp_headers,
+    namespace: meson.project_name(),
+    nsversion: devhelp_api_version,
+    symbol_prefix: 'dh',
+    identifier_prefix: 'Dh',
+    export_packages: 'lib' + devhelp_api_name,
+    extra_args: gir_extra_args,
+    includes: gir_incs,
+    include_directories: top_inc,
+    install: true,
+    install_dir_gir: gir_dir,
+    install_dir_typelib: typelib_dir
+  )
+endif


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