Im having a problem with a Makefile Im trying to create. I just want to create one by one the .elf file then the dump and lastly the bin file and then with a python script convert it to .hex file. My goal is to actually create the .elf and .hex files with just using the make command.
Despite that because Im very new to Makefiles, Im getting an error after executing the make command:
make
test
make: *** [copy.hex] Error 1
Thank you in advance!
XLEN ?= 32
RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
CFLAGS = -O2
./configure --prefix=/home/opt/Risc_V/my_tests --with-arch=rv32if --with-abi=ilp32d
SCRIPTDIR=/home/opt/Risc_V/tools/
RISCV_TEST_DIR=/home/opt/Risc_V/my_tests/my_software
PROGRAMS ?= copy.c
ALL_HEX = $(PROGRAMS:%.c=%.hex)
PWD := $(shell pwd)
all: $(ALL_HEX) $(PROGRAMS)
RISCV_OPTIONS ?= -o $(PROGRAMS).elf $(CFLAGS)
RISCV_LINK ?= $(RISCV_GCC) $(PROGRAMS) $(RISCV_OPTIONS)#produces .elf file!
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump -D $(PROGRAMS).elf > $(PROGRAMS).dump#produces a dump file to see the assembly code!
RISCV_OBJCOPY ?= $(RISCV_PREFIX)objcopy -O binary $(PROGRAMS).elf $(PROGRAMS).bin#produces a bin file!
test: all
%.elf: %.c
$(RISCV_LINK)
%.bin: %.elf
$(RISCV_OBJDUMP)
%.dump: %.elf
$(RISV_OBJCOPY)
%.hex: %.bin $(SCRIPTDIR)/bin2hex.py
test
test: $(SCRIPTDIR)/bin2hex.py
python $(SCRIPTDIR)/bin2hex.py $(PROGRAMS).bin -a 0x0 > $(PROGRAMS).hex || exit -1
clean:
rm -rf *.elf *.hex *.map *.objdump *.i *.s *.bin *.dump