Reputation: 31
I am trying to expand a variable in the Makefile:
LIST = 1,3-6,9
so that "3-6" would expand into a list of numbers between 3 and 6.
I tried the following command in the terminal:
echo 1,3-6,9 | perl -pe 's/(\d+)-(\d+)/join(",", $1..$2)/ge'
It does produce the exact output. I then tried the following approach in the Makefile:
LIST_NEW = $(shell printf $(shell echo ${LIST} | perl -pe 's/(\d+)-(\d+)/join(",", $1..$2)/ge'))
which then has the error message as:
syntax error at -e line 1, near ", .."
How can I solve this issue?
Upvotes: 0
Views: 91
Reputation: 100836
You have to escape any $
you don't want to be expanded by make, as $$
.
Also, why are you running $(shell ...)
twice?
This will work:
LIST_NEW = $(shell echo ${LIST} | perl -pe 's/(\d+)-(\d+)/join(",", $$1..$$2)/ge')
You might consider using :=
instead, here, if the value of LIST
is constant for a given invocation of make.
Upvotes: 2