I think the problem is simpler. If there is a rule "/foo/bar/%.cpp.o:" and I type "make /foo/bar/baz.cpp.o", should I ever get the error "No rule to make target '/foo/bar/baz.cpp.o'"? The remainder of the makefile should not affect this. This is gmake 3.81 on macOS by the way. Are there some versions of make that do not accept text on both sides of % wildcards perhaps?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
You're absolutely right to focus on the core issue: GNU Make's pattern rule matching behavior. Let me address this directly.
The Problem:
If you have a rule like:
makefile
/foo/bar/%.cpp.o: /foo/bar/%.cpp
recipe...
and you run:
sh
make /foo/bar/baz.cpp.o
you should never get "No rule to make target" if:
The pattern rule syntax is correct, and
/foo/bar/baz.cpp exists.
Key Observations:
GNU Make 3.81 (your version) absolutely supports wildcards (%) on both sides of the rule. This has been a core feature for decades.
The error suggests one of these is happening:
The rule isn't actually being defined correctly (e.g., missing directory components)
The prerequisite file (baz.cpp) doesn't exist
There's a hidden character or syntax error in the Makefile
Minimal Test Case:
Try this absolutely minimal Makefile:
makefile
# Test rule - should work if test.cpp exists
build/paris/%.cpp.o: %.cpp
@echo "Building $@ from $<"
touch $@
# Force a test
.PHONY: test
test: build/paris/test.cpp.o
Then create test.cpp and run:
sh
mkdir -p build/paris
touch test.cpp
make test
This must work in any GNU Make version. If it doesn't, something is fundamentally wrong with your environment.
Common Pitfalls:
Directory Creation:
The target directory (build/paris/) must exist before the rule runs
Add $(shell mkdir -p build/paris) at the top
Path Mismatch:
If your rule says build/paris/%.cpp.o: paris/%.cpp but the file is in ./, it won't match
Hidden Characters:
Run cat -e Makefile to check for Windows line endings (^M) or other invisible characters
Case Sensitivity:
macOS filesystems are case-insensitive, but Make rules are case-sensitive in matching
Solution Path:
First verify with the minimal test case above
If that works, gradually add complexity back until it breaks
Use make -d to see exactly how make is trying (and failing) to match the rules
This is absolutely supposed to work in GNU Make 3.81. If it's not, there's either:
A syntax error in your rule
A missing prerequisite file
An environmental issue (like filesystem permissions)
Would you like me to suggest any specific diagnostic steps for your exact case?