apple.file : orange banana pineapple
@echo "Apple"
orange : orange.file
@echo "Orange"
banana :
@echo "Banana"
pineapple : pineapple.file
@echo "Pineapple"
What I want is for gmake to to process all of the prerequisites in
order, but not to consider "banana" as a prerequisite to actually
rebuild apple.
In other words, if apple.file exists, orange.file exists, and
pineapple.file exists (and assuming that apple.file is the most
recent), I would want the words "Banana" printed, but not have to
rebuild apple.file.
I apologize if this is a little bit confusing. I have read in the
gmake manual that there are "order-only-prerequisites", which are
almost perfect, except that I can't interleave their order with the
actual prerequisites.
Thanks,
Chess
cs> apple.file : orange banana pineapple
cs> @echo "Apple"
cs> orange : orange.file
cs> @echo "Orange"
cs> banana :
cs> @echo "Banana"
cs> pineapple : pineapple.file
cs> @echo "Pineapple"
cs> What I want is for gmake to to process all of the prerequisites in
cs> order, but not to consider "banana" as a prerequisite to actually
cs> rebuild apple.
Make doesn't always guarantee that prerequisites will be built in the
order they appear in the prerequisites list. As long as you're running
serial make yes, they will be built in that order. But as soon as you
invoke parallel make (-j) make will not guarantee any order in which
prerequisites are built _EXCEPT_ that they will all be complete before
the target's build script is invoked.
If, in the makefile above, you are relying on orange to be built before
banana your makefile is not properly constructed. If you want to ensure
that orange is built before banana and banana is built before pineapple,
you have to declare that:
apple.file : orange
...
orange: banana
...
banana: pineapple
...
pineapple:
...
cs> In other words, if apple.file exists, orange.file exists, and
cs> pineapple.file exists (and assuming that apple.file is the most
cs> recent), I would want the words "Banana" printed, but not have to
cs> rebuild apple.file.
cs> I apologize if this is a little bit confusing. I have read in the
cs> gmake manual that there are "order-only-prerequisites", which are
cs> almost perfect, except that I can't interleave their order with the
cs> actual prerequisites.
See above.
In that "correct" makefile you would simply change the banana
prerequisite to be order-only and leave the rest:
apple.file : orange
...
orange: | banana
...
banana: pineapple
...
pineapple:
...
--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Thanks for responding, and I think I understand your suggestion. But
in the example you give here, if pineapple gets updated, I want
apple.file to be updated. I think the fact that it is buried in the
tree under a "order-only" node will prevent this.
In other words, pineapple is a real prerequisite of apple.file
although banana is not.
-Chess
cs> I apologize if this is a little bit confusing. I have read in the
cs> gmake manual that there are "order-only-prerequisites", which are
cs> almost perfect, except that I can't interleave their order with the
cs> actual prerequisites.
>> In that "correct" makefile you would simply change the banana
>> prerequisite to be order-only and leave the rest:
>>
>> apple.file : orange
>> ...
>> orange: | banana
>> ...
>> banana: pineapple
>> ...
>> pineapple:
>> ...
cs> Thanks for responding, and I think I understand your suggestion. But
cs> in the example you give here, if pineapple gets updated, I want
cs> apple.file to be updated. I think the fact that it is buried in the
cs> tree under a "order-only" node will prevent this.
cs> In other words, pineapple is a real prerequisite of apple.file
cs> although banana is not.
Well, you can always use:
apple.file: orange pineapple
...
orange: | banana
...
banana: pineapple
...
pineapple:
...
--
Brilliant. That is a very creative solution.
Thanks for your help,
Chess