0
votes

In a project I'm working on, I have a directory full of source files which require a special executable to compile. My initial reaction is to do:

SomeDirectory/%.o: my-special-compiler

...to add the dependency for all %.o files.

Except of course this doesn't work, because pattern rules are special and while the above index will add a prerequisite for a non pattern rule, for pattern rules it seems to do nothing.

I don't have a list of all .o files in SomeDirectory at this point in the build system. Is there a way I can achieve the same effect without having to refactor my build system?

This is GNU Make, if it helps.

1

1 Answers

1
votes

Not simply by adding a new rule. You must list each of the object files and add that prerequisite specifically to them. A pattern rule with no recipe cancels the pattern rule.

Probably your best option is to follow the model created for auto-dependency generation and automatically generate a file that contains that extra prerequisite, as a side-effect of creating the object file... then include it.