Index: configure.in =================================================================== RCS file: /home/freeciv/CVS/freeciv/configure.in,v retrieving revision 1.171 diff -u -r1.171 configure.in --- configure.in 2002/01/22 17:04:05 1.171 +++ configure.in 2002/02/01 20:15:46 @@ -154,8 +154,112 @@ dnl I18n support ALL_LINGUAS="da de en_GB es fi fr hu it ja nl no pl pt pt_BR ro ru sv" -AM_GNU_GETTEXT +AM_GNU_GETTEXT(,need-ngettext) +dnl AM_GNU_GETTEXT doesn't have all features we want +dnl or they don't behave correctly. +dnl Old gettext binaries don't understand plurals. (ngettext, msgid_plural) +dnl and there are some problems with missing ngettext. + +if test "$USE_NLS" = "yes"; then + dnl nls_cv_force_use_gnu_gettext is set by AM_GNU_GETTEXT + dnl it is "yes" when --with-included-gettext is given + + if (test "$IS_BETA_VERSION" = "1" || test "$IS_DEVEL_VERSION" = "1") && \ + test "$nls_cv_force_use_gnu_gettext" != "yes"; then + + have_working_ngettext=0 + AC_CHECK_LIB(c, ngettext, + [AC_MSG_CHECKING(whether libc's ngettext works at runtime) + FC_CHECK_NGETTEXT_RUNTIME(,have_working_ngettext=1,)],) + + if test "$have_working_ngettext" = "0"; then + AC_CHECK_LIB(intl, ngettext, + [AC_MSG_CHECKING(whether libintl's ngettext works at runtime) + FC_CHECK_NGETTEXT_RUNTIME("-lintl",have_working_ngettext=1,)],) + fi + + if test "$have_working_ngettext" = "0"; then + AC_MSG_ERROR(I haven't found a working ngettext function in your system. +Try --with-included-gettext or --disable-nls. Read ABOUT-NLS.) + fi + fi + + AC_MSG_CHECKING(for xgettext version >= 0.10.38) + xgettext_version=`$XGETTEXT --version 2>&1 | grep GNU | sed 's/"/ /g'` + AC_TRY_RUN([ +#include + +const char *version = "$xgettext_version"; +int main() +{ + char *p = version; + int major = 0, minor = 0, patch = 0; + + while (*p != '\0' && (*p < '0' || *p > '9')) { + p++; + } + if (*p == '\0') { + return 1; + } + sscanf(p, "%d.%d.%d", &major, &minor, &patch); + if (major < 1 && (minor < 10 || (minor == 10 && patch < 38))) { + return 1; + } + return 0; +} + ], + AC_MSG_RESULT(yes) + , + [ + AC_MSG_RESULT(no) + AC_MSG_WARN(You may have problems with creating pox files. \ +Please update your gettext package.) + ] + , + echo error + ) + + AC_MSG_CHECKING(for msgfmt version >= 0.10.35) + msgfmt_version=`$MSGFMT --version 2>&1 | grep GNU | sed 's/"/ /g'` + AC_TRY_RUN([ +#include + +const char *version = "$msgfmt_version"; + +int main() +{ + char *p = version; + int major = 0, minor = 0, patch = 0; + + while (*p != '\0' && (*p < '0' || *p > '9')) { + p++; + } + if (*p == '\0') { + return 1; + } + sscanf(p, "%d.%d.%d", &major, &minor, &patch); + if (major < 1 && (minor < 10 || (minor == 10 && patch < 35))) { + return 1; + } + return 0; +} + ], + AC_MSG_RESULT(yes) + , + [ + AC_MSG_RESULT(no) + AC_MSG_ERROR(You are unable to create *.gmo files. +This is development version which doesn't include them. Please update your +gettext package. We recommend you versions >= 0.10.38. Or use +--disable-nls instead.) + ] + , + echo error + ) +fi + + dnl note this has to match the path installed by po/Makefile FC_EXPAND_DIR(LOCALEDIR, '${prefix}/share/locale') AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR") @@ -566,17 +670,17 @@ dnl in that 'po/Makefile' a call to xgettext with "--keyword=_" and dnl "--keyword=N_" as arguments. To support Q_() and PL_(), dnl the following simply dnl replaces instances of -dnl "--keyword=N_" with "--keyword=N_ --keyword=Q_ --keyword=PL_" +dnl "--keyword=N_" with "--keyword=N_ --keyword=Q_ --keyword=PL_:1,2" dnl in the 'po/Makefile' file. AC_OUTPUT_COMMANDS( [if test -f po/Makefile ; then - if grep 'keyword=N_ --keyword=Q_ --keyword=PL_' po/Makefile >/dev/null 2>&1 ; then + if grep 'keyword=N_ --keyword=Q_ --keyword=PL_:1,2' po/Makefile >/dev/null 2>&1 ; then # has already been extended : else echo extending po/Makefile mv -f po/Makefile po/Makefile.tmp - sed -e 's/--keyword=N_/--keyword=N_ --keyword=Q_ --keyword=PL_/g' po/Makefile.tmp > po/Makefile + sed -e 's/--keyword=N_/--keyword=N_ --keyword=Q_ --keyword=PL_:1,2/g' po/Makefile.tmp > po/Makefile rm po/Makefile.tmp fi fi]) Index: acinclude.m4 =================================================================== RCS file: /home/freeciv/CVS/freeciv/acinclude.m4,v retrieving revision 1.10 diff -u -r1.10 acinclude.m4 --- acinclude.m4 2001/06/17 22:46:33 1.10 +++ acinclude.m4 2002/02/01 20:15:46 @@ -477,6 +477,50 @@ ]) +dnl FC_CHECK_NGETTEXT_RUNTIME(EXTRA-LIBS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) +dnl +dnl This tests whether ngettext works at runtime. Here, "works" +dnl means "doesn't dump core", as some versions (for exmaple the +dnl version which comes with glibc 2.2.5 is broken, gettext +dnl version 0.10.38 however is ok). + +AC_DEFUN(FC_CHECK_NGETTEXT_RUNTIME, +[ +templibs="$LIBS" +LIBS="$1 $LIBS" +AC_TRY_RUN([ +/* + * Check to make sure that ngettext works at runtime. Specifically, + * some gettext versions dump core if the ngettext function is called. + * (c) 2002 Raimar Falke + */ +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + setenv("LANG", "de_DE", 1); + setlocale(LC_ALL, ""); + + if (strcmp(ngettext("unit", "units", 1), "unit") == 0 && + strcmp(ngettext("unit", "units", 2), "units") == 0) { + return 0; + } else { + return 1; + } +} +], +[AC_MSG_RESULT(yes) + [$2]], +[AC_MSG_RESULT(no) + [$3]], +[AC_MSG_RESULT(unknown: cross-compiling) + [$2]]) +LIBS="$templibs" +]) + dnl @synopsis AC_FUNC_VSNPRINTF dnl dnl Check whether there is a reasonably sane vsnprintf() function installed.