[gnome-terminal/wip/meson: 3/3] build: Port to meson build system



commit 68936a567adc9c4ab01a224dd77a9970cdd338b4
Author: Christian Persch <chpe src gnome org>
Date:   Thu May 2 12:36:53 2019 +0200

    build: Port to meson build system
    
    Based on a patch by Iñigo Martínez.
    
    https://gitlab.gnome.org/GNOME/gnome-terminal/issues/63

 Makefile.meson                                     |  43 ++
 data/icons/meson.build                             |  31 +-
 data/icons/meson_updateiconcache.py                |  28 ++
 help/meson.build                                   |  34 +-
 meson.build                                        | 484 ++++++++++++++-------
 meson_desktopfile.py                               |  28 ++
 meson_options.txt                                  |  58 ++-
 meson_post_install.py                              |  15 -
 org.gnome.Terminal.Nautilus.metainfo.xml.in        |   6 +-
 org.gnome.Terminal.desktop.in.in                   |  10 +-
 ...ta.xml.in => org.gnome.Terminal.metainfo.xml.in |   8 +-
 po/POTFILES.skip                                   |   5 -
 po/meson.build                                     |  22 +-
 src/meson.build                                    | 425 +++++++++++-------
 src/meson_compileschemas.py                        |  28 ++
 src/terminal-app.c                                 |   8 +-
 16 files changed, 865 insertions(+), 368 deletions(-)
---
diff --git a/Makefile.meson b/Makefile.meson
new file mode 100644
index 00000000..4e92f6f8
--- /dev/null
+++ b/Makefile.meson
@@ -0,0 +1,43 @@
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this library.  If not, see <https://www.gnu.org/licenses/>.
+
+srcdir=@srcdir@
+builddir=@builddir@
+
+#
+
+NTHREADS = 1
+NJOBS = -j$(NTHREADS)
+NINJA = ninja $(NJOBS)
+
+#
+
+all:
+       $(NINJA)
+
+check:
+       MESON_TESTTHREADS=$(NTHREADS) $(NINJA) test
+
+clean:
+       $(NINJA) clean
+
+coverage:
+       $(NINJA) coverage
+
+install:
+       $(NINJA) install
+
+uninstall:
+       $(NINJA) uninstall
diff --git a/data/icons/meson.build b/data/icons/meson.build
index fb13555e..d9fb25d0 100644
--- a/data/icons/meson.build
+++ b/data/icons/meson.build
@@ -1,11 +1,34 @@
+# Copyright © 2018, 2019 Iñigo Martínez
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this library.  If not, see <https://www.gnu.org/licenses/>.
+
+icondir = gt_datadir / 'icons' / 'hicolor'
+
 install_data(
   'hicolor_apps_scalable_org.gnome.Terminal.svg',
-  install_dir: gt_datadir / 'icons/hicolor/scalable/apps',
-  rename: gt_iface_name + '.svg',
+  install_dir: icondir / 'scalable' /'apps',
+  rename: 'org.gnome.Terminal.svg',
 )
 
 install_data(
   'hicolor_apps_symbolic_org.gnome.Terminal-symbolic.svg',
-  install_dir: gt_datadir / 'icons/hicolor/symbolic/apps',
-  rename: gt_iface_name + '-symbolic.svg',
+  install_dir: icondir / 'symbolic' / 'apps',
+  rename: 'org.gnome.Terminal-symbolic.svg',
+)
+
+meson.add_install_script(
+  'meson_updateiconcache.py',
+  icondir,
 )
diff --git a/data/icons/meson_updateiconcache.py b/data/icons/meson_updateiconcache.py
new file mode 100755
index 00000000..b625d073
--- /dev/null
+++ b/data/icons/meson_updateiconcache.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
+import os
+import subprocess
+import sys
+
+if os.environ.get('DESTDIR'):
+    sys.exit(0)
+
+prefix = os.environ['MESON_INSTALL_PREFIX']
+icondir = os.path.join(prefix, sys.argv[1])
+
+rv = subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+sys.exit(0)
diff --git a/help/meson.build b/help/meson.build
index 1a036e51..3fee9682 100644
--- a/help/meson.build
+++ b/help/meson.build
@@ -1,4 +1,22 @@
-sources = [
+# Copyright © 2018, 2019 Iñigo Martínez
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
+help_id = gt_name
+
+help_sources = [
   'adv-keyboard-shortcuts.page',
   'app-colors.page',
   'app-cursor.page',
@@ -12,20 +30,20 @@ sources = [
   'introduction.page',
   'legal.xml',
   'overview.page',
-  'pref.page',
   'pref-bell.page',
-  'pref-custom-exit.page',
   'pref-custom-command.page',
+  'pref-custom-exit.page',
   'pref-encoding.page',
   'pref-keyboard-access.page',
   'pref-login-shell.page',
   'pref-menubar.page',
-  'pref-profiles.page',
   'pref-profile-char-width.page',
   'pref-profile-encoding.page',
+  'pref-profiles.page',
   'pref-scrolling.page',
   'pref-tab-window.page',
   'pref-user-input.page',
+  'pref.page',
   'prob-reset.page',
   'txt-copy-paste.page',
   'txt-links.page',
@@ -34,13 +52,13 @@ sources = [
   'txt-select-text.page',
 ]
 
-media = [
+help_media = [
   'figures/gnome-terminal.png',
   'figures/gnome-terminal-icon.png',
 ]
 
 gnome.yelp(
-  gt_name,
-  sources: sources,
-  media: media,
+  help_id,
+  sources: help_sources,
+  media: help_media,
 )
diff --git a/meson.build b/meson.build
index 213c982a..d5b452eb 100644
--- a/meson.build
+++ b/meson.build
@@ -1,12 +1,57 @@
+# Copyright © 2018, 2019 Iñigo Martínez
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
 project(
-  'GNOME Terminal', 'c',
+  'gnome-terminal',
+  ['c'],
   version: '3.33.0',
-  license: 'GPL3+',
-  default_options: 'buildtype=debugoptimized',
-  meson_version: '>= 0.50.0',
+  license: ['GPL-3.0-or-later'],
+  default_options: [
+    'buildtype=release',
+    'c_std=gnu11',
+    'warning_level=' + (meson.version().version_compare('>= 0.50.0') ? '0' : '1'),
+    'b_ndebug=false',
+  ],
+  meson_version: '>= 0.49.0',
 )
 
-gt_name = 'gnome-terminal'
+# Naming
+
+gt_name       = 'gnome-terminal'
+gt_namespace  = 'Terminal'
+gt_iface_name = 'org.gnome.' + gt_namespace
+
+# Requirements
+
+vte_req_version               = '0.57.0'
+
+gtk3_req_version              = '3.12.0'
+gtk4_req_version              = '4.0.0'
+
+dconf_req_version             = '0.14.0'
+gio_req_version               = '2.34.0'
+glib_req_version              = '2.42.0'
+gsettings_schemas_req_version = '0.1.0'
+pango_req_version             = '1.0'
+pcre2_req_version             = '10.21'
+
+vte_gtk3_api_version          = '2.91'
+vte_gtk4_api_version          = '3.91'
+
+# Versioning
 
 gt_version = meson.project_version()
 version_array = gt_version.split('.')
@@ -14,230 +59,343 @@ gt_major_version = version_array[0].to_int()
 gt_minor_version = version_array[1].to_int()
 gt_micro_version = version_array[2].to_int()
 
-gt_prefix = get_option('prefix')
+# i18n
+
+gt_gettext_domain = gt_name
+
+# Directories
+
 gt_datadir = get_option('datadir')
 gt_libdir = get_option('libdir')
 gt_libexecdir = get_option('libexecdir')
 gt_localedir = get_option('localedir')
+gt_prefix = get_option('prefix')
 
 gt_pkgdatadir = gt_datadir / gt_name
 
-gt_namespace = 'Terminal'
-gt_iface_name = 'org.gnome.' + gt_namespace
+# Debug
 
-gt_debug = get_option('buildtype').contains('debug')
+enable_debug = get_option('debugg') or get_option('debug') or get_option('buildtype').contains('debug')
+
+# Meson modules
 
 gnome = import('gnome')
-i18n = import('i18n')
 pkg = import('pkgconfig')
 
-source_root = meson.current_source_dir()
+i18n = import('i18n')
+podir = meson.current_source_dir() / 'po'
 
-po_dir = source_root / 'po'
+# Compilers
 
-intltool_merge = find_program('intltool-merge')
-intltool_cache = po_dir / '.intltool-merge-cache'
-intltool_desktop_cmd = [intltool_merge, '-d', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@']
-intltool_xml_cmd = [intltool_merge, '-x', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@']
+cc = meson.get_compiler('c')
 
 top_inc = include_directories('.')
 
-cc = meson.get_compiler('c')
+# Start config.h
 
 config_h = configuration_data()
 
-# version
+config_h.set_quoted('GETTEXT_PACKAGE', gt_gettext_domain)
 config_h.set_quoted('VERSION', gt_version)
+config_h.set('ENABLE_DEBUG', enable_debug)
+
+# FIXME AC_USE_SYSTEM_EXTENSIONS also supported non-gnu systems
+config_h.set10('_GNU_SOURCE', true)
+
+# Compiler
+
+# Meson has a misfeature where it allows the user to override the -std option
+# for the C/C++ compiler. Disallow that.
+
+assert(get_option('c_std') == 'gnu11', 'cannot override C std version')
+
+# Asserts must not be disabled
+
+assert(get_option('b_ndebug') == 'false', 'assertions may not be disabled')
+
+# Compiler flags
+
+compiler_flags_common = [
+  '-Wall',
+  '-Wcast-align',
+  '-Wendif-labels',
+  '-Werror=implicit-function-declaration',
+  '-Werror=init-self',
+  '-Werror=missing-include-dirs',
+  '-Werror=missing-prototypes',
+  '-Werror=pointer-arith',
+  '-Wextra',
+  '-Wfloat-equal',
+  '-Wformat-signedness',
+  '-Winvalid-pch',
+  '-Wlogical-op',
+  '-Wmissing-declarations',
+  '-Wmissing-format-attribute',
+  '-Wmissing-include-dirs',
+  '-Wmissing-noreturn',
+  '-Wno-missing-field-initializers',
+  '-Wno-switch-enum',
+  '-Wno-unused-parameter',
+  '-Wpacked',
+  '-Wshadow',
+  '-Wsign-compare',
+  '-Wstrict-aliasing=2',
+  '-Wundef',
+  '-Wuninitialized',
+  '-Wunsafe-loop-optimizations',
+  '-Wvla',
+  '-Wwrite-strings',
+  '-fdiagnostics-show-option',
+  '-fno-common',
+  '-fstack-protector',
+  '-fstack-protector-strong',
+  '-fvisibility=hidden',
+]
+
+if enable_debug
+  compiler_flags_common += [
+    '-ggdb3',
+  ]
+endif
 
-# Globally define_GNU_SOURCE and therefore enable the GNU extensions
-config_h.set('_GNU_SOURCE', true)
-
-# Debugging
-config_h.set('ENABLE_DEBUG', gt_debug)
+# These are currently needed but the code should be fixed instead
+compiler_flags_common_undesirable = [
+  '-fno-strict-aliasing'
+]
+
+compiler_flags_c_only = [
+  '-Waggregate-return',
+  '-Wimplicit',
+  '-Wimplicit-fallthrough=3',
+  '-Wnested-externs',
+  '-Wold-style-definition',
+  '-Wstrict-prototypes',
+]
+
+global_cflags = cc.get_supported_arguments(compiler_flags_common +
+                                           compiler_flags_common_undesirable +
+                                           compiler_flags_c_only)
+
+# Meson problem: GCC only accepts the latter 2 options of the 3 below
+# if the first is *also* passed, which doesn't work with get_supported_arguments()
+# above. So just add these unconditionally, since all compilers we support
+# accept these flags.
+
+compiler_flags_format_warnings = [
+  '-Werror=format=2',
+  '-Werror=format-nonliteral',
+  '-Werror=format-security',
+]
+
+global_cflags += compiler_flags_format_warnings
+
+# ... and now make these flags the default
+
+add_project_arguments(global_cflags, language: 'c')
+
+# Dependencies
+
+dconf_dep     = dependency('dconf',      version: '>=' + dconf_req_version)
+gio_dep       = dependency('gio-2.0',    version: '>=' + gio_req_version)
+glib_dep      = dependency('glib-2.0',   version: '>=' + glib_req_version)
+gobject_dep   = dependency('gobject-2.0')
+gsettings_dep = dependency('gsettings-desktop-schemas', version: '>=' + gsettings_schemas_req_version)
+pango_dep     = dependency('pango',      version: '>=' + pango_req_version)
+pcre2_dep     = dependency('libpcre2-8', version: '>=' + pcre2_req_version)
+pthreads_dep  = dependency('threads')
+uuid_dep      = dependency('uuid')
+zlib_dep      = dependency('zlib')
+
+if get_option('gtk3')
+  gdk3_dep     = dependency('gdk-3.0')
+  gtk3_dep     = dependency('gtk+-3.0', version: '>=' + gtk3_req_version)
+  vte_gtk3_dep = dependency('vte-' + vte_gtk3_api_version, version: '>=' + vte_req_version)
+
+  gdk3_targets = gdk3_dep.get_pkgconfig_variable('targets')
+  if gdk3_targets.contains('x11')
+    x11_dep = dependency('x11')
+  else
+    x11_dep = dependency('', required: false)
+  endif
+else
+  gtk3_dep     = dependency('', required: false)
+  vte_gtk3_dep = dependency('', required: false)
+  x11_dep      = dependency('', required: false)
+endif
 
-# i18n
-config_h.set_quoted('GETTEXT_PACKAGE', gt_name)
-
-# compiler flags
-common_flags = ['-DHAVE_CONFIG_H']
-warn_flags = []
-
-if gt_debug
-  common_flags += cc.get_supported_arguments([
-    #'-pthread',
-    #'-pipe',
-    '-fdiagnostics-show-option',
-    '-fno-common',
-    '-fno-strict-aliasing',
-    '-fstack-protector',
-    '-fstack-protector-strong',
-    '-fvisibility=hidden',
-    '-Waggregate-return',
-    '-Wcast-align',
-    '-Werror=format=2',
-    '-Werror=format-nonliteral',
-    '-Werror=format-security',
-    '-Werror=implicit-function-declaration',
-    '-Werror=init-self',
-    '-Werror=missing-include-dirs',
-    '-Werror=missing-prototypes',
-    '-Werror=pointer-arith',
-    '-Wfloat-equal',
-    '-Wformat-signedness',
-    '-Wlogical-op',
-    '-Wmissing-declarations',
-    '-Wmissing-format-attribute',
-    '-Wmissing-include-dirs',
-    '-Wmissing-noreturn',
-    '-Wnested-externs',
-    '-Wno-missing-field-initializers',
-    '-Wno-switch-enum',
-    '-Wno-unused-parameter',
-    '-Wold-style-definition',
-    '-Wpacked',
-    '-Wshadow',
-    '-Wstrict-prototypes',
-    '-Wundef',
-    '-Wunsafe-loop-optimizations',
-    '-Wwrite-strings',
-  ])
+if get_option('gtk4')
+  gtk4_dep     = dependency('gtk+-4.0', version: '>=' + gtk4_req_version)
+  vte_gtk4_dep = dependency('vte-' + vte_gtk4_api_version, version: '>=' + vte_req_version)
+else
+  gtk4_dep     = dependency('', required: false)
+  vte_gtk4_dep = dependency('', required: false)
 endif
 
-add_project_arguments(common_flags, language: 'c')
+libm_dep = cc.find_library('m')
 
-dconf_dep = dependency('dconf', version: '>= 0.14.0')
-gio_dep = dependency('gio-2.0', version: '>= 2.34.0')
-glib_dep = dependency('glib-2.0', version: '>= 2.42.0')
-gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', version: '>= 0.1.0')
-gtk_dep = dependency('gtk+-3.0', version: '>= 3.12.0')
-libpcre_dep = dependency('libpcre2-8', version: '>= 10.00')
-threads_dep = dependency('threads')
-uuid_dep = dependency('uuid')
-vte_dep = dependency('vte-2.91', version: '>= 0.55.92')
+# Dependency directories
+
+dbus_dep = dependency('dbus-1')
+dbus_servicedir = dbus_dep.get_pkgconfig_variable(
+  'session_bus_services_dir',
+  define_variable: ['datadir', gt_prefix / gt_datadir],
+)
+dbus_interfacedir = dbus_dep.get_pkgconfig_variable('interfaces_dir')
 
-m_dep = cc.find_library('m')
+gio_schemadir = gio_dep.get_pkgconfig_variable(
+  'schemasdir',
+  define_variable: ['datadir', gt_prefix / gt_datadir],
+  default: gt_prefix / gt_datadir / 'glib-2.0' / 'schemas',
+)
 
-gdk_dep = dependency('gdk-3.0')
-gdk_targets = gdk_dep.get_pkgconfig_variable('targets')
+# It is correct for this to be in ${prefix}/lib, even on systems where that
+# does not match ${libdir}. This is what systemd uses on such platforms.
+systemd_userunitdir = gt_prefix / 'lib' / 'systemd' / 'user'
 
-gdk_x11_target = gdk_targets.contains('x11')
-if gdk_x11_target
-  x11_dep = dependency('x11')
-endif
+# Shell search provider option
 
-if gdk_targets.contains('win32') or gdk_targets.contains('quartz')
-  warning('unsupported GDK backend target')
-endif
+if get_option('search_provider')
+  gs_searchproviderdir = gt_datadir / 'gnome-shell' / 'search-providers'
 
-if not (gdk_targets.contains('broadway') or gdk_targets.contains('wayland'))
-  warning('unknown GDK backend target')
+  config_h.set('ENABLE_SEARCH_PROVIDER', true)
 endif
 
-# GIO schemas
-gio_schemasdir = gio_dep.get_pkgconfig_variable(
-  'schemasdir',
-  define_variable: ['datadir', gt_prefix / gt_datadir],
-  default: gt_prefix / gt_datadir / 'glib-2.0/schemas',
-)
+# Nautilus extension option
 
-# systemd user unit directory
-systemd_systemduserunitdir = get_option('systemduserunitdir')
-if systemd_systemduserunitdir == ''
-  # FIXME: this would ideally use the systemduserunitdir pkgconfig variable, but
-  # it does not depend on variables we can override to install within prefix.
-  #systemd_systemduserunitdir = dependency('systemd').get_pkgconfig_variable('systemduserunitdir')
-  systemd_systemduserunitdir = gt_libdir / 'systemd/user'
-endif
+if get_option('nautilus_extension')
+  assert(get_option('gtk3'), 'nautilus extension requires gtk3')
 
-# DBus
-dbus_dep = dependency('dbus-1')
-dbus_session_bus_services_dir = dbus_dep.get_pkgconfig_variable('session_bus_services_dir', define_variable: 
['datadir', gt_prefix / gt_datadir])
-
-# GNOME Shell search provider
-enable_search_provider = get_option('search_provider')
-if enable_search_provider
-  shell_search_provider_iface = dbus_dep.get_pkgconfig_variable('interfaces_dir') / 
'org.gnome.ShellSearchProvider2.xml'
-  res = run_command(find_program('test'), '-e', shell_search_provider_iface)
-  assert(res.returncode() == 0, 'gnome-shell search provider requested but interface definition file not 
found')
+  nautilus_dep = dependency('libnautilus-extension', version: '>= 3.0.0')
+  nautilus_extensiondir = nautilus_dep.get_pkgconfig_variable(
+    'extensiondir',
+    define_variable: ['libdir', gt_prefix / gt_libdir],
+  )
 endif
-config_h.set('ENABLE_SEARCH_PROVIDER', enable_search_provider)
 
-# Nautilus extension
-enable_nautilus_extension = get_option('nautilus_extension')
-if enable_nautilus_extension
-  libnautilus_extension_dep = dependency('libnautilus-extension', version: '>= 3.0.0')
-  libnautilus_extension_extensiondir = libnautilus_extension_dep.get_pkgconfig_variable('extensiondir', 
define_variable: ['libdir', gt_prefix / gt_libdir])
+# Appstream data
+
+appdatadir = gt_prefix / gt_datadir / 'metainfo'
+
+i18n.merge_file(
+  'org.gnome.Terminal.metainfo.xml',
+  input: 'org.gnome.Terminal.metainfo.xml' + '.in',
+  output: '@BASENAME@',
+  po_dir: podir,
+  install: true,
+  install_dir: appdatadir,
+)
 
+if get_option('nautilus_extension')
   appdata = gt_iface_name + '.Nautilus.metainfo.xml'
 
-  custom_target(
-    appdata,
-    input: appdata + '.in',
+  i18n.merge_file(
+    'org.gnome.Terminal.Nautilus.metainfo.xml',
+    input: 'org.gnome.Terminal.Nautilus.metainfo.xml' + '.in',
     output: '@BASENAME@',
-    command: intltool_xml_cmd,
+#    output: 'org.gnome.Terminal.Nautilus.metainfo.xml',
+    po_dir: podir,
     install: true,
-    install_dir: gt_datadir / 'metainfo',
-  )
+    install_dir: appdatadir,
+)
 endif
 
-subdir('data/icons')
-subdir('src')
-subdir('po')
-subdir('help')
+# Desktop file
 
-desktop_conf = {'VERSION': gt_version}
+desktopdatadir = gt_prefix / gt_datadir / 'applications'
 
-desktop = gt_iface_name + '.desktop'
+desktop_conf = {
+  'VERSION': gt_version
+}
 
 desktop_in = configure_file(
-  input: desktop + '.in.in',
+  input: 'org.gnome.Terminal.desktop.in.in',
   output: '@BASENAME@',
   configuration: desktop_conf,
+  install: false,
 )
 
-custom_target(
-  desktop,
+i18n.merge_file(
+  'org.gnome.Terminal.desktop',
   input: desktop_in,
   output: '@BASENAME@',
-  command: intltool_desktop_cmd,
+  type: 'desktop',
+  po_dir: podir,
   install: true,
-  install_dir: gt_datadir / 'applications',
+  install_dir: desktopdatadir,
 )
 
-appdata = gt_iface_name + '.appdata.xml'
-
-custom_target(
-  appdata,
-  input: appdata + '.in',
-  output: '@BASENAME@',
-  command: intltool_xml_cmd,
-  install: true,
-  install_dir: gt_datadir / 'metainfo',
+meson.add_install_script(
+  'meson_desktopfile.py',
+  desktopdatadir,
+  'org.gnome.Terminal.desktop',
 )
 
+# Write config.h
+
 configure_file(
   output: 'config.h',
   configuration: config_h,
 )
 
-meson.add_install_script(
-  'meson_post_install.py',
-  gt_datadir,
-  gio_schemasdir,
+# Subdirs
+
+subdir('src')
+subdir('data/icons')
+subdir('po')
+
+if get_option('docs')
+  subdir('help')
+endif
+
+# Simple compat Makefile
+
+makefile_conf = configuration_data()
+makefile_conf.set('srcdir', meson.current_source_dir())
+makefile_conf.set('builddir', meson.current_build_dir())
+
+configure_file(
+  input: 'Makefile.meson',
+  output: '@BASENAME@',
+  configuration: makefile_conf,
 )
 
-output = '\ngnome-terminal-' + gt_version + ':\n\n'
-output += '\tprefix:                 ' + gt_prefix + '\n'
-output += '\tsource code location:   ' + source_root + '\n'
-output += '\tcompiler:               ' + cc.get_id() + '\n'
-output += '\tDBus service dir:       ' + dbus_session_bus_services_dir + '\n'
-output += '\tDebug:                  ' + gt_debug.to_string() + '\n'
-output += '\tSearch provider:        ' + enable_search_provider.to_string() + '\n'
-if enable_search_provider
-  output += '\tShell search provider:  ' + shell_search_provider_iface + '\n'
+# .gitignore everything in the build directory
+
+configure_file(
+  output: '.gitignore',
+  command: ['echo', '**/**',],
+  capture: true,
+  install: false,
+)
+
+# Summary
+
+output = '\n'
+output += 'Configuration for GNOME Terminal:\n\n'
+output += '  Version:                ' + gt_version + '\n'
+output += '\n'
+output += '  C compiler:             ' + cc.get_id() + '\n\n'
+output += '  Coverage:               ' + get_option('b_coverage').to_string() + '\n'
+output += '  Documentation:          ' + get_option('docs').to_string() + '\n'
+output += '  Debug:                  ' + enable_debug.to_string() + '\n'
+output += '  GTK+ 3.0:               ' + get_option('gtk3').to_string() + '\n'
+output += '  GTK+ 4.0:               ' + get_option('gtk4').to_string() + '\n\n'
+output += '  Nautilus Extension:     ' + get_option('nautilus_extension').to_string() + '\n'
+output += '  Search Provider:        ' + get_option('search_provider').to_string() + '\n'
+output += '\n'
+output += '  Prefix:                 ' + get_option('prefix') + '\n'
+output += '  Appstream data dir:     ' + appdatadir + '\n'
+output += '  D-BUS interfaces dir:   ' + dbus_interfacedir + '\n'
+output += '  D-BUS services dir:     ' + dbus_servicedir + '\n'
+output += '  Desktop data dir:       ' + desktopdatadir + '\n'
+output += '  Schemas dir:            ' + gio_schemadir + '\n'
+output += '  Systemd user unit dir:  ' + dbus_servicedir + '\n'
+if get_option('nautilus_extension')
+  output += '  Nautilus extension dir: ' + nautilus_extensiondir + '\n'
 endif
-output += '\tNautilus extension:     ' + enable_nautilus_extension.to_string() + '\n'
-if enable_nautilus_extension
-  output += '\tNautilus extension dir: ' + libnautilus_extension_extensiondir
+if get_option('search_provider')
+  output += '  Search provider dir:    ' + gs_searchproviderdir + '\n'
 endif
 message(output)
+
+# Done
diff --git a/meson_desktopfile.py b/meson_desktopfile.py
new file mode 100755
index 00000000..ced926f1
--- /dev/null
+++ b/meson_desktopfile.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
+import os
+import subprocess
+import sys
+
+if os.environ.get('DESTDIR'):
+    sys.exit(0)
+
+prefix = os.environ['MESON_INSTALL_PREFIX']
+desktopfile = os.path.join(prefix, sys.argv[1], sys.argv[2])
+
+rv = subprocess.call(['desktop-file-validate', desktopfile])
+sys.exit(rv)
diff --git a/meson_options.txt b/meson_options.txt
index 33276add..7dcb4948 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,56 @@
-option('systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user 
units')
+# Copyright © 2018, 2019 Iñigo Martínez
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
 
-option('search_provider', type: 'boolean', value: true, description: 'Enable gnome-shell search provider')
-option('nautilus_extension', type: 'boolean', value: false, description: 'Enable nautilus extension')
+option(
+  'debugg', # for some reason, 'debug' is "reserved"
+  type: 'boolean',
+  value: false,
+  description: 'Enable extra debugging functionality',
+)
+
+option(
+  'docs',
+  type: 'boolean',
+  value: true,
+  description: 'Enable documentation',
+)
+
+option(
+  'gtk3',
+  type: 'boolean',
+  value: true,
+  description: 'Enable GTK+ 3.0 widget',
+)
+
+option(
+  'gtk4',
+  type: 'boolean',
+  value: false,
+  description: 'Enable GTK+ 4.0 widget',
+)
+
+option(
+  'nautilus_extension',
+  type: 'boolean',
+  value: false,
+  description: 'Enable nautilus extension',
+)
+
+option(
+  'search_provider',
+  type: 'boolean',
+  value: false,
+  description: 'Enable gnome-shell search provider',
+)
diff --git a/org.gnome.Terminal.Nautilus.metainfo.xml.in b/org.gnome.Terminal.Nautilus.metainfo.xml.in
index f9b17064..24aa1018 100644
--- a/org.gnome.Terminal.Nautilus.metainfo.xml.in
+++ b/org.gnome.Terminal.Nautilus.metainfo.xml.in
@@ -36,10 +36,10 @@
   <extends>org.gnome.Nautilus.desktop</extends>
   <metadata_license>GPL-3.0+ or GFDL-1.3-only</metadata_license>
   <project_license>GPL-3.0+</project_license>
-  <_name>Terminal plugin for Files</_name>
-  <_summary>Open a terminal from Files</_summary>
+  <name>Terminal plugin for Files</name>
+  <summary>Open a terminal from Files</summary>
   <description>
-    <_p>Open Terminal is a plugin for the Files application that adds a menu item to the context menu to 
open a terminal in the currently browsed directory.</_p>
+    <p>Open Terminal is a plugin for the Files application that adds a menu item to the context menu to open 
a terminal in the currently browsed directory.</p>
   </description>
   <url type="homepage">https://wiki.gnome.org/Apps/Terminal</url>
   <project_group>GNOME</project_group>
diff --git a/org.gnome.Terminal.desktop.in.in b/org.gnome.Terminal.desktop.in.in
index ae18a544..7b7c44fc 100644
--- a/org.gnome.Terminal.desktop.in.in
+++ b/org.gnome.Terminal.desktop.in.in
@@ -1,8 +1,8 @@
 [Desktop Entry]
 # VERSION=@VERSION@
-_Name=Terminal
-_Comment=Use the command line
-_Keywords=shell;prompt;command;commandline;cmd;
+Name=Terminal
+Comment=Use the command line
+Keywords=shell;prompt;command;commandline;cmd;
 TryExec=gnome-terminal
 Exec=gnome-terminal
 Icon=org.gnome.Terminal
@@ -13,9 +13,9 @@ X-GNOME-SingleWindow=false
 Actions=new-window;preferences;
 
 [Desktop Action new-window]
-_Name=New Window
+Name=New Window
 Exec=gnome-terminal --window
 
 [Desktop Action preferences]
-_Name=Preferences
+Name=Preferences
 Exec=gnome-terminal --preferences
diff --git a/org.gnome.Terminal.appdata.xml.in b/org.gnome.Terminal.metainfo.xml.in
similarity index 85%
rename from org.gnome.Terminal.appdata.xml.in
rename to org.gnome.Terminal.metainfo.xml.in
index 31aaa302..b411ccdd 100644
--- a/org.gnome.Terminal.appdata.xml.in
+++ b/org.gnome.Terminal.metainfo.xml.in
@@ -35,11 +35,11 @@
   <id>org.gnome.Terminal.desktop</id>
   <metadata_license>GPL-3.0+ or GFDL-1.3-only</metadata_license>
   <project_license>GPL-3.0+</project_license>
-  <_name>Terminal</_name>
-  <_summary>Use the command line</_summary>
+  <name>Terminal</name>
+  <summary>Use the command line</summary>
   <description>
-    <_p>GNOME Terminal is a terminal emulator application for accessing a UNIX shell environment which can 
be used to run programs available on your system.</_p>
-    <_p>It supports several profiles, multiple tabs and implements several keyboard shortcuts.</_p>
+    <p>GNOME Terminal is a terminal emulator application for accessing a UNIX shell environment which can be 
used to run programs available on your system.</p>
+    <p>It supports several profiles, multiple tabs and implements several keyboard shortcuts.</p>
   </description>
   <screenshots>
     <screenshot 
type="default">https://help.gnome.org/users/gnome-terminal/stable/figures/gnome-terminal.png</screenshot>
diff --git a/po/meson.build b/po/meson.build
index 470d71d7..5302e6fb 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -1 +1,21 @@
-i18n.gettext(gt_name, preset: 'glib')
+# Copyright © 2018, 2019 Iñigo Martínez
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
+i18n = import('i18n')
+
+i18n.gettext(
+  gt_gettext_domain,
+  preset: 'glib',
+)
diff --git a/src/meson.build b/src/meson.build
index b515e0c5..475caa34 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,120 +1,79 @@
-service_conf = {'libexecdir': gt_prefix / gt_libexecdir}
-
-configure_file(
-  input: gt_iface_name + '.service.in',
-  output: '@BASENAME@',
-  configuration: service_conf,
-  install: true,
-  install_dir: dbus_session_bus_services_dir,
+# Copyright © 2018, 2019 Iñigo Martínez
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
+# Sources
+
+debug_sources = files(
+  'terminal-debug.c',
+  'terminal-debug.h',
 )
 
-configure_file(
-  input: gt_name + '-server.service.in',
-  output: '@BASENAME@',
-  configuration: service_conf,
-  install: true,
-  install_dir: systemd_systemduserunitdir,
+enum_headers = files(
+  'terminal-enums.h'
 )
 
-install_data(
-  gt_iface_name + '.gschema.xml',
-  install_dir: gio_schemasdir,
+enum_sources = gnome.mkenums(
+  'terminal-type-builtins.h',
+  sources: enum_headers,
+  c_template: 'terminal-type-builtins.c.template',
+  h_template: 'terminal-type-builtins.h.template',
+  install_header: false,
 )
 
-enums_header = files('terminal-enums.h')
-
-enums = 'terminal-type-builtins'
-
-enums_sources = gnome.mkenums(
-  enums,
-  sources: enums_header,
-  c_template: enums + '.c.template',
-  h_template: enums + '.h.template',
+gdbus_data = files(
+  'org.gnome.Terminal.xml',
 )
 
 gdbus_sources = gnome.gdbus_codegen(
   'terminal-gdbus-generated',
-  gt_iface_name + '.xml',
+  sources: gdbus_data,
   interface_prefix: gt_iface_name,
   namespace: gt_namespace,
   object_manager: true,
 )
 
-common_deps = [
-  dconf_dep,
-  gio_dep,
-  glib_dep,
-  gtk_dep,
-  uuid_dep,
-  vte_dep,
-]
-
-if gdk_x11_target
-  common_deps += x11_dep
-endif
-
-# gnome-terminal-server
-sources = files(
-  'eggshell.c',
-  'profile-editor.c',
-  'server.c',
-  'terminal-accels.c',
-  'terminal-app.c',
-  'terminal-debug.c',
-  'terminal-encoding.c',
-  'terminal-gdbus.c',
-  'terminal-headerbar.c',
+i18n_sources = files(
+  'terminal-intl.h',
   'terminal-i18n.c',
-  'terminal-icon-button.c',
-  'terminal-info-bar.c',
-  'terminal-mdi-container.c',
-  'terminal-menu-button.c',
-  'terminal-notebook.c',
-  'terminal-prefs.c',
-  'terminal-profiles-list.c',
-  'terminal-screen.c',
-  'terminal-screen-container.c',
-  'terminal-search-popover.c',
-  'terminal-settings-list.c',
-  'terminal-tab-label.c',
-  'terminal-util.c',
-  'terminal-window.c',
+  'terminal-i18n.h',
 )
 
-version_conf = {
-  'TERMINAL_MAJOR_VERSION': gt_major_version,
-  'TERMINAL_MINOR_VERSION': gt_minor_version,
-  'TERMINAL_MICRO_VERSION': gt_micro_version,
-}
-
-sources += configure_file(
-  input: 'terminal-version.h.in',
-  output: '@BASENAME@',
-  configuration: version_conf,
+marshal_sources = gnome.genmarshal(
+  'terminal-marshal',
+  sources: 'terminal-marshal.list',
+  prefix: '_terminal_marshal',
+  internal: true,
 )
 
-marshal = 'terminal-marshal'
-
-sources += gnome.genmarshal(
-  marshal,
-  sources: marshal + '.list',
-  prefix: '_' + marshal.underscorify(),
-  internal: true,
+regex_sources = files(
+  'terminal-regex.c',
+  'terminal-regex.h',
 )
 
 resource_data = files(
   'preferences.ui',
   'search-popover.ui',
-  'terminal.about',
-  'terminal.common.css',
   'terminal-headerbar.ui',
   'terminal-headermenu.ui',
   'terminal-notebook-menu.ui',
   'terminal-window.ui',
+  'terminal.about',
+  'terminal.common.css',
 )
 
-menubar = 'terminal-menubar'
-
 mnemonics_conf = {
   'WITH_MNEMONIC_START': '',
   'WITH_MNEMONIC_END': '',
@@ -123,8 +82,8 @@ mnemonics_conf = {
 }
 
 resource_data += configure_file(
-  input: menubar + '.ui.in',
-  output: menubar + '-with-mnemonics.ui',
+  input: 'terminal-menubar.ui.in',
+  output: 'terminal-menubar-with-mnemonics.ui',
   configuration: mnemonics_conf,
 )
 
@@ -136,129 +95,283 @@ mnemonics_conf = {
 }
 
 resource_data += configure_file(
-  input: menubar + '.ui.in',
-  output: menubar + '-without-mnemonics.ui',
+  input: 'terminal-menubar.ui.in',
+  output: 'terminal-menubar-without-mnemonics.ui',
   configuration: mnemonics_conf,
 )
 
 resource_prefix = 'terminal'
 
-sources += gnome.compile_resources(
-  resource_prefix + '-resources',
-  resource_prefix + '.gresource.xml',
-  c_name: resource_prefix,
+resource_sources = gnome.compile_resources(
+  'terminal-resources',
+  'terminal.gresource.xml',
+  c_name: 'terminal',
   dependencies: resource_data,
   export: true,
 )
 
-deps = common_deps + [
-  gsettings_desktop_schemas_dep,
-  libpcre_dep,
-  m_dep,
-  threads_dep,
-]
+settings_sources = files(
+  'terminal-profiles-list.c',
+  'terminal-profiles-list.h',
+  'terminal-schemas.h',
+  'terminal-settings-list.c',
+  'terminal-settings-list.h',
+)
 
-c_flags = [
-  '-DTERMINAL_COMPILATION',
-  '-DVTE_DISABLE_DEPRECATION_WARNINGS',
-  '-DTERM_LOCALEDIR="@0@"'.format(gt_prefix / gt_localedir),
+version_conf = {
+  'TERMINAL_MAJOR_VERSION': gt_major_version,
+  'TERMINAL_MINOR_VERSION': gt_minor_version,
+  'TERMINAL_MICRO_VERSION': gt_micro_version,
+}
+
+version_sources = [
+  configure_file(
+    input: 'terminal-version.h.in',
+    output: '@BASENAME@',
+    configuration: version_conf,
+  )
 ]
 
-# GNOME Shell search provider
-if enable_search_provider
-  sources += files('terminal-search-provider.c')
+# Server
 
-  sources += gnome.gdbus_codegen(
+server_sources = debug_sources + enum_sources + gdbus_sources + i18n_sources + marshal_sources + 
settings_sources + regex_sources + resource_sources + version_sources + files(
+  'eggshell.c',
+  'eggshell.h',
+  'profile-editor.c',
+  'profile-editor.h',
+  'server.c',
+  'terminal-accels.c',
+  'terminal-accels.h',
+  'terminal-app.c',
+  'terminal-app.h',
+  'terminal-defines.h',
+  'terminal-enums.h',
+  'terminal-encoding.c',
+  'terminal-encoding.h',
+  'terminal-gdbus.c',
+  'terminal-gdbus.h',
+  'terminal-headerbar.c',
+  'terminal-headerbar.h',
+  'terminal-icon-button.h',
+  'terminal-icon-button.c',
+  'terminal-info-bar.c',
+  'terminal-info-bar.h',
+  'terminal-libgsystem.h',
+  'terminal-mdi-container.c',
+  'terminal-mdi-container.h',
+  'terminal-menu-button.h',
+  'terminal-menu-button.c',
+  'terminal-notebook.c',
+  'terminal-notebook.h',
+  'terminal-pcre2.h',
+  'terminal-prefs.c',
+  'terminal-prefs.h',
+  'terminal-screen.c',
+  'terminal-screen.h',
+  'terminal-screen-container.c',
+  'terminal-screen-container.h',
+  'terminal-search-popover.c',
+  'terminal-search-popover.h',
+  'terminal-tab-label.c',
+  'terminal-tab-label.h',
+  'terminal-util.c',
+  'terminal-util.h',
+  'terminal-window.c',
+  'terminal-window.h',
+)
+
+if get_option('search_provider')
+  server_sources += files(
+    'terminal-search-provider.c',
+    'terminal-search-provider.h',
+  )
+
+  search_provider_gdbus_data = [
+    dbus_interfacedir / 'org.gnome.ShellSearchProvider2.xml',
+  ]
+
+  server_sources += gnome.gdbus_codegen(
     'terminal-search-provider-gdbus-generated',
-    shell_search_provider_iface,
+    sources: search_provider_gdbus_data,
     interface_prefix: 'org.gnome.Shell',
     namespace: gt_namespace,
   )
-
-  install_data(
-    gt_name + '-search-provider.ini',
-    install_dir: gt_datadir / 'gnome-shell/search-providers',
-  )
 endif
 
-executable(
+server_cflags = [
+  '-DTERMINAL_COMPILATION',
+  '-DTERM_LOCALEDIR="@0@"'.format(gt_prefix / gt_localedir),
+  '-DVTE_DISABLE_DEPRECATION_WARNINGS',
+]
+
+server_common_deps = [
+  dconf_dep,
+  gio_dep,
+  glib_dep,
+  gsettings_dep,
+  libm_dep,
+  pcre2_dep,
+  pthreads_dep,
+  uuid_dep,
+]
+
+server_gtk3_deps = server_common_deps + [
+  gtk3_dep,
+  vte_gtk3_dep,
+  x11_dep,
+]
+
+server_gtk3 = executable(
   gt_name + '-server',
-  sources + [enums_sources, gdbus_sources],
+  sources: server_sources,
   include_directories: top_inc,
-  dependencies: deps,
-  c_args: c_flags,
+  dependencies: server_gtk3_deps,
+  c_args: server_cflags,
   install: true,
   install_dir: gt_libexecdir,
 )
 
-# Legacy terminal client
-sources = files(
+# Server data files
+
+service_conf = {
+  'libexecdir': gt_prefix / gt_libexecdir
+}
+
+configure_file(
+  input: 'org.gnome.Terminal.service.in',
+  output: '@BASENAME@',
+  configuration: service_conf,
+  install: true,
+  install_dir: dbus_servicedir,
+)
+
+configure_file(
+  input: 'gnome-terminal-server.service.in',
+  output: '@BASENAME@',
+  configuration: service_conf,
+  install: true,
+  install_dir: systemd_userunitdir,
+)
+
+install_data(
+  'org.gnome.Terminal.gschema.xml',
+  install_dir: gio_schemadir,
+)
+
+meson.add_install_script(
+  'meson_compileschemas.py',
+  gio_schemadir,
+)
+
+if get_option('search_provider')
+  install_data(
+    'gnome-terminal-search-provider.ini',
+    install_dir: gs_searchproviderdir,
+  )
+endif
+
+# Client
+
+client_sources = debug_sources + enum_sources + gdbus_sources + i18n_sources + settings_sources + 
version_sources + files(
   'terminal.c',
   'terminal-client-utils.c',
-  'terminal-debug.c',
-  'terminal-i18n.c',
+  'terminal-client-utils.h',
+  'terminal-defines.h',
+  'terminal-libgsystem.h',
   'terminal-options.c',
-  'terminal-profiles-list.c',
-  'terminal-settings-list.c',
+  'terminal-options.h',
 )
 
-c_flags = [
-  '-DTERMINAL_COMPILATION',
+client_cflags = [
   '-DTERMINAL_CLIENT',
-  '-DTERM_DATADIR="@0@"'.format(gt_prefix / gt_datadir),
+  '-DTERMINAL_COMPILATION',
   '-DTERM_LOCALEDIR="@0@"'.format(gt_prefix / gt_localedir),
-  '-DTERM_PKGDATADIR="@0@"'.format(gt_prefix / gt_pkgdatadir),
 ]
 
-executable(
-  gt_name,
-  sources + [enums_sources, gdbus_sources],
+client_deps = [
+  dconf_dep,
+  gio_dep,
+  glib_dep,
+  uuid_dep,
+]
+
+client_deps += [
+  gtk3_dep,
+  vte_gtk3_dep,
+  x11_dep,
+]
+
+client = executable(
+  'gnome-terminal',
+  client_sources,
   include_directories: top_inc,
-  dependencies: common_deps,
-  c_args: c_flags,
+  dependencies: client_deps,
+  c_args: client_cflags,
   install: true,
 )
 
 # Nautilus extension
-if enable_nautilus_extension
-  sources = files(
+
+if get_option('nautilus_extension') and get_option('gtk3')
+  nautilus_sources = enum_sources + gdbus_sources + i18n_sources + files(
     'terminal-client-utils.c',
-    'terminal-i18n.c',
+    'terminal-client-utils.h',
+    'terminal-defines.h',
+    'terminal-libgsystem.h',
     'terminal-nautilus.c',
   )
 
-  deps = [
+  nautilus_cflags = [
+    '-DTERM_LOCALEDIR="@0@"'.format(gt_prefix / gt_localedir),
+  ]
+
+  nautilus_deps = [
     gio_dep,
     glib_dep,
-    gtk_dep,
-    libnautilus_extension_dep,
+    gtk3_dep,
+    nautilus_dep,
   ]
 
-  symbol_map = meson.current_source_dir() / 'nautilus.map'
-  ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
+  nautilus_symbols_map = meson.current_source_dir() / 'nautilus.map'
+  nautilus_ldflags = [
+    cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(nautilus_symbols_map)),
+  ]
 
-  shared_module(
+  nautilus_module = shared_module(
     'terminal-nautilus',
-    sources: sources + [enums_sources, gdbus_sources],
+    sources: nautilus_sources,
     include_directories: top_inc,
-    dependencies: deps,
-    c_args: '-DTERM_LOCALEDIR="@0@"'.format(gt_prefix / gt_localedir),
-    link_args: ldflags,
-    link_depends: symbol_map,
+    dependencies: nautilus_deps,
+    c_args: nautilus_cflags,
+    link_args: nautilus_ldflags,
+    link_depends: nautilus_symbols_map,
     install: true,
-    install_dir: libnautilus_extension_extensiondir,
+    install_dir: nautilus_extensiondir,
   )
 endif
 
-# Checks
-test_unit = 'terminal-regex'
+# Unit tests
 
-exe = executable(
-  test_unit,
-  test_unit + '.c',
+test_regex = executable(
+  'test-regex',
+  sources: regex_sources,
   include_directories: top_inc,
-  c_args: '-DTERMINAL_REGEX_MAIN',
-  dependencies: glib_dep,
+  c_args: ['-DTERMINAL_REGEX_MAIN',],
+  dependencies: [glib_dep, pcre2_dep],
 )
 
-test(test_unit, exe)
+test_env = [
+  'GNOME_TERMINAL_DEBUG=0'
+]
+
+test_units = [
+  ['regex', test_regex],
+]
+
+foreach test: test_units
+  test(
+    test[0],
+    test[1],
+    env: test_env,
+  )
+endforeach
diff --git a/src/meson_compileschemas.py b/src/meson_compileschemas.py
new file mode 100755
index 00000000..3268ddc0
--- /dev/null
+++ b/src/meson_compileschemas.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+# Copyright © 2019 Christian Persch
+#
+# This programme is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This programme is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this programme.  If not, see <https://www.gnu.org/licenses/>.
+
+import os
+import subprocess
+import sys
+
+if os.environ.get('DESTDIR'):
+    sys.exit(0)
+
+prefix = os.environ['MESON_INSTALL_PREFIX']
+schemasdir = os.path.join(prefix, sys.argv[1])
+
+rv = subprocess.call(['glib-compile-schemas', schemasdir])
+sys.exit(rv)
diff --git a/src/terminal-app.c b/src/terminal-app.c
index ab1c81a6..832c3325 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -231,7 +231,9 @@ strv_contains_gnome (char **strv)
  * terminal_app_should_use_headerbar:
  *
  * Determines if the app should use headerbars. This is determined
- * * If the pref is set, the pref value is used
+ * * If GNOME_TERMINAL_HEADERBAR env var is set, the app uses headerbars iff
+ *   the value is 1
+ * * Otherwise, if the pref is set, the pref value is used
  * * Otherwise, if XDG_CURRENT_DESKTOP contains GNOME or GNOME-Classic,
  *   headerbar is used
  * * Otherwise, headerbar is not used.
@@ -239,6 +241,10 @@ strv_contains_gnome (char **strv)
 static gboolean
 terminal_app_should_use_headerbar (TerminalApp *app)
 {
+  const char *env = g_getenv("GNOME_TERMINAL_HEADERBAR");
+  if (env != NULL)
+    return g_strcmp0 (env, "1") == 0;
+
   gboolean set, use;
   g_settings_get (app->global_settings, TERMINAL_SETTING_HEADERBAR_KEY, "mb", &set, &use);
   if (set)



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