Create comma-separated lists in GNU Make

后端 未结 3 2167
夕颜
夕颜 2021-02-12 21:57

I have a Makefile with a set of booleans which must be used to control the flags for an external application. The problem is that the flag must be passed as a comma-separated s

3条回答
  •  长情又很酷
    2021-02-12 22:37

    Or just use sed: ugly (and untested) but straightforward

    WITH_LIST = $(shell echo A$(BOOL_A) B$(BOOL_B) C$(BOOL_C) | sed -e 's/[ABC][^yABC]*//g' -e 's/y//g' -e 's/ /,/g')
    WITHOUT_LIST = $(shell echo A$(BOOL_A) B$(BOOL_B) C$(BOOL_C) | sed -e 's/[ABC]y[^ABC]*//g' -e 's/[^ABC ]//g' -e 's/ /,/g')
    

提交回复
热议问题