From 70331ad0a7c255a48c03cfe09f3f9df80f00c2d0 Mon Sep 17 00:00:00 2001
From: panne <unknown>
Date: Fri, 21 Apr 2000 18:05:20 +0000
Subject: [PATCH] [project @ 2000-04-21 18:05:19 by panne] /tmp/msg

---
 acconfig.h               |  9 +++++---
 configure.in             | 49 +++++++++++++++++++++++++++-------------
 ghc/driver/Makefile      |  4 ++--
 ghc/driver/ghc.lprl      |  2 +-
 ghc/interpreter/Makefile | 12 +++-------
 ghc/interpreter/input.c  |  6 ++---
 mk/config.h.in           | 18 +++++++--------
 mk/config.mk.in          |  8 ++++---
 8 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/acconfig.h b/acconfig.h
index 536412712b76..a5cd3f35efbc 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -81,6 +81,12 @@
 /* Define if compiler supports prototypes. */
 #define HAVE_PROTOTYPES 0
 
+/* Define if readline/readline.h and readline/history.h exist */
+#undef HAVE_READLINE_HEADERS
+
+/* Define if readline plus any additional libs needed for it exist */
+#undef HAVE_READLINE_LIBS
+
 /* Define if time.h or sys/time.h define the timezone variable */
 #undef HAVE_TIMEZONE
 
@@ -90,9 +96,6 @@
 /* Define if you support the production (and use) of Win32 DLLs. */
 #undef HAVE_WIN32_DLL_SUPPORT
 
-/* Define if you have and want to use readline in Hugs. */
-#undef HAVE_LIBREADLINE
-
 /* Define if C Symbols have a leading underscore added by the compiler */
 #undef LEADING_UNDERSCORE
 
diff --git a/configure.in b/configure.in
index 38f838d7cce0..42415b530a1a 100644
--- a/configure.in
+++ b/configure.in
@@ -504,7 +504,19 @@ dnl ** check for full ANSI header (.h) files
 AC_HEADER_STDC
 
 dnl ** check for specific header (.h) files that we are interested in
-AC_CHECK_HEADERS(Files.h assert.h console.h ctype.h dirent.h errno.h fcntl.h float.h ftw.h grp.h ieee754.h malloc.h memory.h nlist.h pascal.h pwd.h sgtty.h siginfo.h signal.h stat.h stdint.h stdlib.h stdarg.h string.h sys/fault.h sys/file.h sys/ioctl.h sys/limits.h sys/mman.h sys/param.h sys/procfs.h sys/resource.h sys/signal.h sys/socket.h netinet/tcp.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/vadvise.h sys/wait.h termio.h termios.h time.h types.h unistd.h utime.h values.h vfork.h readline/readline.h readline/history.h bfd.h winsock.h)
+AC_CHECK_HEADERS(Files.h assert.h console.h ctype.h dirent.h errno.h fcntl.h float.h ftw.h grp.h ieee754.h malloc.h memory.h nlist.h pascal.h pwd.h sgtty.h siginfo.h signal.h stat.h stdint.h stdlib.h stdarg.h string.h sys/fault.h sys/file.h sys/ioctl.h sys/limits.h sys/mman.h sys/param.h sys/procfs.h sys/resource.h sys/signal.h sys/socket.h netinet/tcp.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/vadvise.h sys/wait.h termio.h termios.h time.h types.h unistd.h utime.h values.h vfork.h bfd.h winsock.h)
+
+AC_CHECK_HEADER(readline/readline.h, HaveReadlineReadlineH=YES, HaveReadlineReadlineH=NO)
+AC_CHECK_HEADER(readline/history.h, HaveReadlineHistoryH=YES, HaveReadlineHistoryH=NO)
+
+if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then
+  HaveReadlineHeaders=YES
+  AC_DEFINE(HAVE_READLINE_HEADERS,1)
+else
+  HaveReadlineHeaders=NO
+  AC_DEFINE(HAVE_READLINE_HEADERS,0)
+fi
+AC_SUBST(HaveReadlineHeaders)
 
 dnl ** check for DOS include files
 AC_CHECK_HEADERS(dos.h conio.h io.h std.h) 
@@ -669,22 +681,27 @@ dnl    the order of these tests matters: bfd needs liberty
 AC_CHECK_LIB(iberty, xmalloc)
 AC_CHECK_LIB(bfd,    bfd_init)
 
-dnl ** check for readline, for Hugs
-dnl termcap is obsoleted by ncurses, but for compatibility, we have to
-dnl check for both...
-AC_SEARCH_LIBS(tputs, [ncurses termcap])
-
-AC_CHECK_LIB(readline, readline,
-[
-AC_DEFINE(HAVE_LIBREADLINE,1)
-HaveLibReadline=YES
-],
-[
-AC_DEFINE(HAVE_LIBREADLINE,0)
-HaveLibReadline=NO
-])
-AC_SUBST(HaveLibReadline)
+dnl ** check for readline, for Hugs and hslibs' Readline
+dnl ncurses supersedes termcap and curses, but for compatibility,
+dnl we have to check for all...
+AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=YES; LibTermcap=ncurses,
+  AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=YES; LibTermcap=termcap,
+    AC_CHECK_LIB(curses, tputs, HaveLibTermcap=YES; LibTermcap=curses,
+      HaveLibTermcap=NO; LibTermcap=not-installed)))
+
+if test $HaveLibTermcap = YES ; then
+  LIBS="-l$LibTermcap $LIBS"
+  AC_CHECK_LIB(readline, readline, HaveLibReadline=YES, HaveLibReadline=NO)
+fi
 
+if test $HaveLibTermcap = YES && test x"$HaveLibReadline" = xYES ; then
+  AC_DEFINE(HAVE_READLINE_LIBS,1)
+  LibsReadline="-lreadline -l$LibTermcap"
+else
+  AC_DEFINE(HAVE_READLINE_LIBS,0)
+  LibsReadline=
+fi
+AC_SUBST(LibsReadline)
 
 dnl ################################################################
 dnl Check for libraries
diff --git a/ghc/driver/Makefile b/ghc/driver/Makefile
index 52b04e139703..26575bf8614a 100644
--- a/ghc/driver/Makefile
+++ b/ghc/driver/Makefile
@@ -1,5 +1,5 @@
 #-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.27 1999/11/25 10:38:59 simonpj Exp $
+# $Id: Makefile,v 1.28 2000/04/21 18:05:19 panne Exp $
 
 # We create two driver scripts: 
 #	- one to run in-place in the build tree for building libraries
@@ -53,7 +53,7 @@ SCRIPT_SUBST_VARS := \
   GHC_LIB_DIR GHC_RUNTIME_DIR GHC_INCLUDE_DIR \
   GHC_OPT_HILEV_ASM GhcWithNativeCodeGen LeadingUnderscore\
   GHC_UNLIT GHC_HSCPP GHC_MKDEPENDHS GHC_HSC GHC_SYSMAN EnableWin32DLLs \
-  CP RM CONTEXT_DIFF LibGmp GhcWithRegisterised \
+  CP RM CONTEXT_DIFF LibGmp GhcWithRegisterised LibsReadline \
   $(USER_WAY_NAMES) $(USER_WAY_OPTS)
 
 #
diff --git a/ghc/driver/ghc.lprl b/ghc/driver/ghc.lprl
index 34db5eb06a9b..299798d5645f 100644
--- a/ghc/driver/ghc.lprl
+++ b/ghc/driver/ghc.lprl
@@ -2650,7 +2650,7 @@ sub add_syslib {
 	, 'lang concurrent posix' # Syslib dependencies
 	, ''     # extra ghc opts
 	, ''     # extra cc opts
-	, ''     # extra ld opts
+	, "$LibsReadline"     # extra ld opts
 	],
 
        win32,
diff --git a/ghc/interpreter/Makefile b/ghc/interpreter/Makefile
index bdff634f4842..c81537987f70 100644
--- a/ghc/interpreter/Makefile
+++ b/ghc/interpreter/Makefile
@@ -1,6 +1,6 @@
 
 # --------------------------------------------------------------------------- #
-# $Id: Makefile,v 1.31 2000/04/14 15:11:25 sewardj Exp $                      #
+# $Id: Makefile,v 1.32 2000/04/21 18:05:19 panne Exp $                      #
 # --------------------------------------------------------------------------- #
 
 TOP = ..
@@ -19,12 +19,6 @@ DYN_EXT=.so
 LIB_DL=-ldl
 endif
 
-ifeq "$(HaveLibReadline)$" "YES"
-LIB_READLINE=-lreadline -ltermcap
-else
-LIB_READLINE=
-endif
-
 ifeq "$(HaveLibGmp)$" "YES"
 LIB_GMP=-lgmp
 else
@@ -56,7 +50,7 @@ hugs: $(C_OBJS) ../rts/Sanity.o ../rts/Assembler.o ../rts/Disassembler.o   \
       ../rts/StgCRun.o ../rts/PrimOps.o ../rts/Prelude.o ../rts/Storage.o \
       ../rts/Schedule.o ../rts/libHSrts.a
 	$(CC) -o $@ $(CC_OPTS) $^ $(GHC_LIBS_NEEDED) \
-		 -lbfd -liberty $(LIB_READLINE) $(LIB_DL) \
+		 -lbfd -liberty $(LibsReadline) $(LIB_DL) \
 		 $(LIB_GMP) -lm
 
 foobar:
@@ -120,7 +114,7 @@ CLEAN_FILES += parser.c
 
 INSTALL_LIBEXECS = hugs
 
-depend :: $(LOOPS) $(SRCS_UGNHS)
+depend :: parser.c $(LOOPS) $(SRCS_UGNHS)
 
 
 include $(TOP)/mk/target.mk
diff --git a/ghc/interpreter/input.c b/ghc/interpreter/input.c
index 6615e7751be1..c32044f87113 100644
--- a/ghc/interpreter/input.c
+++ b/ghc/interpreter/input.c
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: input.c,v $
- * $Revision: 1.27 $
- * $Date: 2000/04/06 00:36:12 $
+ * $Revision: 1.28 $
+ * $Date: 2000/04/21 18:05:19 $
  * ------------------------------------------------------------------------*/
 
 #include "hugsbasictypes.h"
@@ -31,7 +31,7 @@
 #undef IN
 #endif
 
-#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H && HAVE_READLINE_HISTORY_H
+#if HAVE_READLINE_LIBS && HAVE_READLINE_HEADERS
 #define USE_READLINE 1
 #else
 #define USE_READLINE 0
diff --git a/mk/config.h.in b/mk/config.h.in
index 5506409067f4..c7e4b30c4a1d 100644
--- a/mk/config.h.in
+++ b/mk/config.h.in
@@ -132,6 +132,12 @@
 /* Define if compiler supports prototypes. */
 #define HAVE_PROTOTYPES 0
 
+/* Define if readline/readline.h and readline/history.h exist */
+#undef HAVE_READLINE_HEADERS
+
+/* Define if readline plus any additional libs needed for it exist */
+#undef HAVE_READLINE_LIBS
+
 /* Define if time.h or sys/time.h define the timezone variable */
 #undef HAVE_TIMEZONE
 
@@ -141,9 +147,6 @@
 /* Define if you support the production (and use) of Win32 DLLs. */
 #undef HAVE_WIN32_DLL_SUPPORT
 
-/* Define if you have and want to use readline in Hugs. */
-#undef HAVE_LIBREADLINE
-
 /* Define if C Symbols have a leading underscore added by the compiler */
 #undef LEADING_UNDERSCORE
 
@@ -389,12 +392,6 @@
 /* Define if you have the <pwd.h> header file.  */
 #undef HAVE_PWD_H
 
-/* Define if you have the <readline/history.h> header file.  */
-#undef HAVE_READLINE_HISTORY_H
-
-/* Define if you have the <readline/readline.h> header file.  */
-#undef HAVE_READLINE_READLINE_H
-
 /* Define if you have the <sgtty.h> header file.  */
 #undef HAVE_SGTTY_H
 
@@ -413,6 +410,9 @@
 /* Define if you have the <stdarg.h> header file.  */
 #undef HAVE_STDARG_H
 
+/* Define if you have the <stdint.h> header file.  */
+#undef HAVE_STDINT_H
+
 /* Define if you have the <stdlib.h> header file.  */
 #undef HAVE_STDLIB_H
 
diff --git a/mk/config.mk.in b/mk/config.mk.in
index a20a3b1578b4..a4057ae41f67 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -269,13 +269,15 @@ GhcLibToolsHcOpts=-O
 
 # Build the Haskell Readline bindings?
 #
-GhcLibsWithReadline=NO
-#
+GhcLibsWithReadline=@HaveReadlineHeaders@
+
+# Libraries needed for linking with readline
+LibsReadline=@LibsReadline@
+
 # Include path to readline.h
 # (no path == in standard include path)
 #
 ReadlineIncludePath=
-HaveLibReadline=@HaveLibReadline@
 
 ################################################################################
 #
-- 
GitLab