diff --git a/configure b/configure index dee39d45f..cf648fb26 100755 --- a/configure +++ b/configure @@ -17554,7 +17554,6 @@ done # gettext() will be defined to gettext_libintl in libintl.h. # Since gcc prefers /usr/local/include to /usr/include, we need to # make sure we use the gettext() that matches the include file. -# First check that it links w/o additional libs, then try with -lintl. if test "$enable_nls" != "no"; then if test "$enable_nls" != "yes"; then CPPFLAGS="${CPPFLAGS} -I${enable_nls}/include" @@ -17574,16 +17573,22 @@ if test "$enable_nls" != "no"; then fi fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettext" >&5 -$as_echo_n "checking for gettext... " >&6; } - if ${sudo_cv_gettext+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + OLIBS="$LIBS" + for l in "libc" "-lintl" "-lintl -liconv"; do + if test "$l" = "libc"; then + # If user specified a dir for libintl ignore libc + if test "$enable_nls" != "yes"; then + continue + fi + else + LIBS="$OLIBS $l" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettext in $l" >&5 +$as_echo_n "checking for gettext in $l... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include + #include int main () { @@ -17594,108 +17599,27 @@ main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : - sudo_cv_gettext=yes -else - sudo_cv_gettext=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_gettext" >&5 -$as_echo "$sudo_cv_gettext" >&6; } - if test "$sudo_cv_gettext" != "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettext in -lintl" >&5 -$as_echo_n "checking for gettext in -lintl... " >&6; } -if ${ac_cv_lib_intl_gettext+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lintl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gettext (); -int -main () -{ -return gettext (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_intl_gettext=yes -else - ac_cv_lib_intl_gettext=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_gettext" >&5 -$as_echo "$ac_cv_lib_intl_gettext" >&6; } -if test "x$ac_cv_lib_intl_gettext" = xyes; then : - LIBINTL="-lintl" -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettext in -lintl" >&5 -$as_echo_n "checking for gettext in -lintl... " >&6; } -if ${ac_cv_lib_intl_gettext_liconv+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lintl -liconv $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gettext (); -int -main () -{ -return gettext (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_intl_gettext_liconv=yes -else - ac_cv_lib_intl_gettext_liconv=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_gettext_liconv" >&5 -$as_echo "$ac_cv_lib_intl_gettext_liconv" >&6; } -if test "x$ac_cv_lib_intl_gettext_liconv" = xyes; then : - LIBINTL="-lintl -liconv" + enable_nls=yes else enable_nls=no -fi - fi - - fi - if test "$enable_nls" != "no"; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_nls" >&5 +$as_echo "$enable_nls" >&6; } + if test "$enable_nls" = "yes"; then + break + fi + done + LIBS="$OLIBS" + if test "$enable_nls" = "yes"; then $as_echo "#define HAVE_LIBINTL_H 1" >>confdefs.h SUDO_NLS=enabled + if test "$l" != "libc"; then + LIBINTL="$l" + fi fi fi diff --git a/configure.in b/configure.in index f822ef8ce..fa07cd08d 100644 --- a/configure.in +++ b/configure.in @@ -2212,31 +2212,39 @@ AC_CHECK_FUNCS(getprogname, , [ # gettext() will be defined to gettext_libintl in libintl.h. # Since gcc prefers /usr/local/include to /usr/include, we need to # make sure we use the gettext() that matches the include file. -# First check that it links w/o additional libs, then try with -lintl. if test "$enable_nls" != "no"; then if test "$enable_nls" != "yes"; then CPPFLAGS="${CPPFLAGS} -I${enable_nls}/include" SUDO_APPEND_LIBPATH(LDFLAGS, [$enable_nls/lib]) fi - AC_MSG_CHECKING([for gettext]) - AC_CACHE_VAL(sudo_cv_gettext, [ - AC_LINK_IFELSE( - [ - AC_LANG_PROGRAM([[#include ]], [(void)gettext((char *)0);]) - ], [sudo_cv_gettext=yes], [sudo_cv_gettext=no]) - ]) - AC_MSG_RESULT($sudo_cv_gettext) - if test "$sudo_cv_gettext" != "yes"; then - AC_CHECK_LIB(intl, gettext, - [LIBINTL="-lintl"], - [ - AC_CHECK_LIB(intl, gettext, [LIBINTL="-lintl -liconv"], - [enable_nls=no], [-liconv]) - ]) - fi - if test "$enable_nls" != "no"; then + OLIBS="$LIBS" + for l in "libc" "-lintl" "-lintl -liconv"; do + if test "$l" = "libc"; then + # If user specified a dir for libintl ignore libc + if test "$enable_nls" != "yes"; then + continue + fi + else + LIBS="$OLIBS $l" + fi + AC_MSG_CHECKING([for gettext in $l]) + AC_LINK_IFELSE( + [ + AC_LANG_PROGRAM([[#include ]], [(void)gettext((char *)0);]) + ], [enable_nls=yes], [enable_nls=no] + ) + AC_MSG_RESULT($enable_nls) + if test "$enable_nls" = "yes"; then + break + fi + done + LIBS="$OLIBS" + if test "$enable_nls" = "yes"; then AC_DEFINE(HAVE_LIBINTL_H) SUDO_NLS=enabled + if test "$l" != "libc"; then + LIBINTL="$l" + fi fi fi