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