xref: /PHP-8.3/ext/gettext/config.m4 (revision 7236dfef)
1PHP_ARG_WITH([gettext],
2  [for GNU gettext support],
3  [AS_HELP_STRING([[--with-gettext[=DIR]]],
4    [Include GNU gettext support])])
5
6if test "$PHP_GETTEXT" != "no"; then
7  for i in $PHP_GETTEXT /usr/local /usr; do
8    test -r $i/include/libintl.h && GETTEXT_DIR=$i && break
9  done
10
11  if test -z "$GETTEXT_DIR"; then
12    AC_MSG_ERROR(Cannot locate header file libintl.h)
13  fi
14
15  GETTEXT_LIBDIR=$GETTEXT_DIR/$PHP_LIBDIR
16  GETTEXT_INCDIR=$GETTEXT_DIR/include
17
18  O_LDFLAGS=$LDFLAGS
19  LDFLAGS="$LDFLAGS -L$GETTEXT_LIBDIR"
20  AC_CHECK_LIB(intl, bindtextdomain, [
21    GETTEXT_LIBS=intl
22    GETTEXT_CHECK_IN_LIB=intl
23    ],
24    [
25    AC_CHECK_LIB(c, bindtextdomain, [
26      GETTEXT_LIBS=
27      GETTEXT_CHECK_IN_LIB=c
28    ],[
29      AC_MSG_ERROR(Unable to find required gettext library)
30    ])
31  ]
32  )
33
34  AC_DEFINE(HAVE_LIBINTL,1,[ ])
35  PHP_NEW_EXTENSION(gettext, gettext.c, $ext_shared)
36  PHP_SUBST(GETTEXT_SHARED_LIBADD)
37
38  PHP_ADD_INCLUDE($GETTEXT_INCDIR)
39
40  AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, ngettext,  [AC_DEFINE(HAVE_NGETTEXT, 1, [ ])])
41  AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, dngettext,  [AC_DEFINE(HAVE_DNGETTEXT, 1, [ ])])
42  AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, dcngettext,  [AC_DEFINE(HAVE_DCNGETTEXT, 1, [ ])])
43  AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, bind_textdomain_codeset,  [AC_DEFINE(HAVE_BIND_TEXTDOMAIN_CODESET, 1, [ ])])
44  LDFLAGS=$O_LDFLAGS
45
46  if test -n "$GETTEXT_LIBS"; then
47    PHP_ADD_LIBRARY_WITH_PATH($GETTEXT_LIBS, $GETTEXT_LIBDIR, GETTEXT_SHARED_LIBADD)
48  fi
49fi
50