Consider the following:
%.foo: %.bar echo $< > $@
Assuming we have one 1.bar file, the command just executed echo 1.bar > 1.foo . However, when % contains a path, and not just a file name, it starts to become awkward. My problem is that I want to add another path to %.bar , the template becomes completely distorted. Ie, when %.bar nice/path/1.bar , this becomes impossible:
%.foo: /project/something/%.bar echo $< > $@
This will execute, but it does echo nice/path//project/something/1.bar > 1.foo instead of echo /project/something/nice/path1.bar > 1.foo
The reason for this is how make makes its rule pattern. From the docs:
If the target pattern does not contain a slash (and this is usually not the case), the directory names in the file names are removed from the file name before matching it with the target prefix and suffix. [...] Directories are ignored only to find an implicit rule to use, and not to apply this rule. Thus, 'e% t matches the file name src / eat, and src / a as the base. When prerequisites turn into file names, directories from the stem are added in front, and the rest of the stem is replaced with "%". The string 'src / a with the required pattern' c% r gives the file name src / car
Is it possible to disable this for a specific rule?
source share