dnl AM_WITH_NLS version: 40 updated: 2024/06/12 19:04:11
dnl -----------
dnl Inserted as requested by gettext 0.10.40
dnl File from /usr/share/aclocal
dnl gettext.m4
dnl ====================
dnl Macro to add for using GNU gettext.
dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
dnl ====================
dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
dnl range of locations searched.  Retain the same cache-variable naming to
dnl allow reuse with the other gettext macros -Thomas E Dickey
dnl ====================
dnl
dnl This file can be copied and used freely without restrictions.  It can
dnl be used in projects which are not available under the GNU General Public
dnl License or the GNU Library General Public License but which still want
dnl to provide support for the GNU gettext functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl
dnl serial 10
dnl
dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
AC_DEFUN([AM_WITH_NLS],
[AC_MSG_CHECKING([whether NLS is requested])
  dnl Default is enabled NLS
  ifelse([$4],,[
  AC_ARG_ENABLE(nls,
    [  --disable-nls           do not use Native Language Support],
    USE_NLS=$enableval, USE_NLS=yes)],[
  AC_ARG_ENABLE(nls,
    [  --enable-nls            use Native Language Support],
    USE_NLS=$enableval, USE_NLS=no)])
  AC_MSG_RESULT($USE_NLS)
  AC_SUBST(USE_NLS)

  dnl If we use NLS figure out what method
  if test "$USE_NLS" = "yes"; then
    dnl We need to process the po/ directory.

    dnl Search for GNU msgfmt in the PATH.
    AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
        ["$ac_dir/$ac_word" --statistics /dev/null >/dev/null 2>&1], :)
    AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
    AC_SUBST(MSGFMT)

    dnl Search for GNU xgettext in the PATH.
    AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
        ["$ac_dir/$ac_word" --omit-header /dev/null >/dev/null 2>&1], :)

	CATOBJEXT=NONE

	dnl Save these (possibly-set) variables for reference.  If the user
	dnl overrode these to provide full pathnames, then warn if not actually
	dnl GNU gettext, but do not override their values.  Also, if they were
	dnl overridden, suppress the part of the library test which prevents it
	dnl from finding anything other than GNU gettext.  Doing this also
	dnl suppresses a bogus search for the intl library.
	cf_save_msgfmt_path="$MSGFMT"
	cf_save_xgettext_path="$XGETTEXT"

	CF_ADD_LIBS($LIBICONV)
	cf_save_LIBS_1="$LIBS"
	cf_save_OPTS_1="$CPPFLAGS"

	AC_ARG_WITH([libintl-prefix],
		[  --with-libintl-prefix=DIR
                          search for libintl in DIR/include and DIR/lib],
		[CF_ADD_OPTIONAL_PATH($withval, libintl)])

	CF_FIND_LINKAGE(CF__INTL_HEAD,
	  CF__INTL_BODY($2),
	  intl,
	  cf_cv_func_gettext=yes,
	  cf_cv_func_gettext=no)

	AC_MSG_CHECKING([for libintl.h and gettext()])
	AC_MSG_RESULT($cf_cv_func_gettext)

	if test "$cf_cv_func_gettext" = yes ; then
	  AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have libintl.h])

	  AC_DEFINE(HAVE_GETTEXT, 1,
		  [Define if the GNU gettext() function is already present or preinstalled.])

	  CF_ADD_INCDIR($cf_cv_header_path_intl)

	  if test -n "$cf_cv_library_file_intl" ; then
		INTLLIBS="$cf_cv_library_file_intl"
		CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
	  fi

	  AC_MSG_CHECKING(if this is GNU gettext)
	  AC_TRY_LINK(
#define USE_MSGFMT_HACK
CF__INTL_HEAD,
		  CF__INTL_BODY,
		  cf_cv_gnu_gettext=yes,
		  cf_cv_gnu_gettext=no)
	  AC_MSG_RESULT($cf_cv_gnu_gettext)
	  test "$" = yes && AC_DEFINE(HAVE__NL_MSG_CAT_CNTR,1,[define to 1 if _nl_msg_cat_cntr is found with gettext/intl])

	  LIBS="$LIBS $INTLLIBS"
	  AC_CHECK_FUNCS(dcgettext)
	  CATOBJEXT=.gmo
	  AC_DEFINE(ENABLE_NLS, 1,
          [Define to 1 if translation of program messages is enabled.])
	elif test -z "$MSGFMT" || test -z "$XGETTEXT" ; then
	  AC_MSG_WARN(disabling NLS feature)
	  ALL_LINGUAS=
	  CATOBJEXT=.ignored
	  MSGFMT=":"
	  GMSGFMT=":"
	  XGETTEXT=":"
	  USE_NLS=no
	  LIBS="$cf_save_LIBS_1"
	  CPPFLAGS="$cf_save_OPTS_1"
    fi

    dnl Test whether we really found GNU msgfmt.
    if test "$GMSGFMT" != ":"; then
      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
        : ;
      else
        AC_MSG_WARN([found msgfmt program is not GNU msgfmt])
      fi
    fi

    dnl Test whether we really found GNU xgettext.
    if test "$XGETTEXT" != ":"; then
      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
        : ;
      else
        AC_MSG_WARN([found xgettext program is not GNU xgettext])
      fi
    fi
  fi

  if test "$XGETTEXT" != ":"; then
    AC_OUTPUT_COMMANDS(
     [for ac_file in $CONFIG_FILES; do

        # Support "outfile[:infile[:infile...]]"
        case "$ac_file" in
          (*:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
        esac

        # PO directories have a Makefile.in generated from Makefile.inn.
        case "$ac_file" in
        (*/[Mm]akefile.in)
          # Adjust a relative srcdir.
          ac_dir="`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`"
          ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
          ac_dots="`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`"
          ac_base="`basename $ac_file .in`"
          # In autoconf-2.13 it is called $ac_given_srcdir.
          # In autoconf-2.50 it is called $srcdir.
          test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"

          case "$ac_given_srcdir" in
            (.)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
            (/*) top_srcdir="$ac_given_srcdir" ;;
            (*)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
          esac

          if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
            rm -f "$ac_dir/POTFILES"
            test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
            sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
            test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
            sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
          fi
          ;;
        esac
      done])

    dnl These rules are solely for the distribution goal.  While doing this
    dnl we only have to keep exactly one list of the available catalogs
    dnl in configure.in.
    for lang in $ALL_LINGUAS; do
      GMOFILES="$GMOFILES $lang.gmo"
      POFILES="$POFILES $lang.po"
    done
  fi

  dnl Make all variables we use known to autoconf.
  AC_SUBST(CATALOGS)
  AC_SUBST(CATOBJEXT)
  AC_SUBST(GMOFILES)
  AC_SUBST(POFILES)

  dnl For backward compatibility. Some configure.ins may be using this.
  nls_cv_header_intl=
  nls_cv_header_libgt=

  dnl For backward compatibility. Some Makefiles may be using this.
  DATADIRNAME=share
  AC_SUBST(DATADIRNAME)

  dnl For backward compatibility. Some Makefiles may be using this.
  INSTOBJEXT=.mo
  AC_SUBST(INSTOBJEXT)

  dnl For backward compatibility. Some Makefiles may be using this.
  GENCAT=gencat
  AC_SUBST(GENCAT)
])dnl
