Get word before last word inside GNU makefile
I need to extract the word to the last from $(MAKEFILE_LIST)
.
Until now, I couldn't think of anything better than this monster:
LIST := a b c
LAST_WORD_INDEX = $(words $(LIST))
BEFORE_LAST := $(word $(shell echo $(LAST_WORD_INDEX) - 1 | bc),$(LIST))
$(info word before last is $(BEFORE_LAST))
When I ran it:
word before last is b
make: *** No targets. Stop.
The result is correct, but is there a more elegant and sane way to achieve the same?
+3
source to share