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
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))
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
$ make
me reverse please