Makefile appending string to variable -


i want generate command:

taskset -c 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 ./myprogram 

first try: use echo:

taskset 0$(shell n in $(shell seq 1 14);do echo ",$$n";done) ./myprogram 

but echo gives additional trailing space between iterations

taskset -c 0,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ./myprogram 

,which not recognizable taskset function. so, tried append string self,

taskset -c $(shell core_num=0; n in $(shell seq 1 14); core_num:=$(core_num)","$$n;done;echo $(core_num)) ./myprogram 

however, i'm not familiar makefile, got error:

/bin/sh: 1: core_num:=0,1: not found /bin/sh: 1: core_num:=0,2: not found /bin/sh: 1: core_num:=0,3: not found /bin/sh: 1: core_num:=0,4: not found .... /bin/sh: 1: core_num:=0,14: not found taskset -c 0 ./myprogram 

can fix it?

don't use $(shell) here @ all. there's no point. $(shell) function running shell commands in make context. aren't in make context @ point. in shell context in recipe use normal shell command substitution.

taskset -c "0$$(printf ,%s $$(seq 1 14))" ./myprogram 

Comments