How can I pass a variable via a Makefile into a .s file?
I wish to pass a value from a script into the .s start-up file, similar to the following with a C program. The script 'mm' exports the CAN id, 0xB0A00000--
./mm B0A00000
and when 'make' executes, the 'Makefile' includes the following, which passes the value to a C program via C_DEFS--
C_DEFS += -DI_AM_CANID=$(I_AM_CANID)
and the C program has--
canwinch_ldrproto_init(IAMUNITNUMBER);
which uses the B0A00000 from the command line.
I would like to do the following with 'startup_stm32l431xx.s', e.g.--
...
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
.word I_AM_CANID
.word _begin_flash
.word _end_prog
Reset_Handler:
ldr sp, =_estack /* Set stack pointer */
...With the following added to Makefile--
AS_DEFS = -DI_AM_CANID=$(I_AM_CANID)
But this results in--
build/startup_stm32l431xx.o:(.text.Reset_Handler+0x0): undefined reference to `I_AM_CANID'
I have tried a number of variations, with no success. There must be some detail I'm missing.
