www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000127

When Created: 12/18/1996 23:40:50
Against DJGPP version: 2.01
By whom: margaret@tusc.com.au
Abstract: Make 3.75 incorrectly expands pattern rules
Pattern rules in makefile do not seem to be handled correctly by GNU Make 3.75. For example,
a Makefile that looks like this (with files a.sh, b.sh and c.sh in the current directory):

FOO := $(addprefix /temp/,a b c)
$(FOO) : /temp/% : %.sh
        echo "Making $@ from $<"

produces the following rules (produced by running make -p):

/temp/a /temp/b: a.sh b.sh    
#  Implicit rule search has not been done.
#  Implicit/static pattern stem: `a b'
#  File does not exist.
#  File has not been updated.
#  commands to execute (from `makefile.test', line 4):
        echo "Making $@ from $<"

/temp/c: c.sh
#  Implicit rule search has not been done.
#  Implicit/static pattern stem: `c'  
#  Modification time never checked.
#  File has not been updated.
#  commands to execute (from `makefile.test', line 4):
        echo "Making $@ from $<"

and the following error message:
C:/users/margaret/gnu> ./bin/make375 -f makefile.test
.in\make375: *** No rule to make target `a.sh b.sh', needed by `/temp/a /temp/b'.  Stop.

However:
C:/users/margaret/gnu> ./bin/make375 -f makefile.test /temp/c
echo "Making /temp/c from c.sh"
Making /temp/c from c.sh

But:
C:/users/margaret/gnu> ./bin/make375 -f makefile.test /temp/a
.in\make375: *** No rule to make target `/temp/a'.  Stop.  

Is there a patch or a workaround?
Thanks,
Marg

Solution added: 12/19/1996 01:22:24
By whom: margaret@tusc.com.au
I *think* I have solved the problem by fixing some code in read.c, in function
parse_file_seq() (around line 1639 in my source):

Original code:
#ifdef WIN32
      /* For WIN32, skip a "C:\..." or "C:/...". */
      if (stopchar == ':' &&
          p != 0 &&
          (p[1] == '\' || p[1] == '/') &&
          isalpha (p[-1])) {
        p = end_of_token_w32(++p, ':');
        if (*p == '\0' && p[-1] == ':')
          p--;
      }
#endif

I inserted an extra test for "&& p[0] == stopchar", because the previous call
to find_char_unquote() may have been terminated by a blank at p[0].

Marg.

Solution added: 12/29/1996 06:40:26
By whom: eliz@is.elta.co.il
The bug report and its analysis are correct, but the solution is
not.  It patches the code fragment that isn't even compiled for
the DJGPP port of Make, so it couldn't do anything to solve the
problem.

Here's the patch that does solve the bug:

*** gnu/make-3.75/read.c~1      Sat Oct  5 11:21:34 1996
--- gnu/make-3.75/read.c        Fri Dec 27 14:27:48 1996
*************** parse_file_seq (stringp, stopchar, size,
*** 1624,1630 ****
        /* For MS-DOS, skip a "C:\..." or a "C:/..." until we find a
         first colon which isn't followed by a slash or a backslash.  */
        if (stopchar == ':')
!       while (p != 0 && (p[1] == '\' || p[1] == '/') && isalpha (p[-1]))
          p = find_char_unquote (p + 1, stopchars, 1);
  #endif
  #ifdef _AMIGA
--- 1624,1633 ----
        /* For MS-DOS, skip a "C:\..." or a "C:/..." until we find a
         first colon which isn't followed by a slash or a backslash.  */
        if (stopchar == ':')
!       while (p != 0
!              && *p == ':'
!              && (p[1] == '\' || p[1] == '/')
!              && isalpha (p[-1]))
          p = find_char_unquote (p + 1, stopchars, 1);
  #endif
  #ifdef _AMIGA

Fixed in version on 04/13/1999 07:00:46
By whom: eliz@is.elta.co.il



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010