diff options
author | Anup Patel <apatel@ventanamicro.com> | 2022-05-13 09:26:00 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2022-05-13 09:26:00 +0530 |
commit | 7fb474b9dde5d56e0d4d6a0c1627337694cdc2f2 (patch) | |
tree | f9f70da61cd5242633ec8dd1587bade2f088abd1 /Makefile | |
parent | f726f2dc0186964feb17296471233086bcc3d1b2 (diff) | |
download | opensbi-7fb474b9dde5d56e0d4d6a0c1627337694cdc2f2.zip opensbi-7fb474b9dde5d56e0d4d6a0c1627337694cdc2f2.tar.gz opensbi-7fb474b9dde5d56e0d4d6a0c1627337694cdc2f2.tar.bz2 |
Makefile: Add support for generating C array at compile time
Generating C array at compile time based on details provided by
objects.mk is a very useful feature which will help us compile
only a subset of drivers or modules.
We add a bash script (carray.sh) which takes array details and
object/variable list from command-line to generate a C source
containing array of object/variable pointers. We also extend
top-level makefile to use carray.sh whenever specified through
objects.mk.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -404,6 +404,10 @@ compile_d2c = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \ $(if $($(2)-varprefix-$(3)),$(eval D2C_NAME_PREFIX := $($(2)-varprefix-$(3))),$(eval D2C_NAME_PREFIX := $(5))) \ $(if $($(2)-padding-$(3)),$(eval D2C_PADDING_BYTES := $($(2)-padding-$(3))),$(eval D2C_PADDING_BYTES := 0)) \ $(src_dir)/scripts/d2c.sh -i $(6) -a $(D2C_ALIGN_BYTES) -p $(D2C_NAME_PREFIX) -t $(D2C_PADDING_BYTES) > $(1) +compile_carray = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \ + echo " CARRAY $(subst $(build_dir)/,,$(1))"; \ + $(eval CARRAY_VAR_LIST := $(carray-$(subst .c,,$(shell basename $(1)))-y)) \ + $(src_dir)/scripts/carray.sh -i $(2) -l "$(CARRAY_VAR_LIST)" > $(1) compile_gen_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \ echo " GEN-DEP $(subst $(build_dir)/,,$(1))"; \ echo "$(1:.dep=$(2)): $(3)" >> $(1) @@ -451,6 +455,13 @@ $(build_dir)/%.dep: $(src_dir)/%.S $(build_dir)/%.o: $(src_dir)/%.S $(call compile_as,$@,$<) +$(build_dir)/%.dep: $(src_dir)/%.carray + $(call compile_gen_dep,$@,.c,$<) + $(call compile_gen_dep,$@,.o,$(@:.dep=.c)) + +$(build_dir)/%.c: $(src_dir)/%.carray + $(call compile_carray,$@,$<) + $(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf $(call compile_objcopy,$@,$<) |