I want to generate a random value within a given range and use the result to update a Makevariable as well as modify a file.
I tried using the below code, I do see the random value generated. But I am unable to use it in the sed/Make variable.
Makefile ::
ALL_CPU_IRQ = 1
all:
ifeq ($(ALL_CPU_IRQ),1)
RANDINT=$(shell python -c 'from random import randint; print(randint(1,3));')
@echo $(RANDINT)
override BLOCK_RUN_OPT += +init_cpu=$(RANDINT)
sed -i 's|asm_comp_opt_tl=|\0INIT_CPU=$(RANDINT),|' $(CURDIR)/asm_opt.txt
@echo $(BLOCK_RUN_OPT)
endif
Output I observe is :
RANDINT=2
+init_cpu=
And asm_opt.txt : asm_comp_opt=INIT_CPU=,
Expected output :
RANDINT=2
+init_cpu=2
And asm_opt.txt : asm_comp_opt=INIT_CPU=2,
I am fairly new to Makefile. Any suggestions would be helpful. Apologies if it's a redundant question.