makefile: find a position of word in a variable

后端 未结 6 1441
我寻月下人不归
我寻月下人不归 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 21:57

    FAB = macrofab
    # NOTE: base starts at 1 instead of 0
    none := 1
    seeed := 1
    oshpark := 2
    macrofab := 2
    pcbng := 3
    #NOTE: String must end with a space for word function to work
    SUFFIX_DRILLS := "txt xln drl "
    
    .PHONY: gerber
    
    gerber:
        @echo $(FAB) drill suffix is $(word $($(FAB)), $(SUFFIX_DRILLS))
    

    Output of make is: macrofab drill suffix is xln

提交回复
热议问题