tglib-gettext.m4 - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tglib-gettext.m4 (15744B)
       ---
            1 # Copyright (C) 1995-2002 Free Software Foundation, Inc.
            2 # Copyright (C) 2001-2003,2004 Red Hat, Inc.
            3 #
            4 # This file is free software, distributed under the terms of the GNU
            5 # General Public License.  As a special exception to the GNU General
            6 # Public License, this file may be distributed as part of a program
            7 # that contains a configuration script generated by Autoconf, under
            8 # the same distribution terms as the rest of that program.
            9 #
           10 # This file can be copied and used freely without restrictions.  It can
           11 # be used in projects which are not available under the GNU Public License
           12 # but which still want to provide support for the GNU gettext functionality.
           13 #
           14 # Macro to add for using GNU gettext.
           15 # Ulrich Drepper <drepper@cygnus.com>, 1995, 1996
           16 #
           17 # Modified to never use included libintl. 
           18 # Owen Taylor <otaylor@redhat.com>, 12/15/1998
           19 #
           20 # Major rework to remove unused code
           21 # Owen Taylor <otaylor@redhat.com>, 12/11/2002
           22 #
           23 # Added better handling of ALL_LINGUAS from GNU gettext version 
           24 # written by Bruno Haible, Owen Taylor <otaylor.redhat.com> 5/30/3002
           25 #
           26 # Modified to require ngettext
           27 # Matthias Clasen <mclasen@redhat.com> 08/06/2004
           28 
           29 # Increment this whenever this file is changed.
           30 #serial 1
           31 
           32 # We need this here as well, since someone might use autoconf-2.5x
           33 # to configure GLib then an older version to configure a package
           34 # using AM_GLIB_GNU_GETTEXT
           35 AC_PREREQ(2.53)
           36 
           37 dnl
           38 dnl We go to great lengths to make sure that aclocal won't 
           39 dnl try to pull in the installed version of these macros
           40 dnl when running aclocal in the glib directory.
           41 dnl
           42 m4_copy([AC_DEFUN],[glib_DEFUN])
           43 m4_copy([AC_REQUIRE],[glib_REQUIRE])
           44 dnl
           45 dnl At the end, if we're not within glib, we'll define the public
           46 dnl definitions in terms of our private definitions.
           47 dnl
           48 
           49 # GLIB_LC_MESSAGES
           50 #--------------------
           51 glib_DEFUN([GLIB_LC_MESSAGES],
           52   [AC_CHECK_HEADERS([locale.h])
           53     if test $ac_cv_header_locale_h = yes; then
           54     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
           55       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
           56        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
           57     if test $am_cv_val_LC_MESSAGES = yes; then
           58       AC_DEFINE(HAVE_LC_MESSAGES, 1,
           59         [Define if your <locale.h> file defines LC_MESSAGES.])
           60     fi
           61   fi])
           62 
           63 # GLIB_PATH_PROG_WITH_TEST
           64 #----------------------------
           65 dnl GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
           66 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
           67 glib_DEFUN([GLIB_PATH_PROG_WITH_TEST],
           68 [# Extract the first word of "$2", so it can be a program name with args.
           69 set dummy $2; ac_word=[$]2
           70 AC_MSG_CHECKING([for $ac_word])
           71 AC_CACHE_VAL(ac_cv_path_$1,
           72 [case "[$]$1" in
           73   /*)
           74   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
           75   ;;
           76   *)
           77   IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
           78   for ac_dir in ifelse([$5], , $PATH, [$5]); do
           79     test -z "$ac_dir" && ac_dir=.
           80     if test -f $ac_dir/$ac_word; then
           81       if [$3]; then
           82         ac_cv_path_$1="$ac_dir/$ac_word"
           83         break
           84       fi
           85     fi
           86   done
           87   IFS="$ac_save_ifs"
           88 dnl If no 4th arg is given, leave the cache variable unset,
           89 dnl so AC_PATH_PROGS will keep looking.
           90 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
           91 ])dnl
           92   ;;
           93 esac])dnl
           94 $1="$ac_cv_path_$1"
           95 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
           96   AC_MSG_RESULT([$]$1)
           97 else
           98   AC_MSG_RESULT(no)
           99 fi
          100 AC_SUBST($1)dnl
          101 ])
          102 
          103 dnl Checks for special options needed on Mac OS X.
          104 dnl Defines INTL_MACOSX_LIBS.
          105 dnl
          106 dnl Copied from intlmacosx.m4 in gettext, GPL.
          107 dnl Copyright (C) 2004-2013 Free Software Foundation, Inc.
          108 glib_DEFUN([glib_gt_INTL_MACOSX],
          109 [
          110   dnl Check for API introduced in Mac OS X 10.2.
          111   AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
          112     [gt_cv_func_CFPreferencesCopyAppValue],
          113     [gt_save_LIBS="$LIBS"
          114      LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
          115      AC_LINK_IFELSE(
          116        [AC_LANG_PROGRAM(
          117           [[#include <CoreFoundation/CFPreferences.h>]],
          118           [[CFPreferencesCopyAppValue(NULL, NULL)]])],
          119        [gt_cv_func_CFPreferencesCopyAppValue=yes],
          120        [gt_cv_func_CFPreferencesCopyAppValue=no])
          121      LIBS="$gt_save_LIBS"])
          122   if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
          123     AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
          124       [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
          125   fi
          126   dnl Check for API introduced in Mac OS X 10.3.
          127   AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
          128     [gt_save_LIBS="$LIBS"
          129      LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
          130      AC_LINK_IFELSE(
          131        [AC_LANG_PROGRAM(
          132           [[#include <CoreFoundation/CFLocale.h>]],
          133           [[CFLocaleCopyCurrent();]])],
          134        [gt_cv_func_CFLocaleCopyCurrent=yes],
          135        [gt_cv_func_CFLocaleCopyCurrent=no])
          136      LIBS="$gt_save_LIBS"])
          137   if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
          138     AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
          139       [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
          140   fi
          141   INTL_MACOSX_LIBS=
          142   if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
          143     INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
          144   fi
          145   AC_SUBST([INTL_MACOSX_LIBS])
          146 ])
          147 
          148 # GLIB_WITH_NLS
          149 #-----------------
          150 glib_DEFUN([GLIB_WITH_NLS],
          151   dnl NLS is obligatory
          152   [USE_NLS=yes
          153     AC_SUBST(USE_NLS)
          154 
          155     gt_cv_have_gettext=no
          156 
          157     CATOBJEXT=NONE
          158     XGETTEXT=:
          159     INTLLIBS=
          160 
          161     glib_gt_INTL_MACOSX
          162 
          163     AC_CHECK_HEADER(libintl.h,
          164      [gt_cv_func_dgettext_libintl="no"
          165       libintl_extra_libs=""
          166 
          167       #
          168       # First check in libc
          169       #
          170       AC_CACHE_CHECK([for ngettext in libc], gt_cv_func_ngettext_libc,
          171         [AC_TRY_LINK([
          172 #include <libintl.h>
          173 ],
          174          [return !ngettext ("","", 1)],
          175           gt_cv_func_ngettext_libc=yes,
          176           gt_cv_func_ngettext_libc=no)
          177         ])
          178   
          179       if test "$gt_cv_func_ngettext_libc" = "yes" ; then
          180               AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
          181                 [AC_TRY_LINK([
          182 #include <libintl.h>
          183 ],
          184                   [return !dgettext ("","")],
          185                   gt_cv_func_dgettext_libc=yes,
          186                   gt_cv_func_dgettext_libc=no)
          187                 ])
          188       fi
          189   
          190       if test "$gt_cv_func_ngettext_libc" = "yes" ; then
          191         AC_CHECK_FUNCS(bind_textdomain_codeset)
          192       fi
          193 
          194       #
          195       # If we don't have everything we want, check in libintl
          196       #
          197       if test "$gt_cv_func_dgettext_libc" != "yes" \
          198          || test "$gt_cv_func_ngettext_libc" != "yes" \
          199          || test "$ac_cv_func_bind_textdomain_codeset" != "yes" ; then
          200         
          201         AC_CHECK_LIB(intl, bindtextdomain,
          202             [AC_CHECK_LIB(intl, ngettext,
          203                     [AC_CHECK_LIB(intl, dgettext,
          204                                   gt_cv_func_dgettext_libintl=yes)])])
          205 
          206         if test "$gt_cv_func_dgettext_libintl" != "yes" ; then
          207           AC_MSG_CHECKING([if -liconv is needed to use gettext])
          208           AC_MSG_RESULT([])
          209             AC_CHECK_LIB(intl, ngettext,
          210                   [AC_CHECK_LIB(intl, dcgettext,
          211                        [gt_cv_func_dgettext_libintl=yes
          212                         libintl_extra_libs=-liconv],
          213                         :,-liconv)],
          214                 :,-liconv)
          215         fi
          216 
          217         #
          218         # If we found libintl, then check in it for bind_textdomain_codeset();
          219         # we'll prefer libc if neither have bind_textdomain_codeset(),
          220         # and both have dgettext and ngettext
          221         #
          222         if test "$gt_cv_func_dgettext_libintl" = "yes" ; then
          223           glib_save_LIBS="$LIBS"
          224           LIBS="$LIBS -lintl $libintl_extra_libs"
          225           unset ac_cv_func_bind_textdomain_codeset
          226           AC_CHECK_FUNCS(bind_textdomain_codeset)
          227           LIBS="$glib_save_LIBS"
          228 
          229           if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then
          230             gt_cv_func_dgettext_libc=no
          231           else
          232             if test "$gt_cv_func_dgettext_libc" = "yes" \
          233                 && test "$gt_cv_func_ngettext_libc" = "yes"; then
          234               gt_cv_func_dgettext_libintl=no
          235             fi
          236           fi
          237         fi
          238       fi
          239 
          240       if test "$gt_cv_func_dgettext_libc" = "yes" \
          241         || test "$gt_cv_func_dgettext_libintl" = "yes"; then
          242         gt_cv_have_gettext=yes
          243       fi
          244   
          245       if test "$gt_cv_func_dgettext_libintl" = "yes"; then
          246         INTLLIBS="-lintl $libintl_extra_libs $INTL_MACOSX_LIBS"
          247       fi
          248   
          249       if test "$gt_cv_have_gettext" = "yes"; then
          250         AC_DEFINE(HAVE_GETTEXT,1,
          251           [Define if the GNU gettext() function is already present or preinstalled.])
          252         GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
          253           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
          254         if test "$MSGFMT" != "no"; then
          255           glib_save_LIBS="$LIBS"
          256           LIBS="$LIBS $INTLLIBS"
          257           AC_CHECK_FUNCS(dcgettext)
          258           MSGFMT_OPTS=
          259           AC_MSG_CHECKING([if msgfmt accepts -c])
          260           GLIB_RUN_PROG([$MSGFMT -c -o /dev/null],[
          261 msgid ""
          262 msgstr ""
          263 "Content-Type: text/plain; charset=UTF-8\n"
          264 "Project-Id-Version: test 1.0\n"
          265 "PO-Revision-Date: 2007-02-15 12:01+0100\n"
          266 "Last-Translator: test <foo@bar.xx>\n"
          267 "Language-Team: C <LL@li.org>\n"
          268 "MIME-Version: 1.0\n"
          269 "Content-Transfer-Encoding: 8bit\n"
          270 ], [MSGFMT_OPTS=-c; AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
          271           AC_SUBST(MSGFMT_OPTS)
          272           AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
          273           GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
          274             [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
          275           AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
          276                          return _nl_msg_cat_cntr],
          277             [CATOBJEXT=.gmo 
          278              DATADIRNAME=share],
          279             [case $host in
          280             *-*-solaris*)
          281             dnl On Solaris, if bind_textdomain_codeset is in libc,
          282             dnl GNU format message catalog is always supported,
          283             dnl since both are added to the libc all together.
          284             dnl Hence, we'd like to go with DATADIRNAME=share and
          285             dnl and CATOBJEXT=.gmo in this case.
          286             AC_CHECK_FUNC(bind_textdomain_codeset,
          287               [CATOBJEXT=.gmo 
          288                DATADIRNAME=share],
          289               [CATOBJEXT=.mo
          290                DATADIRNAME=lib])
          291             ;;
          292             *-*-openbsd*)
          293             CATOBJEXT=.mo
          294             DATADIRNAME=share
          295             ;;
          296             *)
          297             CATOBJEXT=.mo
          298             DATADIRNAME=lib
          299             ;;
          300             esac])
          301           LIBS="$glib_save_LIBS"
          302           INSTOBJEXT=.mo
          303         else
          304           gt_cv_have_gettext=no
          305         fi
          306       fi
          307     ])
          308 
          309     if test "$gt_cv_have_gettext" = "yes" ; then
          310       AC_DEFINE(ENABLE_NLS, 1,
          311         [always defined to indicate that i18n is enabled])
          312     fi
          313 
          314     dnl Test whether we really found GNU xgettext.
          315     if test "$XGETTEXT" != ":"; then
          316       dnl If it is not GNU xgettext we define it as : so that the
          317       dnl Makefiles still can work.
          318       if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
          319         : ;
          320       else
          321         AC_MSG_RESULT(
          322           [found xgettext program is not GNU xgettext; ignore it])
          323         XGETTEXT=":"
          324       fi
          325     fi
          326 
          327     # We need to process the po/ directory.
          328     POSUB=po
          329 
          330     AC_OUTPUT_COMMANDS(
          331       [case "$CONFIG_FILES" in *po/Makefile.in*)
          332         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
          333       esac])
          334 
          335     dnl These rules are solely for the distribution goal.  While doing this
          336     dnl we only have to keep exactly one list of the available catalogs
          337     dnl in configure.ac.
          338     for lang in $ALL_LINGUAS; do
          339       GMOFILES="$GMOFILES $lang.gmo"
          340       POFILES="$POFILES $lang.po"
          341     done
          342 
          343     dnl Make all variables we use known to autoconf.
          344     AC_SUBST(CATALOGS)
          345     AC_SUBST(CATOBJEXT)
          346     AC_SUBST(DATADIRNAME)
          347     AC_SUBST(GMOFILES)
          348     AC_SUBST(INSTOBJEXT)
          349     AC_SUBST(INTLLIBS)
          350     AC_SUBST(PO_IN_DATADIR_TRUE)
          351     AC_SUBST(PO_IN_DATADIR_FALSE)
          352     AC_SUBST(POFILES)
          353     AC_SUBST(POSUB)
          354   ])
          355 
          356 # AM_GLIB_GNU_GETTEXT
          357 # -------------------
          358 # Do checks necessary for use of gettext. If a suitable implementation 
          359 # of gettext is found in either in libintl or in the C library,
          360 # it will set INTLLIBS to the libraries needed for use of gettext
          361 # and AC_DEFINE() HAVE_GETTEXT and ENABLE_NLS. (The shell variable
          362 # gt_cv_have_gettext will be set to "yes".) It will also call AC_SUBST()
          363 # on various variables needed by the Makefile.in.in installed by 
          364 # glib-gettextize.
          365 dnl
          366 AU_DEFUN([GLIB_GNU_GETTEXT],
          367   [AC_REQUIRE([AC_PROG_CC])dnl
          368    
          369    GLIB_LC_MESSAGES
          370    GLIB_WITH_NLS
          371 
          372    if test "$gt_cv_have_gettext" = "yes"; then
          373      if test "x$ALL_LINGUAS" = "x"; then
          374        LINGUAS=
          375      else
          376        AC_MSG_CHECKING(for catalogs to be installed)
          377        NEW_LINGUAS=
          378        for presentlang in $ALL_LINGUAS; do
          379          useit=no
          380          if test "%UNSET%" != "${LINGUAS-%UNSET%}"; then
          381            desiredlanguages="$LINGUAS"
          382          else
          383            desiredlanguages="$ALL_LINGUAS"
          384          fi
          385          for desiredlang in $desiredlanguages; do
          386             # Use the presentlang catalog if desiredlang is
          387            #   a. equal to presentlang, or
          388            #   b. a variant of presentlang (because in this case,
          389            #      presentlang can be used as a fallback for messages
          390            #      which are not translated in the desiredlang catalog).
          391            case "$desiredlang" in
          392              "$presentlang"*) useit=yes;;
          393            esac
          394          done
          395          if test $useit = yes; then
          396            NEW_LINGUAS="$NEW_LINGUAS $presentlang"
          397          fi
          398        done
          399        LINGUAS=$NEW_LINGUAS
          400        AC_MSG_RESULT($LINGUAS)
          401      fi
          402 
          403      dnl Construct list of names of catalog files to be constructed.
          404      if test -n "$LINGUAS"; then
          405        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
          406      fi
          407    fi
          408 
          409    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
          410    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
          411    dnl Try to locate is.
          412    MKINSTALLDIRS=
          413    if test -n "$ac_aux_dir"; then
          414      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
          415    fi
          416    if test -z "$MKINSTALLDIRS"; then
          417      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
          418    fi
          419    AC_SUBST(MKINSTALLDIRS)
          420 
          421    dnl Generate list of files to be processed by xgettext which will
          422    dnl be included in po/Makefile.
          423    test -d po || mkdir po
          424    if test "x$srcdir" != "x."; then
          425      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
          426        posrcprefix="$srcdir/"
          427      else
          428        posrcprefix="../$srcdir/"
          429      fi
          430    else
          431      posrcprefix="../"
          432    fi
          433    rm -f po/POTFILES
          434    sed -e "/^#/d" -e "/^\$/d" -e "s,.*,        $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
          435         < $srcdir/po/POTFILES.in > po/POTFILES
          436   ],
          437   [[$0: This macro is deprecated. You should use upstream gettext instead.]])
          438 
          439 # AM_GLIB_DEFINE_LOCALEDIR(VARIABLE)
          440 # -------------------------------
          441 # Define VARIABLE to the location where catalog files will
          442 # be installed by po/Makefile.
          443 glib_DEFUN([GLIB_DEFINE_LOCALEDIR],
          444 [glib_REQUIRE([GLIB_GNU_GETTEXT])dnl
          445 glib_save_prefix="$prefix"
          446 glib_save_exec_prefix="$exec_prefix"
          447 glib_save_datarootdir="$datarootdir"
          448 test "x$prefix" = xNONE && prefix=$ac_default_prefix
          449 test "x$exec_prefix" = xNONE && exec_prefix=$prefix
          450 datarootdir=`eval echo "${datarootdir}"`
          451 if test "x$CATOBJEXT" = "x.mo" ; then
          452   localedir=`eval echo "${libdir}/locale"`
          453 else
          454   localedir=`eval echo "${datadir}/locale"`
          455 fi
          456 prefix="$glib_save_prefix"
          457 exec_prefix="$glib_save_exec_prefix"
          458 datarootdir="$glib_save_datarootdir"
          459 AC_DEFINE_UNQUOTED($1, "$localedir",
          460   [Define the location where the catalogs will be installed])
          461 ])
          462 
          463 dnl
          464 dnl Now the definitions that aclocal will find
          465 dnl
          466 ifdef(glib_configure_ac,[],[
          467 AC_DEFUN([AM_GLIB_GNU_GETTEXT],[GLIB_GNU_GETTEXT($@)])
          468 AC_DEFUN([AM_GLIB_DEFINE_LOCALEDIR],[GLIB_DEFINE_LOCALEDIR($@)])
          469 ])dnl
          470 
          471 # GLIB_RUN_PROG(PROGRAM, TEST-FILE, [ACTION-IF-PASS], [ACTION-IF-FAIL])
          472 # 
          473 # Create a temporary file with TEST-FILE as its contents and pass the
          474 # file name to PROGRAM.  Perform ACTION-IF-PASS if PROGRAM exits with
          475 # 0 and perform ACTION-IF-FAIL for any other exit status.
          476 AC_DEFUN([GLIB_RUN_PROG],
          477 [cat >conftest.foo <<_ACEOF
          478 $2
          479 _ACEOF
          480 if AC_RUN_LOG([$1 conftest.foo]); then
          481   m4_ifval([$3], [$3], [:])
          482 m4_ifvaln([$4], [else $4])dnl
          483 echo "$as_me: failed input was:" >&AS_MESSAGE_LOG_FD
          484 sed 's/^/| /' conftest.foo >&AS_MESSAGE_LOG_FD
          485 fi])
          486