[glib/wip/meson: 30/35] meson: Use proxy-libintl if gettext is not found



commit 8307061e1c77e45053ad696068382c8fe9733d76
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Tue Mar 21 22:06:22 2017 +0530

    meson: Use proxy-libintl if gettext is not found
    
    This is a stub-only library that can be used while building against
    MSVC and contains no i18n machinery at all.
    
    The dependencies added indirectly use the libintl.h header, and when
    built as a subproject, the header won't be in a path known the
    pre-processor.

 gio/meson.build       |    2 +-
 gio/win32/meson.build |    1 +
 glib/meson.build      |    8 ++++----
 gobject/meson.build   |    2 +-
 meson.build           |   25 ++++++++++++++++---------
 5 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/gio/meson.build b/gio/meson.build
index 1ac7597..f695f9e 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -755,7 +755,7 @@ executable('gio', gio_tool_sources,
   c_args : ['-DHAVE_CONFIG_H=1'] + gio_c_args,
   # intl.lib is not compatible with SAFESEH
   link_args : noseh_link_args,
-  dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
+  dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
 
 executable('gresource', 'gresource-tool.c',
   install : true,
diff --git a/gio/win32/meson.build b/gio/win32/meson.build
index 8d3b165..3f6af82 100644
--- a/gio/win32/meson.build
+++ b/gio/win32/meson.build
@@ -10,5 +10,6 @@ giowin32_sources = [
 giowin32_lib = static_library('giowin32',
   sources : [giowin32_sources, gioenumtypes_h],
   include_directories : [configinc, glibinc, gioinc, gmoduleinc],
+  dependencies : [libintl],
   pic : true,
   c_args : [ '-DHAVE_CONFIG_H', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
diff --git a/glib/meson.build b/glib/meson.build
index 3872262..9955e0c 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -233,24 +233,24 @@ if host_system == 'windows'
       gui_app : true,
       c_args : ['-DHAVE_CONFIG_H=1'],
       include_directories : configinc,
-      dependencies : [libglib_dep])
+      dependencies : [libintl, libglib_dep])
     executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
       install : true,
       c_args : ['-DHAVE_CONFIG_H=1', '-DHELPER_CONSOLE'],
       include_directories : configinc,
-      dependencies : [libglib_dep])
+      dependencies : [libintl, libglib_dep])
   else
     executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
       install : true,
       gui_app : true,
       c_args : ['-DHAVE_CONFIG_H=1'],
       include_directories : configinc,
-      dependencies : [libglib_dep])
+      dependencies : [libintl, libglib_dep])
     executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
       install : true,
       c_args : ['-DHAVE_CONFIG_H=1', '-DHELPER_CONSOLE'],
       include_directories : configinc,
-      dependencies : [libglib_dep])
+      dependencies : [libintl, libglib_dep])
   endif
 else
   gtester = executable('gtester', 'gtester.c',
diff --git a/gobject/meson.build b/gobject/meson.build
index 49f707a..54387fe 100644
--- a/gobject/meson.build
+++ b/gobject/meson.build
@@ -60,7 +60,7 @@ libgobject = shared_library('gobject-2.0',
   soversion : soversion,
   install : true,
   include_directories : [configinc],
-  dependencies : [libffi_dep, libglib_dep],
+  dependencies : [libintl, libffi_dep, libglib_dep],
   c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args)
 
 libgobject_dep = declare_dependency(link_with : libgobject,
diff --git a/meson.build b/meson.build
index 778c21a..60b83f7 100644
--- a/meson.build
+++ b/meson.build
@@ -115,12 +115,6 @@ if get_option('default_library') != 'static'
   endif
 endif
 
-if run_command('xgettext', '--help').returncode() != 0
-  error('GNU Gettext required currently.')
-endif
-glib_conf.set('HAVE_GETTEXT', 1)
-glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
-
 # FIXME: what about Cygwin (G_WITH_CYGWIN)
 if host_system == 'windows'
   glib_os = '''#define G_OS_WIN32
@@ -603,8 +597,6 @@ endif
 # AC_FUNC_PRINTF_UNIX98
 # Nothing uses HAVE_UNIX98_PRINTF
 
-glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext'))
-
 # Check for nl_langinfo and CODESET
 # FIXME: Check for HAVE_BIND_TEXTDOMAIN_CODESET
 if cc.links('''#include <langinfo.h>
@@ -1276,8 +1268,21 @@ glib_conf.set('USE_SYSTEM_PCRE', pcre.found())
 libm = cc.find_library('m', required : false)
 libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
 libz_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'])
+
 # Only used on non-glibc targets
 libintl = cc.find_library('intl', required : false)
+if host_system == 'windows' and not libintl.found()
+  # Used only when the gettext library is not available (MSVC, not MinGW)
+  libintl = subproject('proxy-libintl').get_variable('intl_dep')
+  glib_conf.set('HAVE_DCGETTEXT', 1)
+else
+  glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext'))
+endif
+# We require gettext to always be present
+glib_conf.set('HAVE_GETTEXT', 1)
+glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
+# xgettext is optional (on Windows for instance)
+xgettext = find_program('xgettext', required : false)
 
 # libmount is only used by gio, but we need to fetch the libs to generate the
 # pkg-config file below
@@ -1382,7 +1387,9 @@ subdir('gobject')
 subdir('gthread')
 subdir('gmodule')
 subdir('gio')
-subdir('po')
+if xgettext.found()
+  subdir('po')
+endif
 
 # Configure and install pkg-config files
 pc_files = [


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