11/07/2009

GNU make fails on Windows with “multiple target patterns” or “target pattern contains no `%'”

Answer

You have a quoted Win32 absolute path in a makefile rule. Don’t use quotes: GNU make doesn’t support quoting at all, and you will never be able to use paths with spaces in them in GNU make.

This is correct:

target: X:\path\to\file
	@command $< $@

This will raise an error:

target: "X:\path\to\file"
	@command $< $@
Why only absolute paths?

It’s the colon after the drive letter. The colon is a special character that tells GNU make that the rule is a pattern rule.

Why only quoted Win32 paths? why not unquoted paths?

GNU make has special code for recognizing and parsing Win32 paths. Since GNU make doesn’t support quoted paths, the opening quote is interpreted as just another character of the file name, the colon is no longer the second character of the path and the path is not recognized as a Win32 path.

No comments:

Post a Comment