Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22268

Makefile can I execute a configuration only once?

$
0
0

Im trying to create a Makefile which compiles some files and creates some outputs but first I want it to execute the configuration only one time and the next time I type make it wont re-execute the configuration unless I change the parameters for example the prefix.

I tried using touch , FORCE and if, after searching a bit in other posts but Im newbie in gcc and Makefiles so I cant make it work.

My code now is (did not include the other rules because they dont affect the configuration):

XLEN := 32RISCV_PREFIX := riscv$(XLEN)-unknown-elf-RISCV_GCC := $(RISCV_PREFIX)gccCFLAGS := -O2WORKING_DIR:= $(shell pwd)LIBRARY_DIR:= $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)B := $(shell echo $(LIBRARY_DIR))$(info $(B))

--->(execute this only once)--->CONFIGURATION := configure --prefix=$(LIBRARY_DIR) --with-arch=rv32if --with-abi=ilp32d

RISCV_TEST_DIR:=$(shell pwd)SCRIPTDIR:=$(RISCV_TEST_DIR)/../../toolsRISCV_OPTIONS = -o  RISCV_LINK = $(RISCV_GCC) $(PROGRAMS) $(RISCV_OPTIONS) $@ $(CFLAGS) #produces .elf file!RISCV_OBJDUMP = $(RISCV_PREFIX)objdump -D                           #produces a dump file to see the assembly code!RISCV_OBJCOPY = $(RISCV_PREFIX)objcopy -O binary                    #produces a bin file!%.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 0x0 > $@ || exit -1    $(info Hex Generation Successful!)    $(info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)all: $(PROGRAMS_TO_CREATE); if [ -a $(LIBRARY_DIR)/config.status ]; then cd $(LIBRARY_DIR) && $(CONFIGURATION); fi;configure: config.status    touch configureconfig.status:    cd $(LIBRARY_DIR) && $(CONFIGURATION);.PHONY: all cleanclean:    $(info Cleaning files...)    @rm -rf *.elf *.hex *.map *.objdump *.i *.s *.bin *.dump    $(info Done cleaning!)

Thank you in advance!


Viewing all articles
Browse latest Browse all 22268

Latest Images

Trending Articles



Latest Images

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