autoconf: #include <libintl.h> when checking for gettext()
Some libc implementations like uclibc or musl provides gettext stubs via libintl library but this case is not checked by AC_CHECK_LIB(c, gettext ...) because gcc has gettext as builtin which passess the check. So check it with included libintl.h where gettext may unfold into libintl_gettext which will cause check to fail if libintl_gettext are needed to be linked with -lintl. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Vadim Kochan committed
Apr 18, 2019 at 08:04 UTC
b71e56a68384748f2dc712471957b719513508fb
1 file changed
+13
-3
configure.ac
+13
-3
@@ -763,9 +763,19 @@ AC_CHECK_LIB([c], [basename],
763
GIT_CONF_SUBST([NEEDS_LIBGEN])
764
test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
765
766
-AC_CHECK_LIB([c], [gettext],
767
-[LIBC_CONTAINS_LIBINTL=YesPlease],
768
-[LIBC_CONTAINS_LIBINTL=])
766
+AC_DEFUN([LIBINTL_SRC], [
767
+AC_LANG_PROGRAM([[
768
+#include <libintl.h>
769
+]],[[
770
+char *msg = gettext("test");
771
+]])])
772
+
773
+AC_MSG_CHECKING([if libc contains libintl])
774
+AC_LINK_IFELSE([LIBINTL_SRC],
775
+ [AC_MSG_RESULT([yes])
776
+ LIBC_CONTAINS_LIBINTL=YesPlease],
777
+ [AC_MSG_RESULT([no])
778
+ LIBC_CONTAINS_LIBINTL=])
779
GIT_CONF_SUBST([LIBC_CONTAINS_LIBINTL])
780
781
#