[libvirt PATCH 062/351] meson: add nls build dependency

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 configure.ac      |  4 ---
 m4/virt-nls.m4    | 72 -----------------------------------------------
 meson.build       | 39 +++++++++++++++++++++++++
 meson_options.txt |  1 +
 4 files changed, 40 insertions(+), 76 deletions(-)
 delete mode 100644 m4/virt-nls.m4

diff --git a/configure.ac b/configure.ac
index 798a30bbd3d..87ba8d059f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,7 +108,6 @@ fi
 
 # Check for compiler and library settings.
 
-LIBVIRT_ARG_NLS
 LIBVIRT_ARG_NSS
 LIBVIRT_ARG_NUMACTL
 LIBVIRT_ARG_OPENWSMAN
@@ -123,7 +122,6 @@ LIBVIRT_ARG_VIRTUALPORT
 LIBVIRT_ARG_WIRESHARK
 LIBVIRT_ARG_YAJL
 
-LIBVIRT_CHECK_NLS
 LIBVIRT_CHECK_NUMACTL
 LIBVIRT_CHECK_NWFILTER
 LIBVIRT_CHECK_OPENWSMAN
@@ -141,7 +139,6 @@ LIBVIRT_CHECK_XDR
 LIBVIRT_CHECK_YAJL
 
 
-AC_CHECK_LIB([intl],[gettext],[])
 AC_CHECK_LIB([util],[openpty],[])
 
 
@@ -419,7 +416,6 @@ AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Libraries])
 AC_MSG_NOTICE([])
 LIBVIRT_RESULT_LIBXL
-LIBVIRT_RESULT_NLS
 LIBVIRT_RESULT_NSS
 LIBVIRT_RESULT_NUMACTL
 LIBVIRT_RESULT_OPENWSMAN
diff --git a/m4/virt-nls.m4 b/m4/virt-nls.m4
deleted file mode 100644
index fd8707033af..00000000000
--- a/m4/virt-nls.m4
+++ /dev/null
@@ -1,72 +0,0 @@
-dnl gettext utilities
-dnl
-dnl Copyright (C) 2018 Red Hat, Inc.
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License, or (at your option) any later version.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library.  If not, see
-dnl <http://www.gnu.org/licenses/>.
-dnl
-
-AC_DEFUN([LIBVIRT_ARG_NLS],[
-  LIBVIRT_ARG_ENABLE([NLS], [NLS], [check])
-])
-
-AC_DEFUN([LIBVIRT_CHECK_NLS],[
-  if test "x$enable_nls" != "xno"
-  then
-    AC_CHECK_FUNC([gettext], [], [
-      AC_CHECK_LIB([intl], [gettext], [], [
-        if test "x$enable_nls" = "xcheck"
-	then
-	  enable_nls=no
-	else
-          AC_MSG_ERROR([gettext() is required to build libvirt]")
-	fi
-      ])
-    ])
-  fi
-
-  if test "x$enable_nls" != "xno"
-  then
-    AC_CHECK_HEADERS([libintl.h], [enable_nls=yes],[
-      if test "x$enable_nls" = "xcheck"
-      then
-        enable_nls=no
-      else
-        AC_MSG_ERROR([libintl.h is required to build libvirt]")
-      fi
-    ])
-  fi
-
-  dnl GNU gettext tools (optional).
-  AC_CHECK_PROG([XGETTEXT], [xgettext], [xgettext], [no])
-  AC_CHECK_PROG([MSGFMT], [msgfmt], [msgfmt], [no])
-  AC_CHECK_PROG([MSGMERGE], [msgmerge], [msgmerge], [no])
-
-  dnl Check they are the GNU gettext tools.
-  AC_MSG_CHECKING([msgfmt is GNU tool])
-  if $MSGFMT --version >/dev/null 2>&1 && $MSGFMT --version | grep -q 'GNU gettext'; then
-    msgfmt_is_gnu=yes
-  else
-    msgfmt_is_gnu=no
-  fi
-  AC_MSG_RESULT([$msgfmt_is_gnu])
-  AM_CONDITIONAL([ENABLE_NLS], [test "x$enable_nls" = "xyes"])
-  AM_CONDITIONAL([HAVE_GNU_GETTEXT_TOOLS],
-    [test "x$XGETTEXT" != "xno" && test "x$MSGFMT" != "xno" && \
-     test "x$MSGMERGE" != "xno" && test "x$msgfmt_is_gnu" != "xno"])
-])
-
-AC_DEFUN([LIBVIRT_RESULT_NLS],[
-  LIBVIRT_RESULT([NLS], [$enable_nls])
-])
diff --git a/meson.build b/meson.build
index 025878a0df6..9a32159472e 100644
--- a/meson.build
+++ b/meson.build
@@ -1170,6 +1170,44 @@ if netcf_dep.found()
   conf.set('WITH_NETCF', 1)
 endif
 
+have_gnu_gettext_tools = false
+if not get_option('nls').disabled()
+  have_gettext = cc.has_function('gettext')
+  if not have_gettext
+    intl_lib = cc.find_library('intl', required: false)
+    have_gettext = intl_lib.found()
+    if have_gettext
+      add_project_link_arguments('-lintl', language: 'c')
+    endif
+  endif
+  if not have_gettext and get_option('nls').enabled()
+    error('gettext() is required to build libvirt')
+  endif
+
+  if cc.has_header('libintl.h')
+    conf.set('HAVE_LIBINTL_H', 1)
+  elif get_option('nls').enabled()
+    error('libintl.h is required to build libvirt')
+  endif
+
+  gettext_progs = [
+    'xgettext',
+    'msgfmt',
+    'msgmerge',
+  ]
+  foreach name : gettext_progs
+    prog = find_program(name, required: false)
+    set_variable('@0@_prog'.format(name), prog)
+  endforeach
+
+  if xgettext_prog.found() and msgfmt_prog.found() and msgmerge_prog.found()
+    rc = run_command(msgfmt_prog, '--version')
+    if rc.returncode() == 0 and rc.stdout().contains('GNU gettext')
+      have_gnu_gettext_tools = true
+    endif
+  endif
+endif
+
 # readline 7.0 is the first version which includes pkg-config support
 readline_version = '7.0'
 readline_dep = dependency('readline', version: '>=' + readline_version, required: false)
@@ -1322,6 +1360,7 @@ libs_summary = {
   'libxml': libxml_dep.found(),
   'macvtap': conf.has('WITH_MACVTAP'),
   'netcf': netcf_dep.found(),
+  'NLS': have_gnu_gettext_tools,
   'readline': readline_dep.found(),
 }
 summary(libs_summary, section: 'Libraries', bool_yn: true)
diff --git a/meson_options.txt b/meson_options.txt
index dc248ee0fe4..d906281900d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -29,4 +29,5 @@ option('libssh', type: 'feature', value: 'auto', description: 'libssh support')
 option('libssh2', type: 'feature', value: 'auto', description: 'libssh2 support')
 option('macvtap', type: 'feature', value: 'auto', description: 'enable macvtap device')
 option('netcf', type: 'feature', value: 'auto', description: 'netcf support')
+option('nls', type: 'feature', value: 'auto', description: 'nls support')
 option('readline', type: 'feature', value: 'auto', description: 'readline support')
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux