[zenity/meson: 3/3] Port build system from autotools to meson.




commit ae51b769019ea5e4c32ec6e386f3d2183562c1cb
Author: Logan Rathbone <poprocks gmail com>
Date:   Tue Jun 8 22:55:49 2021 -0400

    Port build system from autotools to meson.

 Makefile.am           |  32 ------------
 autogen.sh            |  38 --------------
 configure.ac          | 140 --------------------------------------------------
 data/Makefile.am      |  23 ---------
 data/meson.build      |  22 ++++++++
 help/LINGUAS          |   1 +
 help/Makefile.am      |  45 ----------------
 help/meson.build      |  48 +++++++++++++++++
 meson.build           | 109 +++++++++++++++++++++++++++++++++++++++
 meson_options.txt     |   5 ++
 meson_post_install.py |  15 ++++++
 po/Makevars           |  78 ----------------------------
 po/POTFILES.skip      |   2 -
 po/meson.build        |   4 ++
 src/Makefile.am       |  57 --------------------
 src/main.c            |   2 +-
 src/meson.build       |  51 ++++++++++++++++++
 src/zenity.h          |  10 ----
 18 files changed, 256 insertions(+), 426 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..373efcf
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,22 @@
+install_man('zenity.1')
+
+install_data(
+  ['zenity.png', 
+    'zenity-calendar.png',
+    'zenity-list.png',
+    'zenity-file.png',
+    'zenity-progress.png',
+    'zenity-text.png',
+    'zenity-scale.png',
+    'zenity-entry.png',
+    'zenity-notification.png']
+  )
+
+install_data(
+  ['monk.png',
+    'gnome-tshirt.png',
+    'sunglasses.png',
+    'surfboard.png',
+    'hawaii-shirt.png'],
+  install_dir: join_paths(zenity_datadir, 'clothes')
+  )
diff --git a/help/LINGUAS b/help/LINGUAS
new file mode 100644
index 0000000..9940fa3
--- /dev/null
+++ b/help/LINGUAS
@@ -0,0 +1 @@
+bg ca cs da de el en_GB es eu fi fr gl hu ja oc pl pt_BR ru sl sv uk zh_CN
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..cd09412
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,48 @@
+help_pages = [
+  'legal.xml',
+  'calendar.page',
+  'color-selection.page',
+  'entry.page',
+  'error.page',
+  'file-selection.page',
+  'forms.page',
+  'index.page',
+  'info.page',
+  'intro.page',
+  'list.page',
+  'message.page',
+  'notification.page',
+  'password.page',
+  'progress.page',
+  'question.page',
+  'scale.page',
+  'text.page',
+  'usage.page',
+  'warning.page'
+]
+
+help_media = [
+  'figures/zenity-calendar-screenshot.png',
+  'figures/zenity-colorselection-screenshot.png',
+  'figures/zenity-entry-screenshot.png',
+  'figures/zenity-error-screenshot.png',
+  'figures/zenity-fileselection-screenshot.png',
+  'figures/zenity-forms-screenshot.png',
+  'figures/zenity-information-screenshot.png',
+  'figures/zenity-list-screenshot.png',
+  'figures/zenity-notification-listen-screenshot.png',
+  'figures/zenity-notification-screenshot.png',
+  'figures/zenity-password-screenshot.png',
+  'figures/zenity-progress-screenshot.png',
+  'figures/zenity-question-screenshot.png',
+  'figures/zenity-scale-screenshot.png',
+  'figures/zenity-text-screenshot.png',
+  'figures/zenity-warning-screenshot.png'
+]
+
+gnome.yelp(
+  meson.project_name(),
+  sources: help_pages,
+  media: help_media,
+  symlink_media: false
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..f65475a
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,109 @@
+project('zenity', 'c',
+  version: '3.34.0',
+  meson_version: '>=0.53.0',
+  license: 'LGPL-2.1-or-later'
+)
+
+version_arr = meson.project_version().split('.')
+zenity_version_major = version_arr[0].to_int()
+zenity_version_minor = version_arr[1]
+zenity_version_micro = version_arr[2].to_int()
+
+zenity_prefix = get_option('prefix')
+zenity_bindir = join_paths(zenity_prefix, get_option('bindir'))
+zenity_libdir = join_paths(zenity_prefix, get_option('libdir'))
+zenity_datadir = join_paths(zenity_prefix, get_option('datadir'), 'zenity')
+zenity_localedir = join_paths(zenity_prefix, get_option('localedir'))
+
+zenity_root_dir = include_directories('.')
+zenity_po_dir = join_paths(meson.source_root(), 'po')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+cc = meson.get_compiler('c')
+
+zenity_conf = configuration_data()
+zenity_conf.set_quoted('ZENITY_NAME', meson.project_name())
+zenity_conf.set_quoted('ZENITY_VERSION', meson.project_version())
+zenity_conf.set_quoted('ZENITY_STRING',
+  '@0@ @1@'.format(meson.project_name(), meson.project_version()))
+zenity_conf.set_quoted('ZENITY_DATADIR', zenity_datadir)
+zenity_conf.set_quoted('ZENITY_LIBDIR', zenity_libdir)
+zenity_conf.set_quoted('ZENITY_LOCALE_DIR', zenity_localedir)
+
+zenity_conf.set('VERSION', 'ZENITY_VERSION')
+zenity_conf.set('GETTEXT_PACKAGE', 'ZENITY_NAME')
+zenity_conf.set('LOCALEDIR', 'ZENITY_LOCALE_DIR')
+
+zenity_conf.set('DEBUG', get_option('debug'))
+
+check_headers = [
+  'sys/types.h',
+  'unistd.h',
+  'langinfo.h',
+  'locale.h'
+]
+
+foreach h : check_headers
+  cc.has_header(h, required: true)
+endforeach
+
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.0.0')
+
+# Optional dependencies
+
+opt_missing_str = '''
+Requested optional @0@ support but library not found.
+Please ensure you have any required development libraries installed.'''
+
+libnotify = dependency('libnotify', version: '>= 0.6.1', required: false)
+if get_option('libnotify')
+  if libnotify.found()
+    zenity_conf.set('HAVE_LIBNOTIFY', true)
+  else
+    error(opt_missing_str.format('libnotify'))
+  endif
+endif
+
+webkitgtk = dependency('webkit2gtk-4.0', version: '>= 2.8.1', required: false)
+if get_option('webkitgtk')
+  if webkitgtk.found()
+    zenity_conf.set('HAVE_WEBKITGTK', true)
+  else
+    error(opt_missing_str.format('webkitgtk'))
+  endif
+endif
+
+# link Xlib if we have it. This will likely be removed after gtk4 migration.
+x11 = dependency('x11', required: false)
+
+perl = find_program('perl', required: false)
+if perl.found()
+  zenity_conf.set('PERL', perl.path())
+endif
+
+configure_file(
+  output: 'config.h',
+  configuration: zenity_conf
+)
+
+# Print a summary of options at the end.
+
+summary({'prefix': zenity_prefix,
+         'libdir': zenity_libdir,
+         'datadir': zenity_datadir,
+        'localedir': zenity_localedir,
+        }, section: 'Directories')
+
+summary({'libnotify': get_option('libnotify'),
+         'webkitgtk': get_option('webkitgtk'),
+         'gdialog script': perl.found(),
+        }, section: 'Configuration')
+
+subdir('src')
+subdir('data')
+subdir('po')
+subdir('help')
+
+meson.add_install_script('meson_post_install.py')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..b0554fc
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('libnotify', type : 'boolean', value : true,
+  description : 'enable libnotify for desktop notification support')
+
+option('webkitgtk', type : 'boolean', value : true,
+  description : 'enable webkitgtk support')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..2654e49
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+
+# Packaging tools define DESTDIR and this isn't needed for them
+if 'DESTDIR' not in os.environ:
+    print('Updating icon cache...')
+    icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
+    if not os.path.exists(icon_cache_dir):
+        os.makedirs(icon_cache_dir)
+    subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..66362aa
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,4 @@
+i18n.gettext(
+  meson.project_name(),
+  preset: 'glib'
+)
diff --git a/src/main.c b/src/main.c
index 7f0c2db..18b2a72 100644
--- a/src/main.c
+++ b/src/main.c
@@ -43,7 +43,7 @@ main (gint argc, gchar **argv) {
        setlocale (LC_ALL, "");
 #endif
 
-       bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+       bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
 
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..748fe31
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,51 @@
+# for i in `ls *.c`; do echo "  '${i}',"; done
+zenity_sources = [
+  'about.c',
+  'calendar.c',
+  'color.c',
+  'entry.c',
+  'fileselection.c',
+  'forms.c',
+  'main.c',
+  'msg.c',
+  'notification.c',
+  'option.c',
+  'password.c',
+  'progress.c',
+  'scale.c',
+  'text.c',
+  'tree.c',
+  'util.c'
+]
+
+zenity_deps = [
+  gtk_dep,
+  libnotify,
+  webkitgtk,
+  x11
+]
+
+zenity_c_args = [
+  '-DG_LOG_DOMAIN="Zenity"'
+]
+
+zenity = executable(
+  meson.project_name(),
+  zenity_sources,
+  include_directories: zenity_root_dir,
+  dependencies: zenity_deps,
+  c_args: zenity_c_args,
+  install: true
+)
+
+if perl.found()
+  configure_file(
+    input: 'gdialog.in',
+    output: 'gdialog',
+    configuration: zenity_conf,
+    install_dir: zenity_bindir,
+    install: true
+  )
+endif
+
+install_data('zenity.ui')
diff --git a/src/zenity.h b/src/zenity.h
index b86a264..404eec7 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -5,7 +5,6 @@
 
 G_BEGIN_DECLS
 
-#ifdef ENABLE_NLS
 #include <libintl.h>
 #define _(String) dgettext (GETTEXT_PACKAGE, String)
 #ifdef gettext_noop
@@ -13,15 +12,6 @@ G_BEGIN_DECLS
 #else
 #define N_(String) (String)
 #endif
-#else /* NLS is disabled */
-#define _(String) (String)
-#define N_(String) (String)
-#define textdomain(String) (String)
-#define gettext(String) (String)
-#define dgettext(Domain, String) (String)
-#define dcgettext(Domain, String, Type) (String)
-#define bindtextdomain(Domain, Directory) (Domain)
-#endif
 
 typedef struct {
        gchar *dialog_title;


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