相关疑难解决方法(0)

Makefile中的词典/地图/查找表

我需要在Makefile中创建一个查找表/字典/映射来查找键值信息.

我一直在尝试使用ifeq语句来做同样的事情,但我的陈述似乎失败了:

# this gets the account id from the current user's ARN, you must have the AWS CLI and jq installed
AWS_ACCOUNT_ID:=$(shell aws iam get-user | jq -r '.User.Arn' | awk -F ':' '{print $$5;}')

# define a friendly account name for output
ifeq ($(AWS_ACCOUNT_ID), 123456)
AWS_ACCOUNT_FRIENDLY:=staging
endif

ifeq ($(AWS_ACCOUNT_ID), 789012)
AWS_ACCOUNT_FRIENDLY:=preprod
endif

ifeq ($(AWS_ACCOUNT_ID), 345678)
AWS_ACCOUNT_FRIENDLY:=production
endif
Run Code Online (Sandbox Code Playgroud)

它似乎只适用于第一个值123456而不适用于其他值.

有没有办法在Make中定义字典/地图,只需通过帐户ID的密钥查找帐户友好名称?

makefile gnu-make

5
推荐指数
1
解决办法
2922
查看次数

标签 统计

gnu-make ×1

makefile ×1