makefile: find a position of word in a variable

后端 未结 6 1440
我寻月下人不归
我寻月下人不归 2020-12-20 21:16

In my makefile, I need to make a variable assignment based on a command line variable value. for example, I do:

make var_1=xxx

where

6条回答
  •  醉酒成梦
    2020-12-20 22:09

    One way simulate associative containers in make is to use computed variables. E.g.:

    var_2.a := A
    var_2.b := B
    # ...
    
    # lookup
    var_2 = ${var_2.${var_1}}
    # or, lookup and assign a default value if lookup fails
    var_2_or_default = $(or ${var_2.${var_1}},)
    

提交回复
热议问题