acinclude.m4 (PSPP_CHECK_XGETTEXT): Use sed instead of parameter expansion
[pspp] / acinclude.m4
index 043484f45ed3a64a00c4e750f48e4aeee2f7bfb9..750a87efb19495d35d9cfa454c4cef4acee13b10 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright (C) 2005, 2006, 2007, 2009, 2014, 2015 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2006, 2007, 2009, 2014, 2015, 2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -320,6 +320,8 @@ AC_DEFUN([PSPP_ENABLE_WERROR],
    AC_CONFIG_COMMANDS_PRE(
      [if test "X$enable_Werror" = Xyes; then
         CFLAGS="$CFLAGS -Werror -Wno-error=deprecated-declarations"
+       # gnulib needs this, for now:
+       CFLAGS="$CFLAGS -Wno-error=attributes"
       fi])])
 
 # The following comes from Open vSwitch:
@@ -350,3 +352,23 @@ AC_DEFUN([PSPP_CHECK_DOT],
        pspp_cv_dot=no
      fi])
    AM_CONDITIONAL([HAVE_DOT], [test "$pspp_cv_dot" = yes])])
+
+
+dnl Check that xgettext is sufficiently recent
+dnl Before calling this macro, AC_CHECK_PROGS([XGETTEXT], [xgettext]) should have been called,
+dnl which sets the ac_cv_prog_XGETTEXT cache variable.
+AC_DEFUN([PSPP_CHECK_XGETTEXT],
+ [AC_CACHE_CHECK([whether gettext is sufficiently recent],
+   [pspp_cv_progrecent_xgettext],
+   [pspp_cv_progrecent_xgettext=maybe
+    ver=`$ac_cv_prog_XGETTEXT --version | sed -n -e '/xgettext/s/[[^0-9]]*\([[0-9\.]][[0-9\.]]*\).*/\1/p'`
+    majmin=`echo $ver | sed -e 's/\.[[0-9]]*$//'`
+    major=`echo $majmin | sed -e 's/\.[[0-9]]*$//'`
+    minor=`echo $majmin | sed -e 's/^[[0-9]]*\.//'`
+    if test "$major" -lt 0; then
+      pspp_cv_progrecent_xgettext=no;
+    elif test "$minor" -lt 20; then
+      pspp_cv_progrecent_xgettext=no
+    else
+      pspp_cv_progrecent_xgettext=yes
+    fi])])