Subject: Thomas Dickey's color xterm - porting notes.
From: [email-masked] (Andrew Sumner)

4 May 1998 04:02:22 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

Hi all,

Porting of the color xterm to B19.1 requires:-
  * ncurses - download latest version from Thomas Dickey's site, 
  * the xterm source itself (same location - i ported patchlevel 74)
  * the X11R6.3 distribution, binaries available from Sergey
    Okhapkin's site.

I ported using the coolview dll to NT 4.0.

The procedure is somewhat involved - given time it could be made easier.

1.  Build and install ncurses - it compiles smoothly.  Install the
    X11R6.3 distribution.

2.  Unpack the xterm source, and apply the patch at the end of this
    message.

3.  Use the ncurses 'tic' command to install the terminfo file that
comes
    with the xterm distribution into the terminfo database.

4.  Edit /etc/termcap, and append the termcap file from the xterm
distribution.

5.  Back in the xterm directory, run configure.

6.  Build the libXext2.a library.  This is an interface to a function in
    the libXext.dll that libXmu.a needed to call - for some reason the
    function was not present in libXext.a in the X11R6.3 release.

    create Xext2.def containing:-
      EXPORTS
      XShapeCombineMask

    To build the library, type the following command:-

      dlltool --def Xext2.def --output-exp Xext2.exp --output-lib
libXext2.a --dllname libXext.dll

    Add this library to the end of the LIBS variable list, and add -L.
to 
    the X_LIBS variable.  I _know_ this should be done properly in the
    Imakefile, but nevertheless...

7.  Run make.  You may experience a cryptic error compiling button.c - I
    found that turning optimisation back from -O2 to -O fixed this.  The
    xterm _should_ then build and run with no problems.  Install
xterm.exe 
    and resize.exe in place of the existing X11R6.3 executables.

Good Luck - please let me know if any problems.

Btw, I have created a page to which I will be adding ports (binaries &
patches)

Only formative at this stage, it is at
http://www.netmap.com.au/freeStuff/cygwin32

Ciao

Andrew

-----------PATCH BEGINS - CUT HERE------------------
Only in new: confdefs.h
diff -U 3 old/configure new/configure
--- old/configure       Mon May 04 10:25:03 1998
+++ new/configure       Mon May 04 10:41:30 1998
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /Cygnus/B19/H-i386-cygwin32/bin/bash 

 # Guess values for system-dependent variables and create Makefiles.
 # Generated automatically using autoconf version 2.12.971230 
@@ -3481,6 +3481,45 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l${cf_x_athena}_s $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
+#line 3331 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char XawSimpleMenuAddGlobalActions();
+
+int main() {
+XawSimpleMenuAddGlobalActions()
+; return 0; }
+EOF
+if { (eval echo configure:3342: \"$ac_link\") 1>&5; (eval $ac_link)
2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi 
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  LIBS="-l$cf_x_athena $LIBS"
+else
+  echo "$ac_t""no" 1>&6
+  
+echo $ac_n "checking for XawSimpleMenuAddGlobalActions in
-l${cf_x_athena}3d""... $ac_c" 1>&6
+echo "configure:3323: checking for XawSimpleMenuAddGlobalActions in
-l${cf_x_athena}3d" >&5
+ac_lib_var=`echo ${cf_x_athena}3d'_'XawSimpleMenuAddGlobalActions | sed
'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set";
then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-l${cf_x_athena}3d $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat > conftest.$ac_ext <<EOF
 #line 3485 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -3507,10 +3546,11 @@
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  LIBS="-l${cf_x_athena}_s $LIBS"
+  LIBS="-l${cf_x_athena}3d $LIBS"
 else
   echo "$ac_t""no" 1>&6
 { echo "configure: error: Unable to successfully link Athena library
(-l$cf_x_athena) with test program" 1>&2; exit 1; }
+fi
 fi

 fi
diff -U 3 old/main.c new/main.c
--- old/main.c  Mon May 04 10:25:15 1998
+++ new/main.c  Mon May 04 10:35:57 1998
@@ -179,6 +179,14 @@
 #define WTMP
 #endif

+#ifdef __CYGWIN32__
+#define SYSV
+#define SVR4
+#define LASTLOG
+#define WTMP
+#define ATT
+#endif
+
 #ifdef Lynx
 #define USE_SYSV_TERMIO
 #undef  TIOCSLTC
@@ -193,7 +201,17 @@
 #define _SVID3
 #endif

+#ifdef __CYGWIN32__
+#define SYSV
+#define SVR4
+#define LASTLOG
+#define WTMP
+#define ATT
+#endif
+
+#ifndef __CYGWIN32__
 #include <sys/ioctl.h>
+#endif
 #include <sys/stat.h>

 #ifdef Lynx
@@ -367,7 +385,7 @@
 #include <sys/filio.h>
 #endif
-#if defined(SVR4) || defined(SCO325)
+#if (defined(SVR4) || defined(SCO325)) && !defined(__CYGWIN32__)
 #include <utmpx.h>
 #define setutent setutxent
 #define getutent getutxent
@@ -1221,7 +1239,9 @@
        d_tio.c_cc[VEOF] = CEOF;
        d_tio.c_cc[VEOL] = CNUL;
        d_tio.c_cc[VEOL2] = CNUL;
+#ifdef VSWTCH
        d_tio.c_cc[VSWTCH] = CNUL;
+#endif

 #if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */
        d_tio.c_cc[VSUSP] = CSUSP;
@@ -2169,7 +2189,7 @@
 #endif /* sun */
        struct passwd *pw = NULL;
 #ifdef UTMP
-#if defined(SVR4) || defined(SCO325)
+#if (defined(SVR4) || defined(SCO325)) && !defined(__CYGWIN32__)
        struct utmpx utmp;
 #else
        struct utmp utmp;
@@ -3426,7 +3446,7 @@
        /* hung sh problem? */
        signal (SIGHUP, SIG_DFL);
 #else
-       signal (SIGHUP,SIG_IGN);
+       signal (SIGHUP, SIG_IGN);
 #endif

 /*
@@ -4168,6 +4188,16 @@
     long arg;
     ioctl (fd, FIONREAD, (char *) &arg);
     return (int) arg;
+#elif defined(__CYGWIN32__)
+    fd_set set;
+    struct timeval timeout = {0, 0};
+
+    FD_ZERO (&set);
+    FD_SET (fd, &set);
+    if (select (fd+1, &set, NULL, NULL, &timeout) > 0)
+      return 1;+    else
+      return 0;
 #else
 #ifdef MINIX
     /* The answer doesn't have to correct. Calling nbio_isinprogress is
diff -U 3 old/resize.c new/resize.c
--- old/resize.c        Mon May 04 10:25:15 1998
+++ new/resize.c        Mon May 04 10:50:31 1998
@@ -81,7 +81,7 @@
 #define USE_SYSV_UTMP
 #endif

-#if defined(SYSV) || defined(Lynx)
+#if defined(SYSV) || defined(Lynx) || defined(__CYGWIN32__)
 #define USE_SYSV_TERMIO
 #ifndef Lynx
 #define USE_SYSV_UTMP
@@ -104,7 +104,9 @@
 #define USE_TERMIOS
 #endif

+#ifndef __CYGWIN32__
 #include <sys/ioctl.h>
+#endif
 #ifdef USE_SYSV_TERMIO
 # ifndef Lynx
 #  include <sys/termio.h>
@@ -112,11 +114,14 @@
 #  include <termio.h>
 # endif
 #else /* else not USE_SYSV_TERMIO */
+#include <termios.h>
+/*
 # ifdef USE_TERMIOS
 #  include <termios.h>
-# else /* not USE_TERMIOS */
+# else /* not USE_TERMIOS *
 #  include <sgtty.h>
-# endif /* USE_TERMIOS */
+# endif /* USE_TERMIOS *
+*/
 #endif /* USE_SYSV_TERMIO */

 #ifdef USE_USG_PTYS
@@ -259,10 +264,10 @@         * Instead, just use terminfo.
         */
 #undef USE_TERMCAP
-#include <curses.h>
+#include </usr/local/include/curses.h>
 #endif
 #else
-#include <curses.h>
+#include </usr/local/include/curses.h>
 #endif /* HAVE_TERMCAP_H  */
 #endif

diff -U 3 old/screen.c new/screen.c
--- old/screen.c        Mon May 04 10:25:15 1998
+++ new/screen.c        Mon May 04 10:40:27 1998
@@ -44,8 +44,15 @@
 #define SYSV
 #include <termios.h>
 #else
+#ifndef __CYGWIN32__
 #include <sys/ioctl.h>
 #endif
+#endif
+
+#if defined(__CYGWIN32__) && !defined(TIOCSPGRP)
+#include <termios.h>
+#  define TIOCSPGRP (_IOW('t', 118, pid_t))
+#endif

 #ifdef __hpux
 #include <sys/termio.h>
@@ -94,6 +101,9 @@
 static int Reallocate PROTO((ScrnBuf *sbuf, Char **sbufaddr, int nrow,
int ncol, int oldrow, int oldcol));
 static void ScrnClearLines PROTO((TScreen *screen, ScrnBuf sb, int
where, int n, int size));

+#ifdef __CYGWIN32__
+extern XtermWidget term;
+#endif

 ScrnBuf Allocate (nrow, ncol, addr)
 /*
@@ -119,6 +129,7 @@
        register int i, j, k;
        size_t entries = MAX_PTRS * nrow;
        size_t length  = BUF_PTRS * nrow * ncol;+       static char
first_time = 1;

        if ((base = (ScrnBuf) calloc (entries, sizeof (char *))) == 0)
                SysError (ERROR_SCALLOC);
@@ -517,6 +528,9 @@
        int scrollamt = screen->scroll_amt;
        int max = screen->max_row;
        int gc_changes = 0;
+#ifdef __CYGWIN32__
+       static char first_time = 1;
+#endif

        TRACE(("ScrnRefresh (%d,%d) - (%d,%d)%s\n",
                toprow, leftcol,
@@ -720,6 +734,19 @@
            if (gc_changes & BG_COLOR)
                SGR_Background(term->cur_background);
        })
+
+#if defined(__CYGWIN32__) && defined(TIOCSWINSZ)
+       if (first_time == 1)
+       {
+       struct winsize ws;
+               first_time = 0;
+               ws.ws_row = nrows;
+               ws.ws_col = ncols;
+               ws.ws_xpixel = term->core.width;
+               ws.ws_ypixel = term->core.height;
+               ioctl (screen->respond, TIOCSWINSZ, (char *)&ws);
+       }
+#endif
 }

 void
----------PATCH ENDS - CUT HERE---------------
-- 
  "char ((*(*())[])()) is a cast to a function returning a pointer 
   to an array of pointers to functions returning a char."
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".