How to add both prefix and suffix to a list in makefile?

Viewed 245

In my makefile I'm trying to add to each item in the list both prefix and suffix.

For example: Assuming list contains:

ITEMS =item1 item2 item3

I Would like to get this string:

ITEMS_PADDED =--before item1 --after1 --after2 --before item2 --after1 --after2 --before item3 --after1 --after2

I tried with addprefix and addsuffix commands but it treats the added prefix as items so it add a suffix to the preffix as it was an item:

With the following code

ITEMS                   =item1 item2 item3
ITEMS_PREFIX            =$(addprefix ' --before ', $(ITEMS))
ITEMS_SUFFIX            =$(addsuffix ' --after ', $(ITEMS_PREFIX))

list_items:
    @echo $(ITEMS)
    @echo $(ITEMS_PREFIX)
    @echo $(ITEMS_SUFFIX)

I'm getting this results:

item1 item2 item3
--before item1  --before item2  --before item3
--after  --before --after  item1 --after   --after  --before --after  item2 --after   --after  --before --after  item3 --after

which is obviously not correct.

1 Answers
Related