From: Harlan Stenn Date: Mon, 15 Oct 2007 08:52:10 +0000 (-0400) Subject: ChangeLog: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0bcbd6d243407752ed4f8baf7f668cb96965ab9;p=thirdparty%2Fntp.git ChangeLog: [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 --- diff --git a/ChangeLog b/ChangeLog index 8ac6e8ffb6..2550fd677b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [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. diff --git a/configure.ac b/configure.ac index d5576b5186..dfc56f1cb8 100644 --- a/configure.ac +++ b/configure.ac @@ -341,32 +341,8 @@ AC_CHECK_FUNC(openlog, , 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, diff --git a/m4/ntp_lineeditlibs.m4 b/m4/ntp_lineeditlibs.m4 new file mode 100644 index 0000000000..0bde3130da --- /dev/null +++ b/m4/ntp_lineeditlibs.m4 @@ -0,0 +1,86 @@ +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 diff --git a/ntpdc/Makefile.am b/ntpdc/Makefile.am index 657f7f5490..2054407be3 100644 --- a/ntpdc/Makefile.am +++ b/ntpdc/Makefile.am @@ -7,7 +7,7 @@ EXTRA_DATA= check-layout 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 diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c index 347bb3f307..cc88dd33a0 100644 --- a/ntpdc/ntpdc.c +++ b/ntpdc/ntpdc.c @@ -26,10 +26,14 @@ # define closesocket close #endif /* SYS_WINNT */ -#if defined(HAVE_LIBREADLINE) || defined (HAVE_LIBEDIT) +#if defined(HAVE_LIBREADLINE) # include # include -#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */ +#endif /* HAVE_LIBREADLINE */ + +#if defined (HAVE_LIBEDIT) +# include +#endif /* HAVE_LIBEDIT */ #ifdef SYS_VXWORKS /* vxWorks needs mode flag -casey*/ diff --git a/ntpq/Makefile.am b/ntpq/Makefile.am index 2e7a81bd8d..388008c088 100644 --- a/ntpq/Makefile.am +++ b/ntpq/Makefile.am @@ -4,7 +4,7 @@ bin_PROGRAMS= ntpq 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 diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index 9ce79e23f1..119526bb7e 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -31,10 +31,14 @@ # define closesocket close #endif /* SYS_WINNT */ -#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) +#if defined(HAVE_LIBREADLINE) # include # include -#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */ +#endif /* HAVE_LIBREADLINE */ + +#if defined(HAVE_LIBEDIT) +# include +#endif /* HAVE_LIBEDIT */ #ifdef SYS_VXWORKS /* vxWorks needs mode flag -casey*/