Reputation: 1410
I want to call another Rule that I have created to be used to serve multiple targets in my Makefile to create AWS Cloudformation Stacks. The Rule looks like this:
aws/create_stack:
aws cloudformation create-stack \
--stack-name $(stack_name) \
--region $(region) \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND
I want to call the rule from another rule and define Variables for the rule at execution time like this:
aws/parameters: aws/create_stack
$(MAKE) aws/create_stack stack_name=parameter region=$(REGION)
But for some reason when I execute the Makefile the Variables set in the receipe of the Caller Rule are not used by the first Rule I'm calling.
when I set the Variable separately outside of the Rule (aws/parameters) - it works. How do I have to re-write it to keep the Variable assignment in the Rule (aws/parameter)?
Thank you A
Upvotes: 0
Views: 108
Reputation: 1410
As @Beta wrote you can use the "dependency approach"; a more condensed version looks like this:
aws/parameters: stack_name := parameter
aws/parameters: region := $(REGION)
was/parameters: aws/create_stack
Upvotes: 0
Reputation: 99124
There's no need to use recursion ($(MAKE) ...
) here. Just use target-specific variables:
parameters: stack_name := parameter
parameters: region := $(REGION)
parameters: create_stack
@echo parameters done
create_stack:
@echo create_stack: stack_name is $(stack_name)
@echo create_stack: region is $(region)
Upvotes: 1