[gnu.utils.bug] make3.27 under sysVr3

wgb@tntdev.tnt.COM (William G. Bunton) (12/25/88)

I've managed to get GNU make 3.27 working under sysVr3 (VP/ix). These
fixes should apply only to sysVr3.

/usr/include/ar.h is set up to support different archive formats. On
this system at least, PORTAR needs to be defined to 1 to select the
proper format (this was done in the makefile). This format terminates
the member names with a '/'; I added code in arscan.c to replace this
slash with a null.

In commands.c, in a number of places members of the "union wait" were
still being referenced, instead of using the macros. Also, the
definitions for WTERMSIG and WCOREDUMP seem to differ from the manual
entry for wait(2). In child_handler, for USG pid was never being set
from the wait call.

Also in commands.c, if SIG_CLD is set to SIG_IGN, wait(2) will always
return -1 with errno set to ECHILD. Since the default is to ignore the
signal, in wait_for_children I changed SIG_IGN to SIG_DFL.

In Makefile, I added the needed defines (including PORTAR), and set
LOADLIBES to use the shared library.

*** ../make-3.27/arscan.c	Mon Dec 12 17:37:26 1988
--- arscan.c	Sat Dec 24 14:37:05 1988
***************
*** 222,227 ****
--- 222,231 ----
  	{
  	  register char *p = name + sizeof member_header.ar_name;
  	  while (p > name && *--p == ' ') *p = 0;
+ #if PORTAR
+ 	  if (*p == '/')
+ 	    *p = 0;
+ #endif
  	}
  
  	sscanf (member_header.ar_mode, "%o", &eltmode);
*** ../make-3.27/commands.c	Mon Dec 12 17:37:09 1988
--- commands.c	Sat Dec 24 14:47:57 1988
***************
*** 22,29 ****
  #ifdef	USG
  
  #define WAIT_T int
! #define WTERMSIG(x) ((x) & 0xf7)
! #define WCOREDUMP(x) ((x) & 0x01)
  #define WRETCODE(x) ((x) & (0xff >> 8))
  #define WIFSIGNALED(x) (WTERMSIG (x) != 0)
  #define WIFEXITED(x) (WTERMSIG (x) == 0)
--- 22,29 ----
  #ifdef	USG
  
  #define WAIT_T int
! #define WTERMSIG(x) ((x) & 0x7f)
! #define WCOREDUMP(x) ((x) & 0200)
  #define WRETCODE(x) ((x) & (0xff >> 8))
  #define WIFSIGNALED(x) (WTERMSIG (x) != 0)
  #define WIFEXITED(x) (WTERMSIG (x) == 0)
***************
*** 151,157 ****
    if (children == 0 && shell_function_pid <= 0)
      return 0;
  
!   while (wait (&status) > 0)
  #else	/* not USG	*/
    while ((sig <= 0
  	  ? (pid = wait (&status))
--- 151,157 ----
    if (children == 0 && shell_function_pid <= 0)
      return 0;
  
!   while ((pid = wait (&status)) > 0)
  #else	/* not USG	*/
    while ((sig <= 0
  	  ? (pid = wait (&status))
***************
*** 165,171 ****
        if (pid == shell_function_pid)
  	{
  	  shell_function_pid
! 	    = (WIFEXITED (status) && status.w_retcode == 127) ? -1 : 0;
  
  	  if (sig < 0 && ++dead_children > -sig)
  	    return 0;
--- 165,171 ----
        if (pid == shell_function_pid)
  	{
  	  shell_function_pid
! 	    = (WIFEXITED (status) && WRETCODE(status) == 127) ? -1 : 0;
  
  	  if (sig < 0 && ++dead_children > -sig)
  	    return 0;
***************
*** 180,196 ****
  	    char buf[100];
  
  	    if (WIFEXITED (status))
! 	      if (status.w_retcode != 0)
! 		sprintf (buf, "*** Error %d", status.w_retcode);
  	      else
  		buf[0] = '\0';
  	    else if (WIFSIGNALED (status))
  	      {
! 		char *cd = status.w_coredump ? " (core dumped)" : "";
! 		if (status.w_termsig > 0 && status.w_termsig < NSIG)
! 		  sprintf (buf, "*** %s%s", sys_siglist[status.w_termsig], cd);
  		else
! 		  sprintf (buf, "*** Signal %d%s", status.w_termsig, cd);
  	      }
  	    else
  	      strcpy (buf, "*** Strange Error");
--- 180,196 ----
  	    char buf[100];
  
  	    if (WIFEXITED (status))
! 	      if (WRETCODE (status) != 0)
! 		sprintf (buf, "*** Error %d", WRETCODE (status));
  	      else
  		buf[0] = '\0';
  	    else if (WIFSIGNALED (status))
  	      {
! 		char *cd = WCOREDUMP (status) ? " (core dumped)" : "";
! 		if (WTERMSIG (status) > 0 && WTERMSIG (status) < NSIG)
! 		  sprintf (buf, "*** %s%s", sys_siglist[WTERMSIG(status)], cd);
  		else
! 		  sprintf (buf, "*** Signal %d%s", WTERMSIG (status), cd);
  	      }
  	    else
  	      strcpy (buf, "*** Strange Error");
***************
*** 302,308 ****
--- 302,312 ----
  #ifdef SIGCHLD
    (void) signal (SIGCHLD, SIG_IGN);
  #else
+ #ifdef USG
+   (void) signal (SIGCLD, SIG_DFL);
+ #else /* not USG does this every apply? */
    (void) signal (SIGCLD, SIG_IGN);
+ #endif
  #endif
  
    /* Call child_handler to do the work.  */
*** ../make-3.27/Makefile	Sat Dec 10 00:15:46 1988
--- Makefile	Sat Dec 24 14:44:31 1988
***************
*** 22,31 ****
  # add `-DNO_MINUS_C_MINUS_O' to CFLAGS.
  
  CC = gcc
! CFLAGS = -g -O
  LDFLAGS = -g
  
! bindir = $(prefix)/usr/local/bin
  
  objs = arscan.o glob.o ar.o commands.o dir.o file.o make.o	\
         read.o remake.o rule.o variable.o vpath.o version.o
--- 22,32 ----
  # add `-DNO_MINUS_C_MINUS_O' to CFLAGS.
  
  CC = gcc
! CFLAGS = -g -O -DNO_MINUS_C_MINUS_O -DUSG -DUSGr3 -DPORTAR=1
  LDFLAGS = -g
+ LOADLIBES=-lPW -lc_s
  
! bindir = $(prefix)/usr/lbin
  
  objs = arscan.o glob.o ar.o commands.o dir.o file.o make.o	\
         read.o remake.o rule.o variable.o vpath.o version.o
***************
*** 37,43 ****
  .PHONY: all
  all: make make.info make.dvi
  
- 
  # Take your pick.
  #makeinfo = emacs -batch make.texinfo -f texinfo-format-buffer -f save-buffer
  makeinfo = makeinfo make.texinfo
--- 38,43 ----
***************
*** 44,50 ****
  
  make.info: make.texinfo
  	$(makeinfo)
- 
  
  make.dvi: make.texinfo
  	-tex make.texinfo
--- 44,49 ----



--
William G. Bunton            wgb@tntdev.tnt.com     {uunet,natinst}!tntdev!wgb
Tools & Techniques, Inc. Austin, TX