I want to parse digits of a version in a Makefile. I am getting the version in a variable, that variable reads VER=10.11.12-0.1.2
Now I want each individual digits in different variables let's say A=10, B=11 and so on.. I have tried combinations of sed and awk but not getting it work exactly I want.. also it seems piped output doesn't work in Makefile.
A=$(shell echo ${VER} | awk -F . "{print $1}")
Any inputs?
CodePudding user response:
Here's one way of doing it with Gnu make:
VER = 10.11.12-0.1.2
VERNUMS := $(subst .,\ ,$(subst -,\ ,$(VER)))
A = $(word 1,$(VERNUMS))
B = $(word 2,$(VERNUMS))
# Etc.