makefile - How to assign a value to a variable on specific target?
问题 In the below code snippet: IMAGES_TO_DELETE := $(aws ecr list-images --region $(ECR_REGION) --repository-name $(ECR_REPO) --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json) .PHONY: target1 target2 cleanimage cleanimage: ${DISPLAYINFO} "Clean untagged image from AWS ECR " aws ecr batch-delete-image --region $(ECR_REGION) --repository-name $(ECR_REPO) --image-ids "$(IMAGES_TO_DELETE)" || true ${DISPLAYINFO} "Done" target1: # do something target2: # do something IMAGES_TO_DELETE