xref: /PHP-7.3/ext/recode/config.m4 (revision 4371945b)
1dnl config.m4 for extension recode
2
3PHP_ARG_WITH(recode,for recode support,
4[  --with-recode[=DIR]       Include recode support])
5
6if test "$PHP_RECODE" != "no"; then
7  RECODE_LIST="$PHP_RECODE /usr/local /usr /opt"
8
9  for i in $RECODE_LIST; do
10    if test -f $i/include/recode.h; then
11      RECODE_DIR=$i
12      RECODE_INC=include
13      RECODE_LIB=$PHP_LIBDIR
14    fi
15    if test -f $i/include/recode/recode.h; then
16      RECODE_DIR=$i
17      RECODE_INC=include/recode
18      RECODE_LIB=$PHP_LIBDIR/recode
19    fi
20    if test -f $i/recode/include/recode.h; then
21      RECODE_DIR=$i/recode
22      RECODE_INC=include
23      RECODE_LIB=$PHP_LIBDIR
24    fi
25    test -n "$RECODE_DIR" && break
26  done
27
28  if test -z "$RECODE_DIR"; then
29    AC_MSG_ERROR([Can not find recode.h anywhere under $RECODE_LIST.])
30  fi
31
32  PHP_CHECK_LIBRARY(recode, recode_format_table,
33  [
34    PHP_ADD_LIBRARY_WITH_PATH(recode, $RECODE_DIR/$RECODE_LIB, RECODE_SHARED_LIBADD)
35  ], [
36    old_LDFLAGS=$LDFLAGS
37    old_LIBS=$LIBS
38    LDFLAGS="$LDFLAGS -L$RECODE_DIR/$RECODE_LIB"
39    LIBS="$LIBS -lrecode"
40    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
41char *program_name;
42    ]],[[
43recode_format_table();
44    ]])],[
45      PHP_ADD_LIBRARY_DEFER_WITH_PATH(recode, $RECODE_DIR/$RECODE_LIB, RECODE_SHARED_LIBADD)
46      AC_DEFINE(HAVE_BROKEN_RECODE, 1, [Whether we have librecode 3.5])
47    ],[
48      AC_MSG_ERROR(I cannot link librecode (-L$RECODE_DIR/$RECODE_LIB -lrecode). Is it installed?)
49    ])
50    LIBS=$old_LIBS
51    LDFLAGS=$old_LDFLAGS
52  ], [
53    -L$RECODE_DIR/$RECODE_LIB
54  ])
55
56  AC_DEFINE(HAVE_LIBRECODE, 1, [Whether we have librecode 3.5 or higher])
57  PHP_ADD_INCLUDE($RECODE_DIR/$RECODE_INC)
58  PHP_SUBST(RECODE_SHARED_LIBADD)
59  AC_CHECK_HEADERS(stdbool.h)
60  PHP_NEW_EXTENSION(recode, recode.c, $ext_shared)
61fi
62