[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implicit pattern rules do not match files with spaces in their names [re

From: Anthony DeRobertis
Subject: Implicit pattern rules do not match files with spaces in their names [resend]
Date: Tue, 07 Jun 2011 16:35:05 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110510 Icedove/3.1.10

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):

   |address@hidden:/tmp/foo$ make "test"
   cc     test.c   -o test

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

   |address@hidden:/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.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]