On Thu, 2011-01-20 at 14:23 -0500, Bob Bell wrote:
> What I'd really like to do is write a rule like this:
>
> $(objdir)/%: | $(objdir)
> $(objdir): ; mkdir $@
>
> The goal here is that all build output goes into a separate directory
> $(objdir), and so I need to have all contents of the directory
> dependent on the creation of that directory.
>
> I *could* bundle up all the contents of the directory and make them
> explictly depend on the directory. But I'd prefer something simpler
> and less prone to oversight.
I typically just force the directory to be created, with something like:
__dummy := $(shell mkdir -p $(objdir))
This will be run before any rules.
> I presume the example above doesn't work because a pattern rule must
> be required to have % in both the target and the prerequisite.
No. You are allowed to declare pattern rules where there's no % in the
prerequisite.
It doesn't work because it's not legal to create a pattern rule that
doesn't have a recipe. What you're trying to do is not create a pattern
rule, but rather create some kind of pattern-matched prerequisite
definition. GNU make doesn't support that feature.
In the GNU make manual you'll see that a pattern rule that has no recipe
is defined to delete that rule.
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make