Quantcast
Viewing all articles
Browse latest Browse all 22113

Makefile compile many programs with main function with one makefile error

Im trying with one Makefile to compile many .c files. I have written all the rules and I want to add a rule that says: execute all the rules who depend on .c files.

In reference of : Compile all C files in a directory into separate programs

PROGRAMS := copy.c sec_soft.cPROGRAMS_NO_EX := $(basename $(PROGRAMS))PROGRAMS_TO_CREATE := $(PROGRAMS_NO_EX).elf $(PROGRAMS_NO_EX).dump $(PROGRAMS_NO_EX).bin $(PROGRAMS_NO_EX).hex $(PROGRAMS_NO_EX).mem  $(PROGRAMS_NO_EX).coeRISCV_OPTIONS = -march=rv32if -mabi=ilp32 -o  RISCV_LINK = $(RISCV_GCC) $(CFLAGS) $< -o $@                            #produces .elf file!RISCV_OBJDUMP = $(RISCV_PREFIX)objdump -D   $(DFLAGS)                       #produces a dump file to see the assembly code!RISCV_OBJCOPY = $(RISCV_PREFIX)objcopy -O binary                        #produces a bin file!ALL_RES = $(PROGRAMS:%.c=%.elf)%.elf: %.c    $(info Generating .elf file from files: $(PROGRAMS_NO_EX))    $(RISCV_LINK)    $(info Success!)    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)%.dump: %.elf    $(info Copying assembly to dump file $(PROGRAMS_NO_EX).dump)    @$(RISCV_OBJDUMP) $< > $@    $(info Success!)    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)%.bin: %.elf    $(info Generating bin file)    @$(RISCV_OBJCOPY) $< $@    $(info Success!)    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)%.hex: %.bin     $(info Generating hex file)    echo cd $(SCRIPTDIR)    $(info Running binary to hex >>>)    python $(SCRIPTDIR)/bin2hex.py -a $(START_ADDRESS) -o $@ $<    $(info Hex Generation Successful!)    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)%.mem: %.bin    $(info Instantiating memory addresses...)    head -c $$(( $(START_ADDRESS))) /dev/zero | cat - $< | xxd -g1 -c4 | awk '{print $$5$$4$$3$$2}'> $@    $(info Memory instantiation Successful!)    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)%.coe: %.bin    $(info Instantiating memory vector...)    python $(SCRIPTDIR)/bin2coe.py $< -o $@    $(info Memory vector instantiation Successful )    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)    all: $(ALL_RES);

But this line ALL_RES = $(PROGRAMS:%.c=%.elf) does not execute all the rules. I was hoping that after generating .elf files then all of the rules below would execute but not.

Im newbie on Makefiles, so please forgive any mistakes.

Thank you in advance


Viewing all articles
Browse latest Browse all 22113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>