| 1 |
AC_DEFUN([SUDO_CHECK_GETTEXT], [ |
| 2 |
# gettext() and friends may be located in libc (Linux and Solaris) |
| 3 |
# or in libintl. However, it is possible to have libintl installed |
| 4 |
# even when gettext() is present in libc. In the case of GNU libintl, |
| 5 |
# gettext() will be defined to gettext_libintl in libintl.h. |
| 6 |
# Since gcc prefers /usr/local/include to /usr/include, we need to |
| 7 |
# make sure we use the gettext() that matches the include file. |
| 8 |
if test "$enable_nls" != "no"; then |
| 9 |
if test "$enable_nls" != "yes"; then |
| 10 |
AX_APPEND_FLAG([-I${enable_nls}/include], [CPPFLAGS]) |
| 11 |
SUDO_APPEND_LIBPATH(LDFLAGS, [$enable_nls/lib]) |
| 12 |
fi |
| 13 |
OLIBS="$LIBS" |
| 14 |
for l in "libc" "-lintl" "-lintl -liconv"; do |
| 15 |
if test "$l" = "libc"; then |
| 16 |
# If user specified a dir for libintl ignore libc |
| 17 |
if test "$enable_nls" != "yes"; then |
| 18 |
continue |
| 19 |
fi |
| 20 |
gettext_name=sudo_cv_gettext |
| 21 |
AC_MSG_CHECKING([for gettext]) |
| 22 |
else |
| 23 |
LIBS="$OLIBS $l" |
| 24 |
gettext_name=sudo_cv_gettext"`echo $l|sed -e 's/ //g' -e 's/-/_/g'`" |
| 25 |
AC_MSG_CHECKING([for gettext in $l]) |
| 26 |
fi |
| 27 |
AC_CACHE_VAL($gettext_name, [ |
| 28 |
AC_LINK_IFELSE( |
| 29 |
[ |
| 30 |
AC_LANG_PROGRAM([[#include <libintl.h>]], [(void)gettext((char *)0);]) |
| 31 |
], [eval $gettext_name=yes], [eval $gettext_name=no] |
| 32 |
) |
| 33 |
]) |
| 34 |
eval gettext_result="\$$gettext_name" |
| 35 |
AC_MSG_RESULT($gettext_result) |
| 36 |
if test "$gettext_result" = "yes"; then |
| 37 |
AC_CHECK_FUNCS([ngettext]) |
| 38 |
break |
| 39 |
fi |
| 40 |
done |
| 41 |
LIBS="$OLIBS" |
| 42 |
|
| 43 |
if test "$sudo_cv_gettext" = "yes"; then |
| 44 |
SUDO_NLS=enabled |
| 45 |
# For Solaris we need links from lang to lang.UTF-8 in localedir |
| 46 |
case "$host_os" in |
| 47 |
solaris2*) LOCALEDIR_SUFFIX=".UTF-8";; |
| 48 |
esac |
| 49 |
elif test "$sudo_cv_gettext_lintl" = "yes"; then |
| 50 |
SUDO_NLS=enabled |
| 51 |
LIBINTL="-lintl" |
| 52 |
elif test "$sudo_cv_gettext_lintl_liconv" = "yes"; then |
| 53 |
SUDO_NLS=enabled |
| 54 |
LIBINTL="-lintl -liconv" |
| 55 |
fi |
| 56 |
if test X"$SUDO_NLS" = X"enabled"; then |
| 57 |
AC_DEFINE(HAVE_LIBINTL_H) |
| 58 |
SUDO_APPEND_COMPAT_EXP(sudo_warn_gettext_v1) |
| 59 |
fi |
| 60 |
fi |
| 61 |
]) |