This is with GNU Make 3.81. I originally posted this as a question on Stack Overflow, http://stackoverflow.com/questions/6233574/

According to the docs (10.5.1), % in a pattern rule matches "any nonempty substring". But it seems to actually match some subset of that, in particular, ones that does not contain spaces.

Say, you set up a source directory:

   |mkdir /tmp/foo
   cd /tmp/foo
   echo 'int main() { return 0; }'>  "test.c"
   echo 'int main() { return 0; }'>  "test space.c"
   |

Then build test (using the built-in pattern rule for making an executable from a C source file):

   |anthony@Zia:/tmp/foo$ make "test"
   cc     test.c   -o test
   |

As expected, that works, but when you try it on the other file:

   |anthony@Zia:/tmp/foo$ make "test space"
   make: *** No rule to make target `test space'.  Stop.
   |

This holds even if you write it into a makefile (making sure to escape the space, e.g., all: test test\ space), even if you explicitly add your own %: %.c rule, etc.

You can get it to build it, by adding an "expanded" version of the pattern match rule:

   |test\ space: test\ space.c
        $(CC) -o "$@" "$<"     # first char is tab, of course.|


(First time I send this message, it vanished into the ether; no bounceback nor did it appear in the archive. Trying again.)

_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to