Trying to find an elegant method to solve some complex dependencies. I have something like the following in my Makefile:
.PHONY: FOO
FOO: foo
foo:
build foo
.PHONY: BAR
BAR: bar
bar: FOO
build bar
The idea here is that I want to abstract the real files (foo, bar) with phony targets (FOO BAR). In my real Makefile, of course, it is more complicated which is why the abstraction is important. The problem here, though, is by making phony target FOO a dependency for bar, then Make always tries to rebuild bar even if both foo and bar are up-to-date. This is apparently because it always treats FOO as out-of-date. But this behavior is not really correct.
So it seems I only have 3 options: 1) Make bar directly dependent on foo. In my real Makefile it is more complicated and trying to specify the real files as dependencies is highly undesirable. 2) Use variables in addition to all the phonies. This makes the whole Makefile more complex. 3) Remove foo/Foo as a dependency from bar and add a recursive make of FOO as part of the rule in bar. This is very bad form.
Is there some more elegant solution that I am not aware of?
Thanks.
makeis how it handles real targets and timestamps well. - Carl Norum