Bubaya
Bubaya

Reputation: 823

Make: Static recipes for dynamic subdirectories

Given a hierarchy of the (simplified) form

A
  source
  target
B  
  source
  target
...

where there is specifically one target in each subdirectory which is to be built from the one source therein. I'd like to achieve this by make.

Of course, a makefile such as

%target: %source
    ...

would do the job, but this could also match A/wrong_target. Removing the %'s however does not work; it seems that target then only matches in . but in no subdirectory.

Any good way to achieve this?

Upvotes: 0

Views: 28

Answers (1)

MadScientist
MadScientist

Reputation: 100856

When you say "a hierarchy" do you mean a directory hierarchy?

Why don't you just enforce the directory by including the "/", like this:

%/target: %/source
         ....

Upvotes: 1

Related Questions