I'm modifying a makefile and a bit in the dark. I've tried googling and reading make primers but nothing has obvious answers to my problems below
Its first target: "default" compiles and builds using the gcc_riscv compiler
It has 2 phony targets: "clean" and "info". clean does what it should and info invokes riscv_readelf
I want to add 2 targets: "gccx86" and "lint" that will do the same as "default" except invoke the x86 compiler or lint largely on the same file list.
gccx86 will swap a few "hardware close" modules for mocks, and tweak the include hierarchy to make the whole codebase compile as a linux target instead. Hmmm maybe I should call it linux?
But anyway I want my 2 new targets to take rougly the same file list. The $(RISCV-GCC) symbol will point to gcc for "gccx86", and clang-tidy for "lint"
Basically how do I declare these 2 new targets, and conditionally declare the include path and other stuff based on the target
I guess it should be along the lines of:
export CROSS_PREFIX ?= /opt/cae/riscv-gcc/riscv_gcc12.2.1/bin/riscv64-unknown-elf-
export RISCV_GCC ?= $(CROSS_PREFIX)gcc
ifeq ($(TARGET_VARIABLE), "gccx86")
export RISCV_GCC = gcc
endif
ifeq ($(TARGET_VARIABLE), "lint")
export RISCV_GCC = clang-tidy
endif
Well what is the TARGET_VARIABLE?
Or is multiple targets wrong and I should have a -lint switch: make -lint? How do I pick up such switches if so.
Eventually we'll throw out the whole mess and go cmake but not over the next few months
make mode=whateverand switch on$(mode)in the Makefile.make risc gcc. You might want to read more about target specific variables:when you define a target-specific variable that variable value is also in effect for all prerequisites of this target. Meaning you could set variables on the phony targets and have them apply downward. gnu.org/software/make/manual/html_node/Target_002dspecific.html