You can define rules out-of-order
top-rule: sub-rule1 sub-rule2
@echo top-rule
sub-rule1:
@echo sub-rule1
sub-rule2:
@echo sub-rule2
but if you want to do something like collecting the sunb rules in a variable this breaks
top-rule: $(SUBRULES)
@echo top-rule
SUBRULES+= sub-rule1
sub-rule1:
@echo sub-rule1
SUBRULES+= sub-rule1
sub-rule2:
@echo sub-rule2
@echo top-rule
SUBRULES+= sub-rule1
sub-rule1:
@echo sub-rule1
SUBRULES+= sub-rule1
sub-rule2:
@echo sub-rule2
because the variable is expanded when encountered
It must be fixed by rearranging
SUBRULES+= sub-rule1
sub-rule1:
@echo sub-rule1
SUBRULES+= sub-rule1
sub-rule2:
@echo sub-rule2
sub-rule1:
@echo sub-rule1
SUBRULES+= sub-rule1
sub-rule2:
@echo sub-rule2
top-rule: $(SUBRULES)
@echo top-rule
@echo top-rule
Darn! But I like being able write things out of order, top-down.
In general, I like languages that have relaxed order dependencies. Like some RTL languages (notably Intel iHDL). Even C++ has relaxed ordering in some places.
But the inconsistencies such as above are painful and confusing.
--
Single assignment is the easiest way to do non-order dependent.
But accumulation - += - is very much required.
Q: is the accumulation done order dependent, or not?
What is needed is accumulating += - probably order dependent.
And then expanding.
With an error if expanding results in changes to variables already being expanded. ??
Or relaxation.
No comments:
Post a Comment