summaryrefslogtreecommitdiff
path: root/ext/readline/config.m4
blob: ba136d2a8e9d1527c8107fe27c32611a749c3887 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
dnl $Id$
dnl config.m4 for extension readline
dnl don't forget to call PHP_EXTENSION(readline)

PHP_ARG_WITH(libedit,for libedit readline replacement, 
[  --with-libedit[=DIR]    Include libedit readline replacement.])

PHP_ARG_WITH(readline,for readline support,
[  --with-readline[=DIR]   Include readline support.  DIR is the readline
                          install directory.])

if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
  if test "$PHP_SAPI" != "cgi"; then
    AC_MSG_ERROR([readline extension can only be used with CGI build!])
  fi
fi

if test "$PHP_READLINE" != "no"; then
  for i in /usr/local /usr $PHP_READLINE; do
    if test -f $i/include/readline/readline.h; then
      READLINE_DIR=$i
    fi
  done

  if test -z "$READLINE_DIR"; then
    AC_MSG_ERROR(Please reinstall readline - I cannot find readline.h)
  fi
  PHP_ADD_INCLUDE($READLINE_DIR/include)

  AC_CHECK_LIB(ncurses, tgetent, [
    PHP_ADD_LIBRARY_WITH_PATH(ncurses,,READLINE_SHARED_LIBADD)],[
    AC_CHECK_LIB(termcap, tgetent, [
      PHP_ADD_LIBRARY_WITH_PATH(termcap,,READLINE_SHARED_LIBADD)])
  ])

  PHP_ADD_LIBRARY_WITH_PATH(history, $READLINE_DIR/lib, READLINE_SHARED_LIBADD)
  PHP_ADD_LIBRARY_WITH_PATH(readline, $READLINE_DIR/lib, READLINE_SHARED_LIBADD)
  PHP_SUBST(READLINE_SHARED_LIBADD)

  AC_DEFINE(HAVE_LIBREADLINE, 1, [ ])
  PHP_EXTENSION(readline, $ext_shared)
fi

if test "$PHP_LIBEDIT" != "no"; then
  for i in /usr/local /usr $PHP_LIBEDIT; do
    if test -f $i/include/readline/readline.h; then
      LIBEDIT_DIR=$i
    fi
  done

  if test -z "$LIBEDIT_DIR"; then
    AC_MSG_ERROR(Please reinstall libedit - I cannot find readline.h)
  fi
  PHP_ADD_INCLUDE($LIBEDIT_DIR/include)

  AC_CHECK_LIB(ncurses, tgetent, [
    PHP_ADD_LIBRARY_WITH_PATH(ncurses,,READLINE__SHARED_LIBADD)],[
    AC_CHECK_LIB(termcap, tgetent, [
      PHP_ADD_LIBRARY_WITH_PATH(termcap,,READLINE_SHARED_LIBADD)])
  ])

  PHP_ADD_LIBRARY_WITH_PATH(edit, $LIBEDIT_DIR/lib, READLINE_SHARED_LIBADD)  
  PHP_SUBST(READLINE_SHARED_LIBADD)

  AC_DEFINE(HAVE_LIBEDIT, 1, [ ])
  PHP_EXTENSION(readline, $ext_shared)
fi