[Bug 931] Require -lreadline to be asked for explicitly.
[Bug 764] When looking for -lreadline support, also try using -lncurses.
Use new line edit library autoconf macro.
configure.ac:
Use the NTP_LINEEDITLIBS macro now.
Makefile.am, ntpdc.c, ntpq.c:
Use new line editing library detection code
ntp_lineeditlibs.m4:
BitKeeper file /deacon/backroom/ntp-dev-hms/m4/ntp_lineeditlibs.m4
bk: 47132a3avUVzHUdLUb6KBbIQbpw0Fw
+* [Bug 931] Require -lreadline to be asked for explicitly.
+* [Bug 764] When looking for -lreadline support, also try using -lncurses.
* [Bug 909] Fix int32_t errors for ntohl().
* [Bug 376/214] Enhancements to support multiple if names and IP addresses.
* [Bug 929] int32_t is undefined on Windows. Casting wrong.
AC_CHECK_LIB(md5, MD5Init, ,
AC_CHECK_LIB(md, MD5Init))
AC_CHECK_FUNCS(MD5Init)
-dnl HMS: What a hack...
-AC_CHECK_HEADERS(readline/history.h readline/readline.h)
-case "$ac_cv_header_readline_history_h$ac_cv_header_readline_readline_h" in
- *no*) ;;
- *) save_LIBS=$LIBS
- LIBS=
- # Ralf Wildenhues: either unset ... or cache READLINE_LIBS
- unset ac_cv_lib_readline_readline
- AC_CHECK_LIB(readline, readline, ,
- AC_MSG_NOTICE([Trying again with -lcurses])
- unset ac_cv_lib_readline_readline
- AC_CHECK_LIB(readline, readline,
- LIBS="-lreadline -lcurses $LIBS"
- AC_DEFINE(HAVE_LIBREADLINE)
- AC_DEFINE(HAVE_LIBCURSES, , [Do we have the curses library?]),
- AC_CHECK_LIB(edit, readline,
- LIBS="-ledit -lcurses"
- AC_DEFINE(HAVE_LIBEDIT, , [Do we have the edit library?])
- AC_DEFINE(HAVE_LIBCURSES, , [Do we have the curses library?])
- , , -lcurses)
- , -lcurses))
- READLINE_LIBS=$LIBS
- AC_SUBST(READLINE_LIBS)
- LIBS=$save_LIBS
- ;;
-esac
+
+NTP_LINEEDITLIBS
dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt
dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt,
--- /dev/null
+AC_DEFUN([NTP_LINEEDITLIBS], [
+ AC_CACHE_VAL([ntp_cv_lib_lineedit], [
+ # Ralf Wildenhues: either unset ... or cache EDITLINE_LIBS
+ unset ntp_cv_lib_lineedit
+ ORIG_LIBS="$LIBS"
+ AC_ARG_WITH([lineeditlibs],
+ [AC_HELP_STRING([--with-lineeditlibs], [edit,editline,readline])],
+ [use_lineeditlibs="$withval"],
+ [use_lineeditlibs="edit,editline"])
+
+ for lineedit_lib in `echo $use_lineeditlibs | sed -e 's/,/ /'`; do
+ for term_lib in "" termcap curses ncurses; do
+ case "$term_lib" in
+ '') TRY_LIB="-l$lineedit_lib" ;;
+ *) TRY_LIB="-l$lineedit_lib -l$term_lib" ;;
+ esac
+ LIBS="$ORIG_LIBS $TRY_LIB"
+ AC_MSG_CHECKING([for readline() with $TRY_LIB])
+ AC_TRY_LINK_FUNC([readline], [ntp_cv_lib_lineedit="$TRY_LIB"])
+ case "$ntp_cv_lib_lineedit" in
+ '')
+ AC_MSG_RESULT([no])
+ ;;
+ *) # Use readline()
+ AC_MSG_RESULT([yes])
+ break
+ ;;
+ esac
+ AC_MSG_CHECKING([for el_gets() with $TRY_LIB])
+ AC_TRY_LINK_FUNC([el_gets], [ntp_cv_lib_lineedit="$TRY_LIB"])
+ case "$ntp_cv_lib_lineedit" in
+ '')
+ AC_MSG_RESULT([no])
+ ;;
+ *) # Use el_gets()
+ AC_MSG_RESULT([yes])
+ break
+ ;;
+ esac
+ done
+ case "$ntp_cv_lib_lineedit" in
+ '') ;;
+ *) break ;;
+ esac
+ done
+ LIBS="$ORIG_LIBS"
+ case "$ntp_cv_lib_lineedit" in
+ '')
+ ntp_cv_lib_lineedit="no"
+ ;;
+ *) EDITLINE_LIBS="$ntp_cv_lib_lineedit"
+ AC_SUBST(EDITLINE_LIBS)
+ ;;
+ esac
+ ])
+
+ case "$ntp_cv_lib_lineedit" in
+ no) ;;
+ -ledit)
+ AC_DEFINE(HAVE_LIBEDIT, 1,
+ [Define if you have libedit])
+ # we want to also check for readline.h
+ AC_CHECK_HEADERS(histedit.h)
+ ;;
+ -leditline)
+ AC_MSG_WARN([editline is not yet supported])
+ ;;
+ *)
+ AC_DEFINE(HAVE_LIBREADLINE, 1,
+ [Define if you have a readline compatible library])
+ AC_CHECK_HEADERS(readline.h readline/readline.h)
+ AC_CACHE_CHECK([whether readline supports history],
+ ntp_cv_lib_lineedit_history, [
+ ntp_cv_lib_lineedit_history="no"
+ AC_TRY_LINK_FUNC(add_history, ntp_cv_lib_lineedit_history="yes")
+ ])
+ case "$ntp_cv_lib_lineedit_history" in
+ yes)
+ AC_DEFINE(HAVE_READLINE_HISTORY, 1,
+ [Define if your readline library has \`add_history'])
+ AC_CHECK_HEADERS(history.h readline/history.h)
+ ;;
+ esac
+ ;;
+ esac
+])dnl
BUILT_SOURCES= @MAKE_CHECK_LAYOUT@
AM_CPPFLAGS= -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
# LDADD might need RESLIB and ADJLIB
-ntpdc_LDADD= version.o @READLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ntpdc_LDADD= version.o @EDITLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
# ntpdc-layout doesn't need any additional libraries at all
ntpdc_layout_LDADD=
DISTCLEANFILES= .version version.c
# define closesocket close
#endif /* SYS_WINNT */
-#if defined(HAVE_LIBREADLINE) || defined (HAVE_LIBEDIT)
+#if defined(HAVE_LIBREADLINE)
# include <readline/readline.h>
# include <readline/history.h>
-#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
+#endif /* HAVE_LIBREADLINE */
+
+#if defined (HAVE_LIBEDIT)
+# include <editline/readline.h>
+#endif /* HAVE_LIBEDIT */
#ifdef SYS_VXWORKS
/* vxWorks needs mode flag -casey*/
AM_CPPFLAGS= -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
# LDADD might need RESLIB and ADJLIB
-ntpq_LDADD= version.o @READLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ntpq_LDADD= version.o @EDITLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
DISTCLEANFILES= .version version.c
noinst_HEADERS= ntpq.h
ETAGS_ARGS= Makefile.am
# define closesocket close
#endif /* SYS_WINNT */
-#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
+#if defined(HAVE_LIBREADLINE)
# include <readline/readline.h>
# include <readline/history.h>
-#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
+#endif /* HAVE_LIBREADLINE */
+
+#if defined(HAVE_LIBEDIT)
+# include <editline/readline.h>
+#endif /* HAVE_LIBEDIT */
#ifdef SYS_VXWORKS
/* vxWorks needs mode flag -casey*/