[NetworkManager-openvpn/wip/ernestask/meson: 7/7] Add Meson support




commit 928647dc3981dda4293ea73963221115925ae56a
Author: Ernestas Kulik <ernestas@baltic.engineering>
Date:   Sun Jul 31 14:24:26 2022 +0300

    Add Meson support

 appdata/meson.build     |   7 +++
 auth-dialog/meson.build |  13 ++++++
 config.h.meson          |  26 +++++++++++
 meson.build             | 121 ++++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt       |   2 +
 po/meson.build          |   1 +
 properties/meson.build  |  85 ++++++++++++++++++++++++++++++++++
 shared/meson.build      |  22 +++++++++
 src/meson.build         |  20 ++++++++
 9 files changed, 297 insertions(+)
---
diff --git a/appdata/meson.build b/appdata/meson.build
new file mode 100644
index 0000000..386a0f2
--- /dev/null
+++ b/appdata/meson.build
@@ -0,0 +1,7 @@
+i18n.merge_file(
+  input: 'network-manager-openvpn.metainfo.xml.in',
+  install: true,
+  output: 'network-manager-openvpn.metainfo.xml',
+  install_dir: get_option('datadir') / 'metainfo',
+  po_dir: meson.project_source_root() / 'po',
+)
diff --git a/auth-dialog/meson.build b/auth-dialog/meson.build
new file mode 100644
index 0000000..c36ec1b
--- /dev/null
+++ b/auth-dialog/meson.build
@@ -0,0 +1,13 @@
+executable('nm-openvpn-auth-dialog', 'main.c',
+  dependencies: [
+    gtk3,
+    libnma,
+    utils_dep,
+    secret,
+  ],
+  install: true,
+  install_dir: get_option('libexecdir'),
+  link_args: [
+    '-Wl,--version-script,@0@'.format(meson.project_source_root() / 'linker-script-binary.ver'),
+  ],
+)
diff --git a/config.h.meson b/config.h.meson
new file mode 100644
index 0000000..856728a
--- /dev/null
+++ b/config.h.meson
@@ -0,0 +1,26 @@
+/* gettext package name */
+#mesondefine GETTEXT_PACKAGE
+
+/* libexecdir location, service and helper installation directory */
+#mesondefine LIBEXECDIR
+
+/* gettext message catalog location */
+#mesondefine LOCALEDIR
+
+/* gettext message catalog location (same, but used only by the service) */
+#mesondefine NM_OPENVPN_LOCALEDIR
+
+/* Runtime directory, also parent directory for OpenVPN chroot */
+#mesondefine LOCALSTATEDIR
+
+/* Project version */
+#mesondefine VERSION
+
+#mesondefine GDK_VERSION_MIN_REQUIRED
+#mesondefine GDK_VERSION_MAX_ALLOWED
+
+#mesondefine GLIB_VERSION_MIN_REQUIRED
+#mesondefine GLIB_VERSION_MAX_ALLOWED
+
+#mesondefine NM_VERSION_MIN_REQUIRED
+#mesondefine NM_VERSION_MAX_ALLOWED
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..b2215d0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,121 @@
+project('NetworkManager-openvpn', 'c',
+  license: 'GPL-2.0-or-later',
+  meson_version: '>=0.58.0',
+  version: '1.8.19',
+)
+
+project_args = [
+  # Needed for dladdr() and ppoll()
+  '-D_GNU_SOURCE',
+]
+
+add_project_arguments(project_args,
+  language: 'c',
+)
+
+# Imports
+if get_option('gnome')
+  gnome = import('gnome')
+else
+  gnome = disabler()
+endif
+i18n = import('i18n')
+
+# config.h
+conf = configuration_data()
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+if get_option('gtk4')
+  conf.set('GDK_VERSION_MIN_REQUIRED', 'GDK_VERSION_4_0')
+  conf.set('GDK_VERSION_MAX_ALLOWED', 'GDK_VERSION_4_0')
+elif get_option('gnome')
+  conf.set('GDK_VERSION_MIN_REQUIRED', 'GDK_VERSION_3_4')
+  conf.set('GDK_VERSION_MAX_ALLOWED', 'GDK_VERSION_3_4')
+endif
+conf.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_34')
+conf.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_34')
+conf.set_quoted('LIBEXECDIR', get_option('libexecdir'))
+conf.set_quoted('LOCALEDIR', get_option('localedir'))
+conf.set_quoted('LOCALSTATEDIR', get_option('localstatedir'))
+conf.set_quoted('NM_OPENVPN_LOCALEDIR', get_option('localedir'))
+conf.set('NM_VERSION_MIN_REQUIRED', 'NM_VERSION_1_8')
+conf.set('NM_VERSION_MAX_ALLOWED', 'NM_VERSION_1_8')
+conf.set_quoted('VERSION', meson.project_version())
+configure_file(
+  input: 'config.h.meson',
+  output: '@BASENAME@',
+  configuration: conf,
+)
+
+# Dependencies
+gtk4_builder_tool = find_program('gtk4-builder-tool',
+  required: get_option('gtk4'),
+)
+
+glib = dependency('glib-2.0',
+  version: '>=2.34',
+)
+gmodule = dependency('gmodule-2.0',
+  version: '>=2.34'
+)
+
+if get_option('gnome')
+  gtk3 = dependency('gtk+-3.0',
+    version: '>=3.4',
+  )
+  libnma = dependency('libnma',
+    version: '>=1.8.0',
+  )
+else
+  gtk3 = disabler()
+  libnma = disabler()
+endif
+
+if get_option('gtk4')
+  gtk4 = dependency('gtk4',
+    version: '>=4.0',
+  )
+  libnma_gtk4 = dependency('libnma-gtk4',
+    version: '>=1.8.33',
+  )
+else
+  gtk4 = disabler()
+  libnma_gtk4 = disabler()
+endif
+
+libnm = dependency('libnm',
+  version: '>=1.7.0',
+)
+
+if get_option('gnome') or get_option('gtk4')
+  secret = dependency('libsecret-1',
+    version: '>=0.18',
+  )
+else
+  secret = disabler()
+endif
+
+subdir('po')
+subdir('appdata')
+subdir('shared')
+subdir('auth-dialog')
+subdir('properties')
+subdir('src')
+
+install_data('nm-openvpn-service.conf',
+  install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
+)
+
+name_conf = configuration_data()
+name_conf.set('LIBEXECDIR', get_option('libexecdir'))
+name_conf.set('PLUGINDIR', get_option('libdir') / 'NetworkManager')
+configure_file(
+  configuration: name_conf,
+  input: 'nm-openvpn-service.name.in',
+  install: true,
+  install_dir: libnm.get_variable('vpnservicedir',
+    pkgconfig_define: [
+      'prefix', get_option('prefix'),
+    ],
+  ),
+  output: 'nm-openvpn-service.name',
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..c7c2578
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('gnome', type: 'boolean', value: true, description: 'Build NetworkManager-openvpn with GNOME support')
+option('gtk4', type: 'boolean', value: false, description: 'Build NetworkManager-openvpn with libnma-gtk4 
support')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..e9b77d7
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(meson.project_name(), preset: 'glib')
diff --git a/properties/meson.build b/properties/meson.build
new file mode 100644
index 0000000..ec3a237
--- /dev/null
+++ b/properties/meson.build
@@ -0,0 +1,85 @@
+plugin_sources = files(
+  'nm-openvpn-editor-plugin.c',
+  'nm-openvpn-editor-plugin.h',
+  'import-export.c',
+  'import-export.h',
+)
+
+library('nm-vpn-plugin-openvpn', plugin_sources,
+  c_args: [
+    # dladdr()
+    '-D_GNU_SOURCE',
+    '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_BASE',
+  ],
+  dependencies: [
+    gmodule,
+    plugin_utils_dep,
+  ],
+  install: true,
+  install_dir: get_option('libdir') / 'NetworkManager',
+  link_args: [
+    '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libnm-vpn-plugin-openvpn.ver'),
+  ],
+)
+
+editor_sources = files(
+  'nm-openvpn-editor.c',
+  'nm-openvpn-editor.h',
+)
+editor_sources_gtk3 = [
+  editor_sources,
+  gnome.compile_resources('resources', 'gresource.xml',
+    source_dir: '.',
+  ),
+]
+
+library('nm-vpn-plugin-openvpn-editor', editor_sources_gtk3,
+  c_args: [
+    '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR',
+  ],
+  dependencies: [
+    gtk3,
+    libnma,
+    utils_dep,
+  ],
+  install: true,
+  install_dir: get_option('libdir') / 'NetworkManager',
+  link_args: [
+    '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libnm-vpn-plugin-openvpn-editor.ver'),
+  ],
+)
+
+editor_sources_gtk4 = [
+  editor_sources,
+  gnome.compile_resources('resources-gtk4', 'gresource.xml',
+    dependencies: [
+      configure_file(
+        capture: true,
+        command: ['grep', '-v', 'can-default', '@INPUT@'],
+        input: configure_file(
+          capture: true,
+          command: [gtk4_builder_tool, 'simplify', '--3to4', '@INPUT@'],
+          input: 'nm-openvpn-dialog.ui',
+          output: 'nm-openvpn-dialog.3to4.ui',
+        ),
+        output: 'nm-openvpn-dialog.ui',
+      )
+    ],
+    source_dir: meson.current_build_dir(),
+  ),
+]
+library('nm-gtk4-vpn-plugin-openvpn-editor', editor_sources_gtk4,
+  c_args: [
+    '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR',
+  ],
+  dependencies: [
+    gtk4,
+    libnma_gtk4,
+    utils_dep,
+  ],
+  install: true,
+  install_dir: get_option('libdir') / 'NetworkManager',
+  link_args: [
+    '-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libnm-vpn-plugin-openvpn-editor.ver'),
+  ],
+)
diff --git a/shared/meson.build b/shared/meson.build
new file mode 100644
index 0000000..656cf4e
--- /dev/null
+++ b/shared/meson.build
@@ -0,0 +1,22 @@
+shared_inc = include_directories('.', '..')
+utils_dep = declare_dependency(
+  dependencies: [
+    glib,
+    libnm,
+  ],
+  include_directories: shared_inc,
+  sources: files(
+    'nm-utils/nm-shared-utils.c',
+    'utils.c',
+  ),
+)
+plugin_utils_dep = declare_dependency(
+  dependencies: [
+    utils_dep,
+  ],
+  sources: files(
+    'nm-utils/nm-vpn-plugin-utils.c',
+    'nm-utils/nm-vpn-plugin-utils.h',
+    'nm-utils/nm-vpn-plugin-macros.h',
+  ),
+)
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..9147994
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,20 @@
+executable('nm-openvpn-service', 'nm-openvpn-service.c',
+  dependencies: [
+    utils_dep,
+  ],
+  install: true,
+  install_dir: get_option('libexecdir'),
+  link_args: [
+    '-Wl,--version-script,@0@'.format(meson.project_source_root() / 'linker-script-binary.ver'),
+  ],
+)
+executable('nm-openvpn-service-openvpn-helper', 'nm-openvpn-service-openvpn-helper.c',
+  dependencies: [
+    utils_dep,
+  ],
+  install: true,
+  install_dir: get_option('libexecdir'),
+  link_args: [
+    '-Wl,--version-script,@0@'.format(meson.project_source_root() / 'linker-script-binary.ver'),
+  ],
+)


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