Thanks Bake,
[copied to Ralf Hinze in case it helps him]

I'd swapped the termios code with the sgtty code to work round
a problem on Sunos4.  I'm now deleting the line that #includes
<sys/ioctl.h> and restoring the original order of arguments.
This works on Linux (Kernel 2.0.18, Redhat 4.0?), Solaris 5.4
and Sunos 4.1.2.  I can't test it on anything else locally.

Here's the patch:

Index: machdep.c
===================================================================
RCS file: /net/haskell/homes/systems/hcompile/CVS/hugs/src/machdep.c,v
retrieving revision 1.57
diff -C2 -r1.57 machdep.c
*** machdep.c   1997/11/03 01:15:08     1.57
--- machdep.c   1997/11/04 20:11:50
***************
*** 36,42 ****
  # include <time.h>
  #endif
- #if HAVE_SYS_IOCTL_H
- # include <sys/ioctl.h>
- #endif
  
  /* Windows/DOS include files */
--- 36,39 ----
***************
*** 603,619 ****
  #if (HAVE_TERMIO_H | HAVE_SGTTY_H | HAVE_TERMIOS_H)
  
! #if HAVE_SGTTY_H
! 
! #include <sgtty.h>
! typedef  struct sgttyb   TermParams;
! #define  getTerminal(tp) ioctl(fileno(stdin),TIOCGETP,&tp)
! #define  setTerminal(tp) ioctl(fileno(stdin),TIOCSETP,&tp)
! #if HPUX
! #define  noEcho(tp)      tp.sg_flags |= RAW; tp.sg_flags &= (~ECHO);
! #else
! #define  noEcho(tp)      tp.sg_flags |= CBREAK; tp.sg_flags &= (~ECHO);
  #endif
  
! #elif HAVE_TERMIOS_H
  
  #include <termios.h>
--- 600,627 ----
  #if (HAVE_TERMIO_H | HAVE_SGTTY_H | HAVE_TERMIOS_H)
  
! /* This is believed to be redundant! ADR */
! #if 0 && HAVE_SYS_IOCTL_H
! # include <sys/ioctl.h>
  #endif
  
! /* The order of these three tests is very important because
!  * some systems have more than one of the requisite header file
!  * but only one of them seems to work.
!  * Anyone changing the order of the tests should try enabling each of the
!  * three branches in turn and write down which ones work as well as which
!  * OS/compiler they're using.
!  *
!  * OS            Compiler      sgtty     termio  termios   notes
!  * Linux 2.0.18  gcc 2.7.2     absent    works   works     1
!  *
!  * Notes:
!  * 1) On Linux, termio.h just #includes termios.h and sgtty.h is
!  *    implemented using termios.h.
!  *    sgtty.h is in /usr/include/bsd which is not on my standard include
!  *    path.  Adding it does no harm but you might as well use termios.
!  *    --
!  *    [EMAIL PROTECTED]
!  */
! #if HAVE_TERMIOS_H
  
  #include <termios.h>
***************
*** 625,628 ****
--- 633,648 ----
                           tp.c_cc[VTIME] = 0;
  
+ #elif HAVE_SGTTY_H
+ 
+ #include <sgtty.h>
+ typedef  struct sgttyb   TermParams;
+ #define  getTerminal(tp) ioctl(fileno(stdin),TIOCGETP,&tp)
+ #define  setTerminal(tp) ioctl(fileno(stdin),TIOCSETP,&tp)
+ #if HPUX
+ #define  noEcho(tp)      tp.sg_flags |= RAW; tp.sg_flags &= (~ECHO);
+ #else
+ #define  noEcho(tp)      tp.sg_flags |= CBREAK; tp.sg_flags &= (~ECHO);
+ #endif
+ 
  #elif HAVE_TERMIO_H
  
> I've always been able to compile Hugs on Linux successfully until the
> Hugs971102 snapshot.  Here's the problem:
> 
> gcc -c -g -O   hugs.c
> machdep.c: In function `normalTerminal':
> In file included from hugs.c:81:
> machdep.c:644: `TIOCSETP' undeclared (first use this function)
> machdep.c:644: (Each undeclared identifier is reported only once
> machdep.c:644: for each function it appears in.)
> machdep.c: In function `noechoTerminal':
> machdep.c:648: storage size of `settings' isn't known
> machdep.c:651: `TIOCGETP' undeclared (first use this function)
> machdep.c:655: `CBREAK' undeclared (first use this function)
> machdep.c:655: `ECHO' undeclared (first use this function)
> machdep.c:656: `TIOCSETP' undeclared (first use this function)
> machdep.c: At top level:
> machdep.c:640: storage size of `originalSettings' isn't known
> make: *** [hugs.o] Error 1
> 
> Not sure if this is the best fix, but here goes:
> 
> diff -u machdep.c.orig machdep.c
> --- machdep.c.orig      Mon Nov  3 12:45:20 1997
> +++ machdep.c   Mon Nov  3 12:43:43 1997
> @@ -602,7 +602,7 @@
> 
>  #if (HAVE_TERMIO_H | HAVE_SGTTY_H | HAVE_TERMIOS_H)
> 
> -#if HAVE_SGTTY_H
> +#if (HAVE_SGTTY_H & !HAVE_TERMIOS_H)
> 
>  #include <sgtty.h>
>  typedef  struct sgttyb   TermParams;
> 
> 
> 


Reply via email to