so here's the deal.

first, it's a lot more readable, but that's subjective ;)
second, it will not build intl if linguas selected are not supported.

also do away with requiring xgettext; it's only needed for rebuilding
pot files, so there's no reason hard requiring it for any compilation.

the shell snippet runs on solaris' /sbin/sh, so i'd be rather
surprised if there was a shell that can't run it.

nevertheless, test, especially renato ;)


>From 9ec1a6b5a959f91091208d98f424ee51fadbdf30 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Wed, 24 Mar 2010 21:52:14 +0100
Subject: [PATCH] Streamline i18n-stuff in configure

---
 configure.ac |  150 +++++++++++++++++++++++++---------------------------------
 1 files changed, 65 insertions(+), 85 deletions(-)

diff --git a/configure.ac b/configure.ac
index e056245..4aa9150 100644
--- a/configure.ac
+++ b/configure.ac
@@ -256,102 +256,82 @@ dnl AC_ARG_VAR(PKGCONFIG, [pkg-config command])
 AC_CHECK_PROG(PKGCONFIG, pkg-config, pkg-config) 
 
 
-dnl gettext
-dnl -------
-
-
-dnl AM_GNU_GETTEXT
-
+dnl Internationalization support
+dnl ----------------------------
 
+dnl xgettext is not in any way, shape or form needed to build Window Maker,
+dnl so omit the requirement. If the pot files are to be rebuilt, you will
+dnl probably notice the requirement anyway.
 
 INTLIBS=""
+MOFILES=""
+WPMOFILES=""
+UTILMOFILES=""
+WINGSMOFILES=""
 
-AC_CHECK_FUNC(gettext, [HAVEGETTEXT="yes"], 
-       AC_CHECK_LIB(intl, gettext, [INTLIBS="-lintl" HAVEGETTEXT="yes"],
-                        INTLIBS="" ))
+if test "$LINGUAS" != ""; then
 
-AC_CHECK_PROG(XGETTEXT, xgettext, xgettext)
+    dnl Figure out the intersection of requested and supported
+    dnl languages, on a per-"subproject" basis
+
+    supported_locales="be bg bs ca cs da de el es et fi fr gl hr hu hy it "
+    supported_locales="$supported_locales ja ko ms nl no pl pt ro ru sk sv tr 
zh_CN zh_TW"
+    supported_wprefs_locales="bg ca cs de es et fi fr hr hu it ja ko pt ru sk 
zh_CN zh_TW"
+    supported_wings_locales="bg ca cs de fr sk"
+    supported_util_locales="de"
+
+    for lang in $LINGUAS; do
+            __filter() {
+                ret=""
+                while test -n "$1"; do
+                    if test "$1" = "$lang"; then
+                        ret="$ret $1.mo"
+                    fi
+                    shift
+                done
+                echo $ret
+            }
+            MOFILES="$MOFILES `__filter $supported_locales`"
+            WPMOFILES="$WPMOFILES `__filter $supported_wprefs_locales`"
+            UTILMOFILES="$UTILMOFILES `__filter $supported_util_locales`"
+            WINGSMOFILES="$WINGSMOFILES `__filter $supported_wings_locales`"
+    done
+
+    dnl normalize
+    MOFILES=`echo $MOFILES`
+    WPMOFILES=`echo $WPMOFILES`
+    UTILMOFILES=`echo $UTILMOFILES`
+    WINGSMOFILES=`echo $WINGSMOFILES`
+
+    if test -z "${MOFILES}${WPMOFILES}${UTILMOFILES}${WINGSMOFILES}"; then
+        echo "No valid languages found; not enabling i18n support"
+    else
 
-if test "$XGETTEXT" != ""; then 
-    if $XGETTEXT --help 2>&1 | grep illegal >/dev/null ; then
-        echo "xgettext isn't GNU version"
-        XGETTEXT=""
-    fi
-fi
+        AC_CHECK_FUNC(gettext, [HAVE_GETTEXT="yes"], 
+            AC_CHECK_LIB(intl, gettext, [INTLIBS="-lintl" HAVE_GETTEXT="yes"],
+            INTLIBS="" ))
+    
+        if test "$HAVE_GETTEXT" != ""; then
+            dnl No, I don't want to normalize *MOFILES
+            echo "gettext found; will build i18n support some or all of for 
$LINGUAS"
+            AC_DEFINE(I18N, 1, [Internationalization (I18N) support (set by 
configure)])
+    
+        else
+            echo "gettext not found; support for selected $LINGUAS languages 
will not be build"
+            LINGUAS=""
+            MOFILES=""
+            WPMOFILES=""
+            UTILMOFILES=""
+            WINGSMOFILES=""
+        fi
 
-if test "$LINGUAS" != ""; then
-    if test "$XGETTEXT" != "" -a "$HAVEGETTEXT" != ""; then
-        AC_DEFINE(I18N, 1, [Internationalization (I18N) support (set by 
configure)])
-        PO=""
-        echo "xgettext and gettext() exist; will build i18n support for 
$LINGUAS"
-    else
-        LINGUAS=""
-        PO=""
-        echo "xgettext and libintl.a don't both exist; will not build i18n 
support"
     fi
-else
-       INTLIBS=""
-       MOFILES=""
-       WPMOFILES=""
-       UTILMOFILES=""
-       PO=""
-fi
-
 
-dnl The Tower of Babel
-dnl ==================
+else
 
-dnl List of supported locales
-dnl -------------------------
-supported_locales="be bg bs ca cs da de el es et fi fr gl hr hu hy it ja ko ms 
nl no pl pt ro ru sk sv tr zh_CN zh_TW"
-supported_wprefs_locales="bg ca cs de es et fi fr hr hu it ja ko pt ru sk 
zh_CN zh_TW"
-supported_wings_locales="bg ca cs de fr sk"
-supported_util_locales="de"
+    echo "no languages selected; omitting i18n support"
 
-for lang in $LINGUAS; do
-       ok=0
-       for l in $supported_locales; do
-               if test "$l" = "$lang"; then
-                       ok=1
-                       break
-               fi
-       done
-       if test "$ok" = 1; then
-               MOFILES="$MOFILES $lang.mo"
-       else
-               echo "Locale $lang is not supported."
-       fi
-       ok=0
-       for l in $supported_wprefs_locales; do
-               if test "$l" = "$lang"; then
-                       ok=1
-                       break
-               fi
-       done
-       if test "$ok" = 1; then
-               WPMOFILES="$WPMOFILES $lang.mo"
-       fi
-       ok=0
-       for l in $supported_util_locales; do
-               if test "$l" = "$lang"; then
-                       ok=1
-                       break
-               fi
-       done
-       if test "$ok" = 1; then
-               UTILMOFILES="$UTILMOFILES $lang.mo"
-       fi
-       ok=0
-       for l in $supported_wings_locales; do
-               if test "$l" = "$lang"; then
-                       ok=1
-                       break
-               fi
-       done
-       if test "$ok" = 1; then
-               WINGSMOFILES="$WINGSMOFILES $lang.mo"
-       fi
-done
+fi
 
 
 dnl Kanji Characters support
-- 
1.7.0

-- 
[-]

mkdir /nonexistent
From 9ec1a6b5a959f91091208d98f424ee51fadbdf30 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Wed, 24 Mar 2010 21:52:14 +0100
Subject: [PATCH] Streamline i18n-stuff in configure

---
 configure.ac |  150 +++++++++++++++++++++++++---------------------------------
 1 files changed, 65 insertions(+), 85 deletions(-)

diff --git a/configure.ac b/configure.ac
index e056245..4aa9150 100644
--- a/configure.ac
+++ b/configure.ac
@@ -256,102 +256,82 @@ dnl AC_ARG_VAR(PKGCONFIG, [pkg-config command])
 AC_CHECK_PROG(PKGCONFIG, pkg-config, pkg-config) 
 
 
-dnl gettext
-dnl -------
-
-
-dnl AM_GNU_GETTEXT
-
+dnl Internationalization support
+dnl ----------------------------
 
+dnl xgettext is not in any way, shape or form needed to build Window Maker,
+dnl so omit the requirement. If the pot files are to be rebuilt, you will
+dnl probably notice the requirement anyway.
 
 INTLIBS=""
+MOFILES=""
+WPMOFILES=""
+UTILMOFILES=""
+WINGSMOFILES=""
 
-AC_CHECK_FUNC(gettext, [HAVEGETTEXT="yes"], 
-	AC_CHECK_LIB(intl, gettext, [INTLIBS="-lintl" HAVEGETTEXT="yes"],
-			 INTLIBS="" ))
+if test "$LINGUAS" != ""; then
 
-AC_CHECK_PROG(XGETTEXT, xgettext, xgettext)
+    dnl Figure out the intersection of requested and supported
+    dnl languages, on a per-"subproject" basis
+
+    supported_locales="be bg bs ca cs da de el es et fi fr gl hr hu hy it "
+    supported_locales="$supported_locales ja ko ms nl no pl pt ro ru sk sv tr zh_CN zh_TW"
+    supported_wprefs_locales="bg ca cs de es et fi fr hr hu it ja ko pt ru sk zh_CN zh_TW"
+    supported_wings_locales="bg ca cs de fr sk"
+    supported_util_locales="de"
+
+    for lang in $LINGUAS; do
+            __filter() {
+                ret=""
+                while test -n "$1"; do
+                    if test "$1" = "$lang"; then
+                        ret="$ret $1.mo"
+                    fi
+                    shift
+                done
+                echo $ret
+            }
+            MOFILES="$MOFILES `__filter $supported_locales`"
+            WPMOFILES="$WPMOFILES `__filter $supported_wprefs_locales`"
+            UTILMOFILES="$UTILMOFILES `__filter $supported_util_locales`"
+            WINGSMOFILES="$WINGSMOFILES `__filter $supported_wings_locales`"
+    done
+
+    dnl normalize
+    MOFILES=`echo $MOFILES`
+    WPMOFILES=`echo $WPMOFILES`
+    UTILMOFILES=`echo $UTILMOFILES`
+    WINGSMOFILES=`echo $WINGSMOFILES`
+
+    if test -z "${MOFILES}${WPMOFILES}${UTILMOFILES}${WINGSMOFILES}"; then
+        echo "No valid languages found; not enabling i18n support"
+    else
 
-if test "$XGETTEXT" != ""; then 
-    if $XGETTEXT --help 2>&1 | grep illegal >/dev/null ; then
-        echo "xgettext isn't GNU version"
-        XGETTEXT=""
-    fi
-fi
+        AC_CHECK_FUNC(gettext, [HAVE_GETTEXT="yes"], 
+            AC_CHECK_LIB(intl, gettext, [INTLIBS="-lintl" HAVE_GETTEXT="yes"],
+            INTLIBS="" ))
+    
+        if test "$HAVE_GETTEXT" != ""; then
+            dnl No, I don't want to normalize *MOFILES
+            echo "gettext found; will build i18n support some or all of for $LINGUAS"
+            AC_DEFINE(I18N, 1, [Internationalization (I18N) support (set by configure)])
+    
+        else
+            echo "gettext not found; support for selected $LINGUAS languages will not be build"
+            LINGUAS=""
+            MOFILES=""
+            WPMOFILES=""
+            UTILMOFILES=""
+            WINGSMOFILES=""
+        fi
 
-if test "$LINGUAS" != ""; then
-    if test "$XGETTEXT" != "" -a "$HAVEGETTEXT" != ""; then
-        AC_DEFINE(I18N, 1, [Internationalization (I18N) support (set by configure)])
-        PO=""
-        echo "xgettext and gettext() exist; will build i18n support for $LINGUAS"
-    else
-        LINGUAS=""
-        PO=""
-        echo "xgettext and libintl.a don't both exist; will not build i18n support"
     fi
-else
-    	INTLIBS=""
-	MOFILES=""
-	WPMOFILES=""
-	UTILMOFILES=""
-	PO=""
-fi
-
 
-dnl The Tower of Babel
-dnl ==================
+else
 
-dnl List of supported locales
-dnl -------------------------
-supported_locales="be bg bs ca cs da de el es et fi fr gl hr hu hy it ja ko ms nl no pl pt ro ru sk sv tr zh_CN zh_TW"
-supported_wprefs_locales="bg ca cs de es et fi fr hr hu it ja ko pt ru sk zh_CN zh_TW"
-supported_wings_locales="bg ca cs de fr sk"
-supported_util_locales="de"
+    echo "no languages selected; omitting i18n support"
 
-for lang in $LINGUAS; do
-	ok=0
-	for l in $supported_locales; do
-		if test "$l" = "$lang"; then
-			ok=1
-			break
-		fi
-	done
-	if test "$ok" = 1; then
-		MOFILES="$MOFILES $lang.mo"
-	else
-		echo "Locale $lang is not supported."
-	fi
-	ok=0
-	for l in $supported_wprefs_locales; do
-		if test "$l" = "$lang"; then
-			ok=1
-			break
-		fi
-	done
-	if test "$ok" = 1; then
-		WPMOFILES="$WPMOFILES $lang.mo"
-	fi
-	ok=0
-	for l in $supported_util_locales; do
-		if test "$l" = "$lang"; then
-			ok=1
-			break
-		fi
-	done
-	if test "$ok" = 1; then
-		UTILMOFILES="$UTILMOFILES $lang.mo"
-	fi
-	ok=0
-	for l in $supported_wings_locales; do
-		if test "$l" = "$lang"; then
-			ok=1
-			break
-		fi
-	done
-	if test "$ok" = 1; then
-		WINGSMOFILES="$WINGSMOFILES $lang.mo"
-	fi
-done
+fi
 
 
 dnl Kanji Characters support
-- 
1.7.0

Reply via email to