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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: rf13@xxxxxxxxxxxxxxxxxxxxxx, Per.Inge.Mathisen@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Building freeciv
From: Davide Pagnin <nightmare@xxxxxxxxxx>
Date: Sat, 18 May 2002 20:28:30 +0200

        Hi All!

Per wrote:
>I've reworked the patches so that they work also with autoconf 2.52, and
>moved readline detection to m4/readline.m4 so that configure.[in|ac] can
>share this code. Seems to work. It would be very nice if you could test
>this patch on the platforms you mentioned.
>
>Patch attached.

And After, Raimar wrote:
>Great work to you Davide and Per. Now freeciv supports readline
>(4.1-5) in my computer.
>
>Changes:
> - updated INSTALL
> - changed ifndef to ifdef
>
>Per: can you apply it? I don't know what to write expect "readline
>detection cleanup".

I've taken the last patch from Raimar, and applied to a clean 1.12.2
beta,
and tried to compile on Compaq Tru64 Unix on alpha.

The patch correctly recognize the presence of readline in the old style
(readline 4.1) and moreover the game compile and run correctly.

But, after a second thought, I've found a behaviour that perhaps is
considered indesiderable, I'll try to explain by an example:

Old configure script:

1) check for readline.h
2) check for rl_completion_matches compiles
3) if rl_completion_mathes where not found
then
4) check for initscr presence in termlib
5) check for initscr presence in termcap
6) check for initscr presence in curses
7) check for initscr presence in ncurses
8) check for rl_filename_completion_function + HAVE_TERMCAP compiles
endif
9) if either 2 or 8 where true, set HAVEREADLINE
10) if HAVEREADLINE try to compile and run a sample

New configure script:
1) check for readline.h
2) check for completion_matches compiles
3) if completion_mathes where not found
then
4) check for initscr presence in termlib
5) check for initscr presence in termcap
6) check for initscr presence in curses
7) check for initscr presence in ncurses
8) check for filename_completion_function + HAVE_TERMCAP compiles
endif
9) check for rl_completion_matches compiles
10) if rl_completion_mathes where not found
then
11) check for rl_filename_completion_function + HAVE_TERMCAP compiles
endif
12) if either 2 or 8 where true, set HAVEREADLINE
13) if either 10 or 12 where true set HAVENEWREADLINE and HAVEREADLINE
14) if HAVEREADLINE try to compile and run a sample

Perhaps, in not completely correct, but it is more o less like this way.

Now, I want to point your attention to a sideeffect of this change,
If both completion_matches is not present, the test tries to compile
the filenanem_completion_function plus another library, thus setting
the variable HAVE_TERMCAP, afterwords, it tries to compile 
rl_completion_matches and even if it is able to compile without
other libraries, HAVE_TERMCAP is already set and will be used
in the makefile. (Well, I've not tested this effect but it seems
reasonable to me that this will happen!)

All of this to say that I've reworked Raimar patch and this potential
problem is addressed.

        Ciao, Davide.

P.S. The new patch works correctly with Tru64.

P.S.2. To test this on others platform, It will require more time,
I can work only in spare time...
diff -urN -Xfreeciv.orig/diff_ignore freeciv.orig/INSTALL freeciv-1.12.2/INSTALL
--- freeciv.orig/INSTALL        Fri May 17 15:44:13 2002
+++ freeciv-1.12.2/INSTALL      Sat May 18 18:11:31 2002
@@ -420,7 +420,6 @@
 installed. If so it will automatically set up the makefiles so that readline
 is compiled into the server. If not then it will just silently configure
 without readline support.
-You need readline version >= 4.2.
 You can force configure to include readline or die trying by giving
 configure the --with-readline option:
 
@@ -434,14 +433,6 @@
 to make readline work. This should be harmless, and is just meant as
 a reminder to the folks who distribute readline. :)
 
-It is possible to make freeciv work with versions of readline earlier
-than 4.2 (but not with 4.2). To do this replace
-"rl_filename_completion_function" with "filename_completion_function" and
-"rl_completion_matches" with "completion_matches" in configure.in and
-server/stdinhand.c, and remove the const modifier from the first arg of
-server/stdinhand.c:freeciv_completion(). Then run autoconf and rebuild.
-
-
 7. Reinier's Solaris Installation Notes:
 ========================================
 
@@ -566,7 +557,7 @@
  Common requirements:
    gcc
    libc6-dev
-   libreadline4-dev >= 4.2 (optional, see readline section)
+   libreadline4-dev
    zlib1g-dev
    xlib6g-dev
 
diff -urN -Xfreeciv.orig/diff_ignore freeciv.orig/acconfig.h 
freeciv-1.12.2/acconfig.h
--- freeciv.orig/acconfig.h     Fri May 17 15:44:13 2002
+++ freeciv-1.12.2/acconfig.h   Sat May 18 18:11:31 2002
@@ -47,6 +47,7 @@
 #undef FUNCPROTO
 #undef NARROWPROTO
 #undef HAVE_LIBREADLINE
+#undef HAVE_NEWLIBREADLINE
 #undef NONBLOCKING_SOCKETS
 #undef HAVE_FCNTL
 #undef HAVE_IOCTL
diff -urN -Xfreeciv.orig/diff_ignore freeciv.orig/configure.ac 
freeciv-1.12.2/configure.ac
--- freeciv.orig/configure.ac   Fri May 17 16:28:23 2002
+++ freeciv-1.12.2/configure.ac Sat May 18 18:14:58 2002
@@ -555,77 +555,8 @@
     fi
 
     dnl Readline library and header files.
-    if test "$WITH_READLINE" = "yes" || test "$WITH_READLINE" = "maybe"; then
-       HAVE_TERMCAP="";
-       dnl Readline header
-       AC_CHECK_HEADER(readline/readline.h,
-                       have_readline_header=1,
-                       have_readline_header=0)
-       if test "$have_readline_header" = "0"; then
-           if test "$WITH_READLINE" = "yes"; then
-               AC_MSG_ERROR(Did not find readline header file. 
-You may need to install a readline \"development\" package.)
-           else
-               AC_MSG_WARN(Did not find readline header file. 
-Configuring server without readline support.)
-           fi
-       else
-           dnl Readline lib
-           AC_CHECK_LIB(readline, rl_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 We give them a hand by trying to guess what might be needed.
-               dnl
-               dnl Some older Unices may need both -lcurses and -ltermlib,
-               dnl but we don't support that just yet....
+    FC_HAS_READLINE()
 
-               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")
-
-               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_readline_lib=1, have_readline_lib=0,
-                        "$HAVE_TERMCAP")
-                   if test "$have_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_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, 1, [Readline support])
-               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
-               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
     AC_CHECK_FUNC(pow)
     if test $ac_cv_func_pow = no; then
         AC_CHECK_LIB(m, pow, SERVER_LIBS="$SERVER_LIBS -lm",
diff -urN -Xfreeciv.orig/diff_ignore freeciv.orig/configure.in 
freeciv-1.12.2/configure.in
--- freeciv.orig/configure.in   Fri May 17 16:28:11 2002
+++ freeciv-1.12.2/configure.in Sat May 18 18:15:45 2002
@@ -549,77 +549,8 @@
     fi
 
     dnl Readline library and header files.
-    if test "$WITH_READLINE" = "yes" || test "$WITH_READLINE" = "maybe"; then
-       HAVE_TERMCAP="";
-       dnl Readline header
-       AC_CHECK_HEADER(readline/readline.h,
-                       have_readline_header=1,
-                       have_readline_header=0)
-       if test "$have_readline_header" = "0"; then
-           if test "$WITH_READLINE" = "yes"; then
-               AC_MSG_ERROR(Did not find readline header file. 
-You may need to install a readline \"development\" package.)
-           else
-               AC_MSG_WARN(Did not find readline header file. 
-Configuring server without readline support.)
-           fi
-       else
-           dnl Readline lib
-           AC_CHECK_LIB(readline, rl_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 We give them a hand by trying to guess what might be needed.
-               dnl
-               dnl Some older Unices may need both -lcurses and -ltermlib,
-               dnl but we don't support that just yet....
+    FC_HAS_READLINE()
 
-               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")
-
-               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_readline_lib=1, have_readline_lib=0,
-                        "$HAVE_TERMCAP")
-                   if test "$have_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_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
-               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
     AC_CHECK_FUNC(pow)
     if test $ac_cv_func_pow = no; then
         AC_CHECK_LIB(m, pow, SERVER_LIBS="$SERVER_LIBS -lm",
diff -urN -Xfreeciv.orig/diff_ignore freeciv.orig/m4/readline.m4 
freeciv-1.12.2/m4/readline.m4
--- freeciv.orig/m4/readline.m4 Fri May 17 15:44:13 2002
+++ freeciv-1.12.2/m4/readline.m4       Sat May 18 19:55:05 2002
@@ -57,3 +57,109 @@
 LIBS="$templibs"
 ])
 
+AC_DEFUN([FC_HAS_READLINE],
+[
+    dnl Readline library and header files.
+    if test "$WITH_READLINE" = "yes" || test "$WITH_READLINE" = "maybe"; then
+       HAVE_TERMCAP="";
+       dnl Readline header
+       AC_CHECK_HEADER(readline/readline.h,
+                       have_readline_header=1,
+                       have_readline_header=0)
+       if test "$have_readline_header" = "0"; then
+           if test "$WITH_READLINE" = "yes"; then
+               AC_MSG_ERROR(Did not find readline header file. 
+You may need to install a readline \"development\" package.)
+           else
+               AC_MSG_WARN(Did not find readline header file. 
+Configuring server without readline support.)
+           fi
+       else
+           dnl Readline lib
+           AC_CHECK_LIB(readline, completion_matches, 
+                         have_readline_lib=1, have_readline_lib=0)
+           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_readline_lib" != "1" && test 
"$have_new_readline_lib" != "1"; then
+               dnl Many readline installations are broken in that they
+               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,
+               dnl but we don't support that just yet....
+
+               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 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, filename_completion_function,
+                         have_readline_lib=1, have_readline_lib=0,
+                        "$HAVE_TERMCAP")
+                   if test "$have_readline_lib" = "1"; then
+                       AC_MSG_WARN(I had to manually add $HAVE_TERMCAP 
dependency to 
+make readline library pass the test.)
+                   fi
+                   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_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, 1, [Readline support])
+                   AC_DEFINE_UNQUOTED(HAVE_NEWLIBREADLINE, 1, [Modern 
readline])
+               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
+               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, 1, [Readline 
support])
+                   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
+                   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
+    fi
+])
diff -urN -Xfreeciv.orig/diff_ignore freeciv.orig/server/stdinhand.c 
freeciv-1.12.2/server/stdinhand.c
--- freeciv.orig/server/stdinhand.c     Fri May 17 15:44:13 2002
+++ freeciv-1.12.2/server/stdinhand.c   Sat May 18 19:25:52 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"
@@ -3880,31 +3884,35 @@
 in case we want to do some simple parsing.  Return the array of matches,
 or NULL if there aren't any.
 **************************************************************************/
+#ifdef HAVE_NEWLIBREADLINE
 char **freeciv_completion(const char *text, int start, int end)
+#else
+char **freeciv_completion(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.orig/diff_ignore freeciv.orig/server/stdinhand.h 
freeciv-1.12.2/server/stdinhand.h
--- freeciv.orig/server/stdinhand.h     Fri May 17 15:44:13 2002
+++ freeciv-1.12.2/server/stdinhand.h   Sat May 18 18:11:31 2002
@@ -38,7 +38,11 @@
 void notify_if_first_access_level_is_available(void);
 
 #ifdef HAVE_LIBREADLINE
+#ifdef HAVE_NEWLIBREADLINE
 char **freeciv_completion(const char *text, int start, int end);
+#else
+char **freeciv_completion(char *text, int start, int end);
+#endif
 #endif
 
 #endif /* FC__STDINHAND_H */

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