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



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

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

 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  |   73 +++++++++++
 help/LINGUAS               |   31 +++++
 help/Makefile.am           |    2 +
 help/meson.build           |   57 +++++++++
 jpegutils/Makefile.am      |    5 +-
 jpegutils/meson.build      |   16 +++
 meson.build                |  297 ++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt          |    8 ++
 meson_post_install.py      |   14 ++
 plugins/Makefile.am        |    4 +-
 plugins/meson.build        |   34 +++++
 po/meson.build             |    1 +
 src/Makefile.am            |    3 +-
 src/meson.build            |  208 +++++++++++++++++++++++++++++++
 src/symbol.map             |    6 +
 tests/meson.build          |   44 +++++++
 tests/template.test.in     |    3 +
 24 files changed, 1008 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 04ad19e..062335c 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..4f25e29
--- /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')
+)
+
+appdata = 'eog.appdata.xml'
+
+i18n.merge_file(
+  appdata,
+  input: appdata + '.in',
+  output: appdata,
+  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..921298c
--- /dev/null
+++ b/doc/reference/meson.build
@@ -0,0 +1,73 @@
+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/2271
+#        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),
+  ],
+  gobject_typesfile: meson.project_name() + '.types',
+  install: true,
+  install_dir: doc_path
+)
diff --git a/help/LINGUAS b/help/LINGUAS
new file mode 100644
index 0000000..d95bef3
--- /dev/null
+++ b/help/LINGUAS
@@ -0,0 +1,31 @@
+# please keep this list sorted alphabetically
+ar
+ca
+cs
+da
+de
+el
+en_GB
+es
+eu
+fi
+fr
+gl
+hu
+it
+ja
+ko
+lv
+oc
+pa
+pl
+pt_BR
+ro
+ru
+sl
+sv
+te
+th
+uk
+zh_CN
+zh_TW
diff --git a/help/Makefile.am b/help/Makefile.am
index 3980a03..b1114a8 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..21c466e
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,57 @@
+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',
+  'translate.page',
+  'view.page',
+  'zoom.page'
+]
+
+media = [
+  'figures/eog-logo.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'
+]
+
+gnome.yelp(
+  meson.project_name(),
+  sources: sources,
+  media: media,
+  symlink_media: true
+)
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..87f65ab
--- /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(
+  'eog-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..2e499c0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,297 @@
+project(
+  'eog', 'c',
+  version: '3.27.1',
+  license: 'GPL2+',
+  default_options: [
+    'buildtype=debugoptimized',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.43.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_URL', 'https://wiki.gnome.org/Apps/EyeOfGnome'],
+  ['VERSION', eog_version],
+  # i18n
+  ['GETTEXT_PACKAGE', meson.project_name()]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# 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')
+
+# support for strptime
+config_h.set('HAVE_STRPTIME', cc.has_function('strptime'))
+
+# 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'
+  ]
+
+  compiler_flags += cc.get_supported_arguments(test_cflags)
+endif
+
+add_project_arguments(common_flags + compiler_flags, language: 'c')
+
+ldflag = '-Wl,--version-script'
+have_version_script = host_machine.system().contains('linux') and cc.has_argument(ldflag)
+
+glib_req_version = '>= 2.53.4'
+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.36.5'),
+  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),
+  cc.find_library('m')
+]
+
+# ZLIB support (required)
+have_zlib = false
+if cc.has_header('zlib.h')
+  zlib_dep = cc.find_library('z', required: false)
+  have_zlib =  zlib_dep.found() and (cc.has_function('inflate', dependencies: zlib_dep) or 
cc.has_function('crc32', dependencies: zlib_dep))
+
+  if have_zlib
+    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)
+  have_exif = libexif_dep.found() and cc.has_header('libexif/exif-data.h', dependencies: libexif_dep)
+
+  if have_exif
+    eog_deps += libexif_dep
+    config_h.set10('HAVE_EXIF', true,
+                   description: 'EXIF Support.')
+  endif
+endif
+
+# Little CMS (optional)
+have_lcms = false
+if get_option('enable-cms')
+  libcms_dep = dependency('lcms2', required: false)
+  have_lcms = libcms_dep.found()
+
+  if have_lcms
+    eog_deps += libcms_dep
+    config_h.set10('HAVE_LCMS', true,
+                   description: 'Little CMS Support.')
+  endif
+endif
+
+# Exempi (optional)
+have_exempi = false
+if get_option('enable-xmp')
+  libexempi_dep = dependency('exempi-2.0', version: '>= 1.99.5', required: false)
+  have_exempi = libexempi_dep.found()
+
+  if have_exempi
+    eog_deps += libexempi_dep
+    config_h.set10('HAVE_EXEMPI', true,
+                   description: 'XMP Support.')
+  endif
+endif
+
+# Jpeg (semi-optional)
+jpeg_deps = []
+
+have_jpeg = false
+have_jpeg_80 = false
+
+if get_option('enable-libjpeg')
+  libjpeg_dep = dependency('libjpeg', required: false)
+  if libjpeg_dep.found()
+    have_jpeg = cc.has_function('jpeg_destroy_decompress', dependencies: libjpeg_dep) and 
cc.has_header('jpeglib.h', dependencies: libjpeg_dep)
+
+    if have_jpeg
+      jpeg_deps += libjpeg_dep
+
+      have_progressive = cc.has_function('jpeg_simple_progression', dependencies: libjpeg_dep)
+      if not have_progressive
+        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 -Denable-libjpeg=false to\n'
+    error_msg += '*** meson but some programs using GTK+ may not work properly\n'
+    error(error_msg)
+  endif
+
+  config_h.set10('HAVE_JPEG', true,
+                 description: 'Jpeg Support.')
+endif
+config_h.set('HAVE_LIBJPEG', have_jpeg,
+             description: 'libjpeg is Present.')
+
+# introspection support
+have_gir = false
+if get_option('enable-introspection')
+  gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.7', required: false)
+  have_gir = gir_dep.found()
+
+  if have_gir
+    eog_deps += gir_dep
+  endif
+endif
+config_h.set('HAVE_INTROSPECTION', have_gir)
+
+# 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)
+  have_rsvg = librsvg_dep.found()
+
+  if have_rsvg
+    eog_deps += librsvg_dep
+  endif
+endif
+config_h.set('HAVE_RSVG', have_rsvg,
+             description: 'RSVG Support.')
+
+# libX11 (required for TotemScrSaver and Color Profiling)
+gdk_dep = dependency('gdk-3.0', required: 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')
+  eog_deps += libx11_dep
+endif
+
+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
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+meson.add_install_script(
+  'meson_post_install.py',
+  eog_datadir
+)
+
+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..0df4692
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+if not os.environ.get('DESTDIR'):
+  icondir = os.path.join(sys.argv[1], 'icons', 'hicolor')
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+  schemadir = os.path.join(sys.argv[1], 'glib-2.0', 'schemas')
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
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 8bb1b94..cd96354 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/meson.build b/src/meson.build
new file mode 100644
index 0000000..2c0653b
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,208 @@
+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
+
+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 = join_paths(meson.current_source_dir(), 'symbol.map')
+
+ldflags = []
+if have_version_script
+  ldflags += '-Wl,--version-script,@0@'.format(symbol_map)
+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=' + eog_libexecdir,
+    '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_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: 'Gtk-3.0',
+    extra_args: '--warn-all',
+    install: true,
+    install_dir_gir: gir_dir,
+    install_dir_typelib: typelib_dir
+  )
+endif
diff --git a/src/symbol.map b/src/symbol.map
new file mode 100644
index 0000000..4f3a08a
--- /dev/null
+++ b/src/symbol.map
@@ -0,0 +1,6 @@
+{
+global:
+  eog_*;
+local:
+  *;
+};
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..e5ebd32
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,44 @@
+tests_execdir = join_paths(eog_pkglibexecdir, 'installed-tests')
+tests_metadir = join_paths(eog_datadir, 'installed-tests', meson.project_name())
+
+tests_data = files(
+  'actions.feature',
+  'common_steps.py',
+  'environment.py',
+  'gnome-logo.png',
+  'screenshot_tour.feature'
+)
+
+install_data(
+  tests_data,
+  install_dir: tests_execdir
+)
+
+install_subdir(
+  'steps',
+  install_dir: tests_execdir
+)
+
+test_names = [
+  'about',
+  'undo',
+  'sidepane',
+  'fullscreen',
+  'wallpaper',
+  'screenshot_tour1',
+  'screenshot_tour2'
+]
+
+foreach test_name: test_names
+  tests_conf = configuration_data()
+  tests_conf.set('TESTS_PATH', tests_execdir)
+  tests_conf.set('TEST_NAME', test_name)
+
+  configure_file(
+    input: 'template.test.in',
+    output: test_name + '.test',
+    install: true,
+    install_dir: tests_metadir,
+    configuration: tests_conf
+  )
+endforeach
diff --git a/tests/template.test.in b/tests/template.test.in
new file mode 100644
index 0000000..784e51a
--- /dev/null
+++ b/tests/template.test.in
@@ -0,0 +1,3 @@
+[Test]
+Exec=behave @TESTS_PATH@ -t @TEST_NAME@ -k -f html -o @TEST_NAME@.html -f plain
+Type=session-exclusive


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