[eog/wip/inigomartinez/meson: 1/2] build: Port to meson build system



commit 353b3a3ed430295efbf53945b987189e534f171b
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Jun 29 18:05:02 2017 +0200

    build: Port to meson build system

 Makefile.am                |    4 +
 data/Makefile.am           |    3 +-
 data/icons/Makefile.am     |    2 +
 data/icons/meson.build     |   44 ++++++
 data/meson.build           |   66 +++++++++
 doc/reference/Makefile.am  |    3 +-
 doc/reference/eog-docs.xml |   85 +++++++++++
 doc/reference/meson.build  |   76 ++++++++++
 help/Makefile.am           |    2 +
 help/meson.build           |   92 ++++++++++++
 jpegutils/Makefile.am      |    5 +-
 jpegutils/meson.build      |   16 ++
 meson.build                |  344 ++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt          |    8 +
 meson_post_install.py      |   15 ++
 plugins/Makefile.am        |    4 +-
 plugins/meson.build        |   34 +++++
 po/meson.build             |    1 +
 src/Makefile.am            |    3 +-
 src/eog.map                |    6 +
 src/meson.build            |  216 +++++++++++++++++++++++++++
 tests/meson.build          |   44 ++++++
 tests/tests.in             |    3 +
 23 files changed, 1071 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4297d42..9c3420f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,10 @@ EXTRA_DIST =                         \
        ChangeLog-2.6           \
        ChangeLog-2.18          \
        ChangeLog.pre-git       \
+       meson.build             \
+       meson_options.txt       \
+       meson_post_install.py   \
+       po/meson.build          \
        tests
 
 DISTCLEANFILES =
diff --git a/data/Makefile.am b/data/Makefile.am
index b376d31..abe7123 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -47,7 +47,8 @@ EXTRA_DIST =                  \
        popup-menus.ui          \
        $(DESKTOP_IN_FILES)     \
        $(appdata_in_files)     \
-       eog.convert
+       eog.convert             \
+       meson.build
 
 CLEANFILES =                   \
         $(DESKTOP_FILES)        \
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index ed53ee3..2174268 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -1,5 +1,7 @@
 SUBDIRS = 16x16 22x22 24x24 32x32 48x48 256x256 scalable
 
+EXTRA_DIST = meson.build
+
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
 
 install-data-hook: update-icon-cache
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..3e925ef
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,44 @@
+icon_sizes = [
+  '16x16',
+  '22x22',
+  '24x24',
+  '32x32',
+  '256x256'
+]
+
+foreach icon_size: icon_sizes
+  install_subdir(
+    join_paths(icon_size, 'apps'),
+    install_dir: join_paths(eog_datadir, 'icons', 'hicolor', icon_size)
+  )
+endforeach
+
+install_data(
+  'scalable/apps/eog-symbolic.svg',
+  install_dir: join_paths(eog_datadir, 'icons', 'hicolor', 'scalable', 'apps')
+)
+
+icon_sizes = [
+  ['16x16', ['slideshow-play.png', 'eog-plugin.png']],
+  ['22x22', ['slideshow-play.png', 'eog-plugin.png']],
+  ['24x24', ['slideshow-play.png']],
+  ['32x32', ['slideshow-play.png', 'eog-plugin.png']],
+  ['48x48', ['slideshow-play.png']]
+]
+
+foreach icon_size: icon_sizes
+  actions_icons = []
+  foreach file: icon_size[1]
+    actions_icons += files(join_paths(icon_size[0], 'actions', file))
+  endforeach
+
+  install_data(
+    actions_icons,
+    install_dir: join_paths(eog_pkgdatadir, 'icons', 'hicolor', icon_size[0], 'actions')
+  )
+endforeach
+
+install_subdir(
+  'scalable/actions',
+  install_dir: join_paths(eog_pkgdatadir, 'icons', 'hicolor', 'scalable')
+)
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..ab9343a
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,66 @@
+subdir('icons')
+
+resource_data = files(
+  'pixmaps/thumbnail-frame.png',
+  'eog-app-menu.ui',
+  'eog-gear-menu.ui',
+  'eog-image-properties-dialog.ui',
+  'eog-multiple-save-as-dialog.ui',
+  'eog-preferences-dialog.ui',
+  'eog-zoom-entry.ui',
+  'eog.css',
+  'fullscreen-toolbar.ui',
+  'help-overlay.ui',
+  'metadata-sidebar.ui',
+  'popup-menus.ui'
+)
+
+desktop_conf = configuration_data()
+desktop_conf.set('VERSION', eog_version)
+
+desktop = 'eog.desktop'
+
+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(eog_datadir, 'applications')
+)
+
+info = 'eog.metainfo.xml'
+
+i18n.merge_file(
+  info,
+  input: 'eog.appdata.xml.in',
+  output: info,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(eog_datadir, 'metainfo')
+)
+
+schema_conf = configuration_data()
+schema_conf.set('GETTEXT_PACKAGE', meson.project_name())
+
+schema = 'org.gnome.eog.gschema.xml'
+
+configure_file(
+  input: schema + '.in',
+  output: schema,
+  install: true,
+  install_dir: eog_schemadir,
+  configuration: schema_conf
+)
+
+install_data(
+  'eog.convert',
+  install_dir: join_paths(eog_datadir, 'GConf', 'gsettings')
+)
diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index cdf7106..a57783e 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -126,7 +126,8 @@ include $(top_srcdir)/gtk-doc.make
 # Other files to distribute
 # e.g. EXTRA_DIST += version.xml.in
 EXTRA_DIST += version.xml.in \
-             $(DOC_MODULE)-docs.xml.in
+             $(DOC_MODULE)-docs.xml.in \
+             meson.build
 
 # Files not to distribute
 # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
diff --git a/doc/reference/eog-docs.xml b/doc/reference/eog-docs.xml
new file mode 100644
index 0000000..967a5f0
--- /dev/null
+++ b/doc/reference/eog-docs.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY version SYSTEM "version.xml">
+]>
+<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude";>
+  <bookinfo>
+    <title>Eye of GNOME Reference Manual</title>
+    <releaseinfo>
+      for Eye of GNOME &version;
+    </releaseinfo>
+  </bookinfo>
+
+  <reference>
+    <title>API Reference</title>
+    <chapter>
+      <title>User Interface</title>
+      <xi:include href="xml/eog-properties-dialog.xml"/>
+      <xi:include href="xml/eog-list-store.xml"/>
+      <xi:include href="xml/eog-file-chooser.xml"/>
+      <xi:include href="xml/eog-thumb-nav.xml"/>
+      <xi:include href="xml/eog-thumb-view.xml"/>
+      <xi:include href="xml/eog-scroll-view.xml"/>
+      <xi:include href="xml/eog-window.xml"/>
+      <xi:include href="xml/eog-window-activatable.xml"/>
+      <xi:include href="xml/eog-statusbar.xml"/>
+      <xi:include href="xml/eog-sidebar.xml"/>
+      <xi:include href="xml/eog-thumbnail.xml"/>
+      <xi:include href="xml/eog-save-as-dialog-helper.xml"/>
+      <xi:include href="xml/eog-error-message-area.xml"/>
+    </chapter>
+
+    <chapter>
+      <title>Image data and manipulation</title>
+      <xi:include href="xml/eog-image.xml"/>
+      <xi:include href="xml/eog-image-save-info.xml"/>
+      <xi:include href="xml/eog-transform.xml"/>
+      <xi:include href="xml/eog-clipboard-handler.xml"/>
+    </chapter>
+
+    <chapter>
+      <title>Printing</title>
+      <xi:include href="xml/eog-print.xml"/>
+    </chapter>
+
+    <chapter>
+      <title>Application and configuration</title>
+      <xi:include href="xml/eog-application.xml"/>
+      <xi:include href="xml/eog-session.xml"/>
+      <xi:include href="xml/eog-config-keys.xml"/>
+    </chapter>
+
+    <!--<chapter>
+      <title>Plugins</title>
+      <xi:include href="xml/eog-plugin-engine.xml"/>
+    </chapter>-->
+
+    <chapter>
+      <title>Utilities</title>
+      <xi:include href="xml/eog-debug.xml"/>
+      <xi:include href="xml/eog-uri-converter.xml"/>
+      <xi:include href="xml/eog-util.xml"/>
+      <!--
+      <xi:include href="xml/eog-exif-util.xml"/>
+      -->
+      <xi:include href="xml/eog-pixbuf-util.xml"/>
+      <xi:include href="xml/zoom.xml"/>
+    </chapter>
+
+    <chapter>
+      <title>Asynchronous jobs</title>
+      <xi:include href="xml/eog-jobs.xml"/>
+      <xi:include href="xml/eog-job-scheduler.xml"/>
+    </chapter>
+  </reference>
+
+  <part>
+    <title>Appendix</title>
+    <index id="api-index">
+      <title>API Index</title>
+      <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
+    </index>
+    <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
+  </part>
+</book>
diff --git a/doc/reference/meson.build b/doc/reference/meson.build
new file mode 100644
index 0000000..3c32bee
--- /dev/null
+++ b/doc/reference/meson.build
@@ -0,0 +1,76 @@
+private_headers = [
+  'eog-application-service.h',
+  'eog-close-confirmation-dialog.h',
+  'eog-enum-types.h',
+  'eog-image-private.h',
+  'eog-image-jpeg.h',
+  'eog-marshal.h',
+  'eog-metadata-details.h',
+  'eog-metadata-reader.h',
+  'eog-metadata-reader-jpg.h',
+  'eog-metadata-reader-png.h',
+  'eog-metadata-sidebar.h',
+  'eog-module.h',
+  'eog-plugin-engine.h',
+  'eog-preferences-dialog.h',
+  'eog-print-image-setup.h',
+  'eog-print-preview.h'
+]
+
+if not have_exif
+  private_headers += 'eog-exif-util.h'
+endif
+
+version_conf = configuration_data()
+version_conf.set('VERSION', eog_version)
+
+version_xml = 'version.xml'
+
+configure_file(
+  input: version_xml + '.in',
+  output: version_xml,
+  configuration: version_conf
+)
+
+# FIXME: gtkdoc is not able to get a configure_object as main_xml file.
+#        https://github.com/mesonbuild/meson/issues/1875
+#        https://github.com/mesonbuild/meson/issues/550
+'''
+# Build EXIF-related documentation if we really have support for it
+doc_conf = configuration_data()
+if have_exif or have_exempi
+  doc_conf.set('EOG_DOC_EXIF_START', '')
+  doc_conf.set('EOG_DOC_EXIF_STOP', '')
+else
+  doc_conf.set('EOG_DOC_EXIF_START', '<!--')
+  doc_conf.set('EOG_DOC_EXIF_STOP', '-->')
+endif
+
+docs_xml = meson.project_name() + '-docs.xml'
+
+main_xml = configure_file(
+  input: docs_xml + '.in',
+  output: docs_xml,
+  configuration: doc_conf
+)
+'''
+
+doc_path = join_paths(eog_datadir, 'gtk-doc', 'html', meson.project_name())
+
+gnome.gtkdoc(
+  meson.project_name(),
+  main_xml: meson.project_name() + '-docs.xml',
+  src_dir: src_inc,
+  dependencies: libeog_dep,
+  scan_args: [
+    '--rebuild-types',
+    '--ignore-headers=' + ' '.join(private_headers),
+  ],
+  mkdb_args: [
+    '--xml-mode',
+    '--output-format=xml'
+  ],
+  gobject_typesfile: meson.project_name() + '.types',
+  install: true,
+  install_dir: doc_path
+)
diff --git a/help/Makefile.am b/help/Makefile.am
index 5c928e3..dc44fee 100644
--- a/help/Makefile.am
+++ b/help/Makefile.am
@@ -1,3 +1,5 @@
+EXTRA_DIST = meson.build
+
 @YELP_HELP_RULES@
 
 HELP_ID = eog
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..f620815
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,92 @@
+sources = [
+  'bug-filing.page',
+  'commandline.page',
+  'copy-paste.page',
+  'default.page',
+  'desktop-background.page',
+  'develop.page',
+  'documentation.page',
+  'edit.page',
+  'flip-rotate.page',
+  'format-change.page',
+  'formats-save.page',
+  'formats-view.page',
+  'index.page',
+  'introduction.page',
+  'legal.xml',
+  'license.page',
+  'open.page',
+  'plugin-exif-digital.page',
+  'plugin-fullscreen-background.page',
+  'plugin-fullscreen-double-click.page',
+  'plugin-picasa.page',
+  'plugin-python-console.page',
+  'plugin-send-by-mail.page',
+  'plugin-slideshow-shuffle.page',
+  'plugins.page',
+  'plugin-zoom-width.page',
+  'preferences.page',
+  'print.page',
+  'rename-multiple.page',
+  'shortcuts.page',
+  'slideshow.page',
+  'toolbar.page',
+  'translate.page',
+  'view.page',
+  'zoom.page'
+]
+
+media = [
+  'figures/eog-logo.png',
+  'figures/eog-toolbar-editor.png',
+  'figures/eog-trail.png',
+  'figures/image-view-prefs.png',
+  'figures/multiple-convert.png',
+  'figures/multiple-rename-count.png',
+  'figures/plugins-all.png',
+  'figures/plugin-send-by-mail.png',
+  'figures/prefs-plugins-date.png',
+  'figures/prefs-plugins-fullscreen.png',
+  'figures/prefs-plugins.png',
+  'figures/slideshow-prefs.png'
+]
+
+linguas = [
+  'ar',
+  'ca',
+  'cs',
+  'da',
+  'de',
+  'el',
+  'en_GB',
+  'es',
+  'eu',
+  'fi',
+  'fr',
+  'gl',
+  'hu',
+  'it',
+  'ja',
+  'ko',
+  'lv',
+  'oc',
+  'pa',
+  'pt_BR',
+  'ro',
+  'ru',
+  'sl',
+  'sv',
+  'te',
+  'th',
+  'uk',
+  'zh_CN',
+  'zh_TW'
+]
+
+gnome.yelp(
+  meson.project_name(),
+  sources: sources,
+  media: media,
+  symlink_media: true,
+  languages: linguas
+)
diff --git a/jpegutils/Makefile.am b/jpegutils/Makefile.am
index a48fd76..53c0c84 100644
--- a/jpegutils/Makefile.am
+++ b/jpegutils/Makefile.am
@@ -18,6 +18,9 @@ libeog_jpegutils_la_SOURCES +=                \
        transupp-6b.h
 endif
 
-EXTRA_DIST = README.6b README.8a
+EXTRA_DIST = \
+       README.6b       \
+       README.8a       \
+       meson.build
 
 -include $(top_srcdir)/git.mk
diff --git a/jpegutils/meson.build b/jpegutils/meson.build
new file mode 100644
index 0000000..0a3e84a
--- /dev/null
+++ b/jpegutils/meson.build
@@ -0,0 +1,16 @@
+if have_jpeg_80
+  sources = files('transupp-8a.c')
+else
+  sources = files('transupp-6b.c')
+endif
+
+libjpegutils = static_library(
+  'libeog-jpegutils',
+  sources: sources,
+  include_directories: top_inc
+)
+
+jpeg_deps += declare_dependency(
+  link_with: libjpegutils,
+  include_directories: include_directories('.')
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..9afe85b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,344 @@
+project(
+  'eog', 'c',
+  version: '3.25.2',
+  license: 'GPL2',
+  default_options: [
+    'buildtype=debugoptimized',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.42.0'
+)
+
+eog_version = meson.project_version()
+version_array = eog_version.split('.')
+eog_major_version = version_array[0].to_int()
+eog_minor_version = version_array[1].to_int()
+eog_micro_version = version_array[2].to_int()
+
+eog_api_version = '@0@.0'.format(eog_major_version)
+eog_api_name = '@0@-@1@'.format(meson.project_name(), eog_api_version)
+
+eog_gir_ns = 'Eog'
+eog_gir_version = '1.0'
+
+eog_prefix = get_option('prefix')
+eog_bindir = join_paths(eog_prefix, get_option('bindir'))
+eog_datadir = join_paths(eog_prefix, get_option('datadir'))
+eog_includedir = join_paths(eog_prefix, get_option('includedir'))
+eog_libdir = join_paths(eog_prefix, get_option('libdir'))
+eog_libexecdir = join_paths(eog_prefix, get_option('libexecdir'))
+eog_localedir = join_paths(eog_prefix, get_option('localedir'))
+
+eog_pkgdatadir = join_paths(eog_datadir, meson.project_name())
+eog_pkglibdir = join_paths(eog_libdir, meson.project_name())
+eog_pkglibexecdir = join_paths(eog_libexecdir, meson.project_name())
+
+eog_pluginsdir = join_paths(eog_pkglibdir, 'plugins')
+eog_schemadir = join_paths(eog_datadir, 'glib-2.0', 'schemas')
+
+eog_debug = get_option('buildtype').contains('debug')
+
+cc = meson.get_compiler('c')
+
+config_h = configuration_data()
+
+# defines
+set_defines = [
+  # package
+  ['PACKAGE', meson.project_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(), eog_version)],
+  ['PACKAGE_TARNAME', meson.project_name()],
+  ['PACKAGE_URL', 'https://wiki.gnome.org/Apps/EyeOfGnome'],
+  ['PACKAGE_VERSION', eog_version],
+  ['VERSION', eog_version],
+  # i18n
+  ['GETTEXT_PACKAGE', meson.project_name()]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# version values
+config_h.set('EOG_MAJOR_VERSION', eog_major_version)
+config_h.set('EOG_MINOR_VERSION', eog_minor_version)
+config_h.set('EOG_MICRO_VERSION', eog_micro_version)
+
+# debug options
+config_h.set('GNOME_ENABLE_DEBUG', eog_debug,
+             description: 'Define if debugging is enabled')
+config_h.set('NDEBUG', not eog_debug)
+
+
+# Support for nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) (optional)
+langinfo_measurement_src = '''
+  #include <langinfo.h>
+  int main() {
+    char c;
+    c = *((unsigned char *)  nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
+  };
+'''
+config_h.set('HAVE__NL_MEASUREMENT_MEASUREMENT', cc.compiles(langinfo_measurement_src),
+             description: 'Define if _NL_MEASUREMENT_MEASUREMENT is available')
+
+# 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 = [
+  ['HAVE_STRPTIME', 'strptime'],
+  # 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']
+
+compiler_flags = []
+if eog_debug
+  test_cflags = [
+    '-Werror=format=2',
+    '-Werror=implicit-function-declaration',
+    '-Werror=init-self',
+    '-Werror=missing-include-dirs',
+    '-Werror=missing-prototypes',
+    '-Werror=pointer-arith',
+    '-Werror=return-type',
+    '-Wnested-externs',
+    '-Wstrict-prototypes'
+  ]
+
+  foreach cflag: test_cflags
+    if cc.has_argument(cflag)
+      compiler_flags += [cflag]
+    endif
+  endforeach
+endif
+
+add_project_arguments(common_flags + compiler_flags, language: 'c')
+
+glib_req_version = '>= 2.42.0'
+peas_req_version = '>= 0.7.4'
+
+eog_deps = [
+  dependency('gtk+-3.0', version: '>= 3.22.0'),
+  dependency('glib-2.0', version: glib_req_version),
+  dependency('gio-2.0', version: glib_req_version),
+  dependency('gio-unix-2.0', version: glib_req_version),
+  dependency('gnome-desktop-3.0', version: '>= 2.91.2'),
+  dependency('gdk-pixbuf-2.0', version: '>= 2.30.0'),
+  dependency('gtk+-unix-print-3.0', version: '>= 3.5.4'),
+  dependency('shared-mime-info', version: '>= 0.20'),
+  dependency('gsettings-desktop-schemas', version: '>= 2.91.92'),
+  dependency('libpeas-1.0', version: peas_req_version),
+  dependency('libpeas-gtk-1.0', version: peas_req_version)
+]
+
+# ZLIB support (required)
+have_zlib = false
+if cc.has_header('zlib.h')
+  config_h.set('HAVE_ZLIB_H', true)
+  zlib_dep = cc.find_library('z', required: false)
+  if zlib_dep.found() and (cc.has_function('inflate', dependencies: zlib_dep) or cc.has_function('crc32', 
dependencies: zlib_dep))
+    have_zlib = true
+    config_h.set('HAVE_LIBZ', true)
+    eog_deps += zlib_dep
+  endif
+endif
+
+assert(have_zlib, 'No sufficient zlib library found on your system')
+
+# EXIF (optional)
+have_exif = false
+if get_option('enable-libexif')
+  libexif_dep = dependency('libexif', version: '>= 0.6.14', required: false)
+  if libexif_dep.found() and cc.has_header('libexif/exif-data.h', dependencies: libexif_dep)
+    have_exif = true
+    config_h.set('HAVE_EXIF', 1,
+                 description: 'EXIF Support.')
+    eog_deps += libexif_dep
+  endif
+endif
+
+# Little CMS (optional)
+have_lcms = false
+if get_option('enable-cms')
+  libcms_dep = dependency('lcms2', required: false)
+  if libcms_dep.found()
+    have_lcms = true
+    config_h.set('HAVE_LCMS', 1,
+                 description: 'Little CMS Support.')
+    eog_deps += libcms_dep
+  endif
+endif
+
+# Exempi (optional)
+have_exempi = false
+if get_option('enable-xmp')
+  libexempi_dep = dependency('exempi-2.0', version: '>= 1.99.5', required: false)
+  if libexempi_dep.found()
+    have_exempi = true
+    config_h.set('HAVE_EXEMPI', 1,
+                 description: 'XMP Support.')
+    eog_deps += libexempi_dep
+  endif
+endif
+
+# Jpeg (semi-optional)
+jpeg_deps = []
+
+have_jpeg = false
+have_jpeg_80 = false
+
+libjpeg_option = get_option('enable-libjpeg')
+if libjpeg_option
+  libjpeg_dep = dependency('libjpeg', required: false)
+  if libjpeg_dep.found()
+    if cc.has_function('jpeg_destroy_decompress', dependencies: libjpeg_dep) and cc.has_header('jpeglib.h', 
dependencies: libjpeg_dep)
+      have_jpeg = true
+      config_h.set('HAVE_JPEG', 1,
+                   description: 'Jpeg Support.')
+      config_h.set('HAVE_LIBJPEG', true,
+                   description: 'libjpeg is Present.')
+      jpeg_deps += libjpeg_dep
+
+      if cc.has_function('jpeg_simple_progression', dependencies: libjpeg_dep)
+        config_h.set('HAVE_PROGRESSIVE_JPEG', true,
+                     description: 'Jpeg Progressive Saving Support.')
+      else
+        message('JPEG library does not support progressive saving.')
+      endif
+
+      message('Checking libjpeg version is 8 or greater')
+      jpeg_80_check_src = '''
+        #include <stdio.h>
+        #include <jpeglib.h>
+        #if JPEG_LIB_VERSION < 80
+        #error "wrong version"
+        #endif
+      '''
+      have_jpeg_80 = cc.compiles(jpeg_80_check_src, dependencies: libjpeg_dep)
+    else
+      error_msg = '*** JPEG loader will not be built (JPEG header file not found) ***\n'
+    endif
+  else
+    error_msg = '*** JPEG loader will not be built (JPEG library not found) ***\n'
+  endif
+
+  if not have_jpeg
+    error_msg += '*** You can build without it by passing --without-libjpeg to\n'
+    error_msg += '*** configure but some programs using GTK+ may not work properly\n'
+    error(error_msg)
+  endif
+endif
+
+# introspection support
+have_gir = false
+if get_option('enable-introspection')
+  gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.7', required: false)
+  if gir_dep.found()
+    have_gir = true
+    config_h.set('HAVE_INTROSPECTION', true)
+    eog_deps += gir_dep
+  endif
+endif
+
+# RSVG (optional for scaling svg image)
+have_rsvg = false
+if get_option('enable-librsvg')
+  librsvg_dep = dependency('librsvg-2.0', version: '>= 2.36.2', required: false)
+  if librsvg_dep.found()
+    have_rsvg = true
+    config_h.set('HAVE_RSVG', true,
+                 description: 'RSVG Support.')
+    eog_deps += librsvg_dep
+  endif
+endif
+
+# libX11 (required for TotemScrSaver and Color Profiling)
+gdk_dep = dependency('gdk-3.0', required: false)
+
+have_x11 = false
+if have_lcms or (gdk_dep.found() and gdk_dep.get_pkgconfig_variable('targets').contains('x11'))
+  libx11_dep = dependency('x11', required: false)
+  assert(libx11_dep.found(), 'X development libraries (libX11) not found')
+  have_x11 = true
+  eog_deps += libx11_dep
+endif
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+pkg = import('pkgconfig')
+
+data_dir = join_paths(meson.source_root(), 'data')
+po_dir = join_paths(meson.source_root(), 'po')
+
+top_inc = include_directories('.')
+
+subdir('data')
+
+if have_jpeg
+  subdir('jpegutils')
+endif
+
+subdir('src')
+subdir('plugins')
+subdir('help')
+
+if get_option('enable-gtk-doc')
+  subdir('doc/reference')
+endif
+
+subdir('po')
+
+if get_option('enable-installed-tests')
+  subdir('tests')
+endif
+
+meson.add_install_script('meson_post_install.py')
+
+output = 'Configure summary:\n\n'
+output += '  Source code location .......:  ' + meson.source_root() + '\n'
+output += '  Compiler ...................:  ' + cc.get_id() + '\n'
+output += '  Extra Compiler Warnings ....:  ' + ' '.join(compiler_flags) + '\n'
+output += '  EXIF support ...............:  ' + have_exif.to_string() + '\n'
+output += '  XMP support ................:  ' + have_exempi.to_string() + '\n'
+output += '  JPEG support ...............:  ' + have_jpeg.to_string() + '\n'
+output += '  Colour management support ..:  ' + have_lcms.to_string() + '\n'
+output += '  GObject Introspection.......:  ' + have_gir.to_string() + '\n'
+message(output)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..8ffd0b9
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,8 @@
+option('enable-libexif', type: 'boolean', value: true, description: 'enable EXIF support')
+option('enable-cms', type: 'boolean', value: true, description: 'enable colour management support')
+option('enable-xmp', type: 'boolean', value: true, description: 'enable special XMP support')
+option('enable-libjpeg', type: 'boolean', value: true, description: 'enable special JPEG support')
+option('enable-librsvg', type: 'boolean', value: true, description: 'enable RSVG support')
+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)')
+option('enable-installed-tests', type: 'boolean', value: false, description: 'enable installed unit tests')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..bf320a9
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+install_prefix = os.environ['MESON_INSTALL_PREFIX']
+icondir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
+schemadir = os.path.join(install_prefix, 'share', 'glib-2.0', 'schemas')
+
+if not os.environ.get('DESTDIR'):
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 4026dca..ee4434b 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -64,6 +64,8 @@ $(plugins_DATA): %.plugin: %.plugin.desktop.in $(wildcard $(top_srcdir)/po/*po)
 DISTCLEANFILES = $(plugins_DATA)
 CLEANFILES = $(plugins_DATA)
 
-EXTRA_DIST = $(plugins_in_files)
+EXTRA_DIST = \
+       $(plugins_in_files)     \
+       meson.build
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 0000000..c54ca8a
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,34 @@
+msgfmt = find_program('msgfmt')
+
+plugins = [
+  'fullscreen',
+  'reload'
+]
+
+if have_exif
+  plugins += 'statusbar-date'
+endif
+
+foreach plugin: plugins
+  shared_module(
+    plugin,
+    sources: '@0@/eog-@0@-plugin.c'.format(plugin),
+    include_directories: top_inc,
+    dependencies: libeog_dep,
+    install: true,
+    install_dir: eog_pluginsdir
+  )
+
+  plugin_data = plugin + '.plugin'
+
+  # FIXME: Move custom_target to i18n.merge_file when gettext acquires plugin support.
+  #        http://lists.gnu.org/archive/html/bug-gettext/2017-06/msg00001.html
+  custom_target(
+    plugin_data,
+    input: '@0@/@1  desktop in'.format(plugin, plugin_data),
+    output: plugin_data,
+    command: [msgfmt, '--desktop', '--keyword=Name', '--keyword=Description', '--template', '@INPUT@', '-d', 
po_dir, '-o', '@OUTPUT@'],
+    install: true,
+    install_dir: eog_pluginsdir
+  )
+endforeach
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/src/Makefile.am b/src/Makefile.am
index 735dbd4..cca0251 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -204,7 +204,8 @@ EXTRA_DIST =                                \
        eog.gresource.xml               \
        eog-enum-types.h.template       \
        eog-enum-types.c.template       \
-       eog-marshal.list
+       eog-marshal.list                \
+       meson.build
 
 CLEANFILES = $(BUILT_SOURCES)
 
diff --git a/src/eog.map b/src/eog.map
new file mode 100644
index 0000000..a0a804c
--- /dev/null
+++ b/src/eog.map
@@ -0,0 +1,6 @@
+{
+global:
+  eog_*;
+local:
+       *;
+};
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..e43177c
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,216 @@
+src_inc = include_directories('.')
+
+cflags = [
+  '-DEOG_DATA_DIR="@0@"'.format(eog_datadir),
+  '-DEOG_LOCALE_DIR="@0@"'.format(eog_localedir)
+]
+
+enum_headers = files(
+  'eog-scroll-view.h',
+  'eog-window.h'
+)
+
+gnome.mkenums(
+  'org.gnome.eog.enums.xml',
+  sources: enum_headers,
+  comments: '<!-- @comment@ -->',
+  fhead: '<schemalist>',
+  vhead: '  <@type@ id="org.gnome.eog.@EnumName@">',
+  vprod: '    <value nick="@valuenick@" value="@valuenum@"/>',
+  vtail: '  </@type@>',
+  ftail: '</schemalist>',
+  install_header: true,
+  install_dir: eog_schemadir
+)
+
+headers = enum_headers + files(
+  'eog-application.h',
+  'eog-application-activatable.h',
+  'eog-clipboard-handler.h',
+  'eog-debug.h',
+  'eog-enums.h',
+  'eog-file-chooser.h',
+  'eog-image.h',
+  'eog-image-save-info.h',
+  'eog-job-scheduler.h',
+  'eog-jobs.h',
+  'eog-list-store.h',
+  'eog-properties-dialog.h',
+  'eog-sidebar.h',
+  'eog-statusbar.h',
+  'eog-thumbnail.h',
+  'eog-thumb-nav.h',
+  'eog-thumb-view.h',
+  'eog-transform.h',
+  'eog-uri-converter.h',
+  'eog-window-activatable.h'
+)
+
+sources = files(
+  'eog-application.c',
+  'eog-application-activatable.c',
+  'eog-clipboard-handler.c',
+  'eog-close-confirmation-dialog.c',
+  'eog-debug.c',
+  'eog-error-message-area.c',
+  'eog-file-chooser.c',
+  'eog-image.c',
+  'eog-image-jpeg.c',
+  'eog-image-save-info.c',
+  'eog-job-scheduler.c',
+  'eog-jobs.c',
+  'eog-list-store.c',
+  'eog-metadata-sidebar.c',
+  'eog-metadata-reader.c',
+  'eog-metadata-reader-jpg.c',
+  'eog-metadata-reader-png.c',
+  'eog-pixbuf-util.c',
+  'eog-plugin-engine.c',
+  'eog-preferences-dialog.c',
+  'eog-print.c',
+  'eog-print-image-setup.c',
+  'eog-print-preview.c',
+  'eog-properties-dialog.c',
+  'eog-save-as-dialog-helper.c',
+  'eog-scroll-view.c',
+  'eog-session.c',
+  'eog-sidebar.c',
+  'eog-statusbar.c',
+  'eog-thumbnail.c',
+  'eog-thumb-nav.c',
+  'eog-thumb-view.c',
+  'eog-transform.c',
+  'eog-uri-converter.c',
+  'eog-util.c',
+  'eog-window-activatable.c',
+  'eog-window.c',
+  'eog-zoom-entry.c',
+  'zoom.c'
+)
+
+if have_exif
+  headers += files('eog-exif-util.h')
+  sources += files('eog-exif-util.c')
+endif
+
+if have_exif or have_exempi
+  sources += files('eog-metadata-details.c')
+endif
+
+install_headers(
+  headers,
+  subdir: join_paths(eog_api_name, meson.project_name())
+)
+
+sources += gnome.compile_resources(
+  'eog-resources',
+  'eog.gresource.xml',
+  source_dir: data_dir,
+  c_name: '_eog',
+  dependencies: resource_data,
+  export: true
+)
+
+enum = 'eog-enum-types'
+
+sources += gnome.mkenums(
+  enum,
+  sources: headers,
+  c_template: enum + '.c.template',
+  h_template: enum + '.h.template'
+)
+
+marshal = 'eog-marshal'
+
+sources += gnome.genmarshal(
+  marshal,
+  sources: marshal + '.list',
+  prefix: 'eog_marshal',
+  internal: true
+)
+
+deps = eog_deps + jpeg_deps + [cc.find_library('m')]
+
+libeog_cflags = cflags + [
+  '-DEOG_PLUGIN_DIR="@0@"'.format(eog_pluginsdir),
+  '-DEOG_PREFIX="@0@"'.format(eog_prefix),
+  '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name().to_upper()),
+  '-DLIBDIR="@0@"'.format(eog_libdir)
+]
+
+symbol_map = 'eog.map'
+
+ldflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbol_map)
+
+ldflags = []
+
+if host_machine.system().contains('linux') and cc.has_argument(ldflag)
+  ldflags += ldflag
+endif
+
+libeog = shared_library(
+  meson.project_name(),
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: libeog_cflags,
+  link_args: ldflags,
+  link_depends: symbol_map,
+  install: true,
+  install_dir: eog_pkglibdir
+)
+
+libeog_dep = declare_dependency(
+  link_with: libeog,
+  include_directories: src_inc,
+  dependencies: eog_deps
+)
+
+pkg.generate(
+  libraries: libeog,
+  version: eog_version,
+  name: 'Eye of GNOME',
+  description: 'The GNOME Image Viewer',
+  filebase: meson.project_name(),
+  subdirs: eog_api_name,
+  requires: 'gtk+-3.0',
+  variables: [
+    'exec_prefix=${prefix}',
+    'pluginsdir=' + eog_pluginsdir
+  ],
+  install_dir: join_paths(eog_libdir, 'pkgconfig')
+)
+
+eog = executable(
+  meson.project_name(),
+  'main.c',
+  include_directories: top_inc,
+  dependencies: libeog_dep,
+  c_args: cflags,
+  install: true,
+  install_dir: eog_bindir
+)
+
+if have_gir
+  gir_sources = sources + headers
+
+  gir_incs = 'Gtk-3.0'
+
+  gir_extra_args = '--warn-all'
+
+  gir_dir = join_paths(eog_pkgdatadir, 'gir-' + eog_gir_version)
+  typelib_dir = join_paths(eog_pkglibdir, 'girepository-' + eog_gir_version)
+
+  gnome.generate_gir(
+    eog,
+    sources: gir_sources,
+    nsversion: eog_api_version,
+    namespace: eog_gir_ns,
+    includes: gir_incs,
+    dependencies: libeog_dep,
+    install: true,
+    install_dir_gir: gir_dir,
+    install_dir_typelib: typelib_dir,
+    extra_args: gir_extra_args
+  )
+endif
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..ba4f51e
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,44 @@
+tests_exec_dir = join_paths(eog_pkglibexecdir, 'installed-tests')
+
+tests_files = files(
+  'actions.feature',
+  'common_steps.py',
+  'environment.py',
+  'gnome-logo.png',
+  'screenshot_tour.feature'
+)
+
+install_data(
+  tests_files,
+  install_dir: tests_exec_dir
+)
+
+install_subdir(
+  'steps',
+  install_dir: tests_exec_dir
+)
+
+tests = [
+  'about',
+  'undo',
+  'sidepane',
+  'fullscreen',
+  'wallpaper',
+  'screenshot_tour1',
+  'screenshot_tour2'
+]
+
+foreach test: tests
+  tests_conf = configuration_data()
+  tests_conf.set('TESTS_PATH', tests_exec_dir)
+  tests_conf.set('TEST_NAME', test)
+  tests_conf.set('TEST_TYPE', 'session-exclusive')
+
+  configure_file(
+    input: 'tests.in',
+    output: test + '.test',
+    install: true,
+    install_dir: join_paths(eog_datadir, 'installed-tests', meson.project_name()),
+    configuration: tests_conf
+  )
+endforeach
diff --git a/tests/tests.in b/tests/tests.in
new file mode 100644
index 0000000..4481757
--- /dev/null
+++ b/tests/tests.in
@@ -0,0 +1,3 @@
+[Test]
+Exec=behave @TESTS_PATH@ -t @TEST_NAME@ -k -f html -o @TEST_NAME@.html -f plain
+Type=@TEST_TYPE@


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