readline.m4 1.57 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7
##################################################
# Check for readline support.
##################################################

AC_DEFUN([LP_CHECK_READLINE],[

AC_ARG_WITH( readline,
8 9 10 11 12 13
	[ --with-readline	Set prefix where gnu readline headers and libs can be found (ex:/usr, /usr/local, none) [default=/usr] ],
	[ readline_prefix=${withval} ],
	[ readline_prefix="/usr/local" ],
	[ readline_prefix="/opt/local" ],
	[ readline_prefix="/usr" ]
)
aymeric's avatar
aymeric committed
14

15
if test "$readline_prefix" != "none" -a "$readline_prefix" != "no"; then
16 17 18 19 20

	if test "$readline_prefix" != "/usr"; then
		READLINE_CFLAGS="-I$readline_prefix/include"
		READLINE_LIBS="-L$readline_prefix/lib"
	fi
21

22 23 24 25 26 27
	CPPFLAGS_save=$CPPFLAGS
	LIBS_save=$LIBS
	CPPFLAGS="$CPPFLAGS $READLINE_CFLAGS"
	LIBS="$LIBS $READLINE_LIBS"
	AC_CHECK_HEADERS(readline.h readline/readline.h, readline_h_found=yes)
	AC_CHECK_HEADERS(history.h readline/history.h)
28

Yann Diorcet's avatar
Yann Diorcet committed
29 30 31 32 33 34 35 36 37
	for termcap_lib in "" -ltermcap -lcurses -lncurses; do
		unset ac_cv_lib_readline_readline
		AC_CHECK_LIB(readline, readline, [readline_libs_found=yes],[],[$termcap_lib])
		if test "x$readline_libs_found" = "xyes" ; then
			READLINE_LIBS="$READLINE_LIBS -lreadline $termcap_lib"
			break
		fi
	done

38 39
	LIBS=$LIBS_save
	CPPFLAGS=$CPPFLAGS_save
40

41
	if test "$readline_libs_found$readline_h_found" != "yesyes" ; then
Simon Morlat's avatar
Simon Morlat committed
42
		AC_MSG_WARN([Could not find libreadline headers or library, linphonec will have limited prompt features])
43
	else
Yann Diorcet's avatar
Yann Diorcet committed
44
		AC_DEFINE([HAVE_READLINE],1,[defined when compiling with readline support])
45
	fi
46 47


48 49 50 51 52
	AC_SUBST(READLINE_CFLAGS)
	AC_SUBST(READLINE_LIBS)

else
	AC_MSG_NOTICE([Readline support disabled.])
aymeric's avatar
aymeric committed
53 54 55
fi

])