I was reading gnu make section 10.5.4 "How patterns match" and it does not sound like I can do what I want.
I want to setup a directory structure where my source code is in one directory, and there are sub-directories to hold object files. One sub-directory for each build configuration. So I might have these files
a.c
debug/a.o # compiled with -g
release/a.o # compiled with -O
So I would like to make rules like this
debug/%.o : %.c
gcc -c -g %.c -o $@
release/%.o : %.c
gcc -c -O %.c -o $@
But section 10.5.4 tells me a match on "debug/a.o" will make the stem be "debug/a" so gnu make will look for the source file at "debug/a.c" which is not what I want.
Is there a way to get GNU make to help me ?
Your makefile will work as written.
From that section of the manual:
Your target patterns do contain slashes.
Try it if you don't believe me.
EDIT:
Correction: in the commands you should use
$<
rather than%.c
.