Simplest way to reverse the order of strings in a make variable

后端 未结 5 1855
鱼传尺愫
鱼传尺愫 2021-02-19 11:19

Let\'s say you have a variable in a makefile fragment like the following:

MY_LIST=a b c d

How do I then reverse the order of that list? I need

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 11:48

    A solution in pure GNU make:

    default: all

    foo = please reverse me

    reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))

    all : @echo $(call reverse,$(foo))

    Gives:

    $ make

    me reverse please

提交回复
热议问题