Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2002:
[Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Buildingfreeciv
Home

[Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Buildingfreeciv

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: Per.Inge.Mathisen@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Buildingfreeciv
From: Davide Pagnin <nightmare@xxxxxxxxxx>
Date: Wed, 15 May 2002 02:19:11 +0200

        Hi Per!

>Davide, can you please try to make a patch for configure that fixes this
>for you? I know readline and friends so badly (ie not at all), that for me
>to make a patch that fixes this for you is going to be very time consuming
>for both of us (since I will have to learn the problem and you will have
>to test it until it works for you).

Yes, I can... (I managed to write the whole patch, the decision is up to
you)

I've attached 4 patch file to this mail

tgetent.diff is the patch you asked me to write, infact substituting the
probe for initscr with the probe with tgetent, all goes well.
(I've managed to test the same patch with RH 7.2 for i386 and it works,
I've also downloaded the source file from GNU of readline 2.0, 2.1, 2.2,
4.0, 4.1 and 4.2, and there where no instances of initscr, insted in
the configure of readline the test are done against getent, so I hope
that this fix is safe)

acconfig.diff
configure.diff
newread.diff
This is a proof of concept patch, with this patch the old readline
library
compile well and also the new readline compile well.
I've chosen to implement this, adding a new define in acconfig.h
HAVE_NEWREADLINE, and making the appropriate tests into configure.in
(I hope to have done a good job, but it is my first hacking on configure
scripts, so be careful where reviewing this).
At the end I've patched server/stdinhand.h and server/stdinhand.c,
adding the necessary nested #ifdef and #ifndef and by creating a
macro to do the substitution of rl_completion_matches for us.

With all 4 patches applied, both RH 7.2 on i386 and Tru64 Unix 5.1A on
Alpha,
are happy and compile.

>
>Yours,
>Per

        Ciao, Davide.

P.S. With some effort and time, I can compile (or try to compile)
freeciv,
on this set of os/architecture.

Tru64 Unix 5.1A - Alpha
Linux Redhat 7.1 - Alpha
FreeBSD 4.5 - Alpha
OpenVMS 7.2-1 - Alpha
(for testing on this, I need advice on how MMK work)

FreeBSD 4.5 - i386
Linux Redhat 7.2 - i386
Linux Redhat 6.2 - i386
Linux Mandrake 8.1 - i386
Linux Mandrake 7.2 - i386
Linux Suse 7.3 - i386
Linux Debian 2.2 - i386
Windows 2000 Professional/cygwin - i386
(for testing on this I need help, I never used cygwin)
--- freeciv.orig/configure.in   Thu May  2 08:21:04 2002
+++ freeciv/configure.in        Tue May 14 23:42:42 2002
@@ -575,10 +575,10 @@
                dnl Some older Unices may need both -lcurses and -ltermlib,
                dnl but we don't support that just yet....
 
-               AC_CHECK_LIB(termlib, initscr, HAVE_TERMCAP="-ltermlib")
-               AC_CHECK_LIB(termcap, initscr, HAVE_TERMCAP="-ltermcap")
-               AC_CHECK_LIB(curses, initscr, HAVE_TERMCAP="-lcurses")
-               AC_CHECK_LIB(ncurses, initscr, HAVE_TERMCAP="-lncurses")
+               AC_CHECK_LIB(termlib, tgetent, HAVE_TERMCAP="-ltermlib")
+               AC_CHECK_LIB(termcap, tgetent, HAVE_TERMCAP="-ltermcap")
+               AC_CHECK_LIB(curses, tgetent, HAVE_TERMCAP="-lcurses")
+               AC_CHECK_LIB(ncurses, tgetent, HAVE_TERMCAP="-lncurses")
 
                if test x"$HAVE_TERMCAP" != "x"; then
                    dnl We can't check for rl_completion_matches() again,
diff -urN -Xfreeciv/diff_ignore freeciv/server/stdinhand.c 
freeciv.patched/server/stdinhand.c
--- freeciv/server/stdinhand.c  Wed May 15 03:39:24 2002
+++ freeciv.patched/server/stdinhand.c  Wed May 15 03:34:28 2002
@@ -23,6 +23,10 @@
 
 #ifdef HAVE_LIBREADLINE
 #include <readline/readline.h>
+#ifdef HAVE_NEWLIBREADLINE
+#define completion_matches(x,y) rl_completion_matches(x,y)
+#define filename_completion_function rl_filename_completion_function
+#endif
 #endif
 
 #include "astring.h"
@@ -3878,31 +3882,35 @@
 in case we want to do some simple parsing.  Return the array of matches,
 or NULL if there aren't any.
 **************************************************************************/
+#ifndef HAVE_NEWLIBREADLINE
+char **freeciv_completion(char *text, int start, int end)
+#else
 char **freeciv_completion(const char *text, int start, int end)
+#endif
 {
   char **matches = (char **)NULL;
 
   if (is_help(start)) {
-    matches = rl_completion_matches(text, help_generator);
+    matches = completion_matches(text, help_generator);
   } else if (is_command(start)) {
-    matches = rl_completion_matches(text, command_generator);
+    matches = completion_matches(text, command_generator);
   } else if (is_rulesout(start)) {
-    matches = rl_completion_matches(text, rulesout_generator);
+    matches = completion_matches(text, rulesout_generator);
   } else if (is_list(start)) {
-    matches = rl_completion_matches(text, list_generator);
+    matches = completion_matches(text, list_generator);
   } else if (is_cmdlevel_arg2(start)) {
-    matches = rl_completion_matches(text, cmdlevel_arg2_generator);
+    matches = completion_matches(text, cmdlevel_arg2_generator);
   } else if (is_cmdlevel_arg1(start)) {
-    matches = rl_completion_matches(text, cmdlevel_arg1_generator);
+    matches = completion_matches(text, cmdlevel_arg1_generator);
   } else if (is_connection(start)) {
-    matches = rl_completion_matches(text, connection_generator);
+    matches = completion_matches(text, connection_generator);
   } else if (is_player(start)) {
-    matches = rl_completion_matches(text, player_generator);
+    matches = completion_matches(text, player_generator);
   } else if (is_server_option(start)) {
-    matches = rl_completion_matches(text, option_generator);
+    matches = completion_matches(text, option_generator);
   } else if (is_filename(start)) {
     /* This function we get from readline */
-    matches = rl_completion_matches(text, rl_filename_completion_function);
+    matches = completion_matches(text, filename_completion_function);
   } else /* We have no idea what to do */
     matches = NULL;
 
diff -urN -Xfreeciv/diff_ignore freeciv/server/stdinhand.h 
freeciv.patched/server/stdinhand.h
--- freeciv/server/stdinhand.h  Wed May 15 03:39:24 2002
+++ freeciv.patched/server/stdinhand.h  Wed May 15 03:34:52 2002
@@ -38,7 +38,11 @@
 void notify_if_first_access_level_is_available(void);
 
 #ifdef HAVE_LIBREADLINE
+#ifndef HAVE_NEWLIBREADLINE
+char **freeciv_completion(char *text, int start, int end);
+#else
 char **freeciv_completion(const char *text, int start, int end);
 #endif
+#endif
 
 #endif /* FC__STDINHAND_H */
--- freeciv/configure.in        Tue May 14 23:42:42 2002
+++ freeciv/configure.in.new    Wed May 15 00:26:36 2002
@@ -565,11 +565,11 @@
            fi
        else
            dnl Readline lib
-           AC_CHECK_LIB(readline, rl_completion_matches, 
+           AC_CHECK_LIB(readline, completion_matches, 
                          have_readline_lib=1, have_readline_lib=0)
            if test "$have_readline_lib" = "0"; then
                dnl Many readline installations are broken in that they
-               dnl don't set the dependesy on the curses lib up correctly.
+               dnl don't set the dependency on the curses lib up correctly.
                dnl We give them a hand by trying to guess what might be needed.
                dnl
                dnl Some older Unices may need both -lcurses and -ltermlib,
@@ -581,10 +581,10 @@
                AC_CHECK_LIB(ncurses, tgetent, HAVE_TERMCAP="-lncurses")
 
                if test x"$HAVE_TERMCAP" != "x"; then
-                   dnl We can't check for rl_completion_matches() again,
+                   dnl We can't check for completion_matches() again,
                    dnl cause the result is cached. And autoconf doesn't
                    dnl seem to have a way to uncache it.
-                   AC_CHECK_LIB(readline, rl_filename_completion_function,
+                   AC_CHECK_LIB(readline, filename_completion_function,
                          have_readline_lib=1, have_readline_lib=0,
                         "$HAVE_TERMCAP")
                    if test "$have_readline_lib" = "1"; then
@@ -594,12 +594,31 @@
                fi
            fi
 
-           if test "$have_readline_lib" = "1"; then
+           dnl Readline lib >= 4.2
+           AC_CHECK_LIB(readline, rl_completion_matches, 
+                         have_new_readline_lib=1, have_new_readline_lib=0)
+           if test "$have_new_readline_lib" = "0"; then
+               if test x"$HAVE_TERMCAP" != "x"; then
+                   dnl We can't check for rl_completion_matches() again,
+                   dnl cause the result is cached. And autoconf doesn't
+                   dnl seem to have a way to uncache it.
+                   AC_CHECK_LIB(readline, rl_filename_completion_function,
+                         have_new_readline_lib=1, have_new_readline_lib=0,
+                        "$HAVE_TERMCAP")
+                   if test "$have_new_readline_lib" = "1"; then
+                       AC_MSG_WARN(I had to manually add $HAVE_TERMCAP 
dependency to 
+make readline library pass the test.)
+                   fi
+               fi
+           fi
+
+           if test "$have_new_readline_lib" = "1"; then
                FC_CHECK_READLINE_RUNTIME($HAVE_TERMCAP,
-                         have_readline_lib=1, have_readline_lib=0)
-               if test "$have_readline_lib" = "1"; then
+                         have_new_readline_lib=1, have_new_readline_lib=0)
+               if test "$have_new_readline_lib" = "1"; then
                    SERVER_LIBS="-lreadline $SERVER_LIBS $HAVE_TERMCAP"
                    AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE)
+                   AC_DEFINE_UNQUOTED(HAVE_NEWLIBREADLINE)
                else
                    if test "$WITH_READLINE" = "yes"; then
                        AC_MSG_ERROR(Specified --with-readline but the 
@@ -610,12 +629,29 @@
                    fi
                fi
            else
-               if test "$WITH_READLINE" = "yes"; then
-                   AC_MSG_ERROR(Specified --with-readline but the 
-test to link against the library failed.)
+               if test "$have_readline_lib" = "1"; then
+                   FC_CHECK_READLINE_RUNTIME($HAVE_TERMCAP,
+                       have_readline_lib=1, have_readline_lib=0)
+                   if test "$have_readline_lib" = "1"; then
+                       SERVER_LIBS="-lreadline $SERVER_LIBS $HAVE_TERMCAP"
+                       AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE)
+                   else
+                       if test "$WITH_READLINE" = "yes"; then
+                           AC_MSG_ERROR(Specified --with-readline but the 
+runtime test of readline failed.)
+                       else
+                           AC_MSG_WARN(Runtime test of readline failed. 
+Configuring server without readline support.)
+                       fi
+                   fi
                else
-                   AC_MSG_WARN(Test to link against readline library failed. 
+                   if test "$WITH_READLINE" = "yes"; then
+                       AC_MSG_ERROR(Specified --with-readline but the 
+test to link against the library failed.)
+                   else
+                       AC_MSG_WARN(Test to link against readline library 
failed. 
 Configuring server without readline support.)
+                   fi
                fi
            fi
        fi
--- ../freeciv.orig/acconfig.h  Fri Apr 26 08:14:30 2002
+++ ./acconfig.h        Wed May 15 00:28:25 2002
@@ -47,6 +47,7 @@
 #undef FUNCPROTO
 #undef NARROWPROTO
 #undef HAVE_LIBREADLINE
+#undef HAVE_NEWLIBREADLINE
 #undef NONBLOCKING_SOCKETS
 #undef HAVE_FCNTL
 #undef HAVE_IOCTL

[Prev in Thread] Current Thread [Next in Thread]