]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog:
authorHarlan Stenn <stenn@ntp.org>
Mon, 15 Oct 2007 08:52:10 +0000 (04:52 -0400)
committerHarlan Stenn <stenn@ntp.org>
Mon, 15 Oct 2007 08:52:10 +0000 (04:52 -0400)
  [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

ChangeLog
configure.ac
m4/ntp_lineeditlibs.m4 [new file with mode: 0644]
ntpdc/Makefile.am
ntpdc/ntpdc.c
ntpq/Makefile.am
ntpq/ntpq.c

index 8ac6e8ffb6c7ae572bc4dee481a433089ed43aef..2550fd677bf33180389d57ff28af0d521e20f6f7 100644 (file)
--- 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.
index d5576b51861f5808e7d27acc580bb62a542bbde7..dfc56f1cb8e8841d101aa95419a5dfb802287407 100644 (file)
@@ -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 (file)
index 0000000..0bde313
--- /dev/null
@@ -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
index 657f7f5490ce5f16724dbc2ed01f9eb23705f8cb..2054407be35baa98091bccf41356efee89b71134 100644 (file)
@@ -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
index 347bb3f30707189d36068522d006cbd1c21a0b81..cc88dd33a0cc02276897516b68c99b6b91b1b065 100644 (file)
 # 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*/
index 2e7a81bd8d95157d7dacfe1acbe69995e4f29589..388008c08825907e298503caef030e2120538674 100644 (file)
@@ -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
index 9ce79e23f128392bb85be3821d11c19e0a002d0b..119526bb7e8bb9a8a740a3f6ec64467ec9e0f1a6 100644 (file)
 # 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*/