diff options
author | Nathaniel Graff <nathaniel.graff@sifive.com> | 2019-03-15 19:35:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 19:35:26 +0000 |
commit | 30c143eb5445f47edb351ba54c84ff8285dc27a9 (patch) | |
tree | c02276d630c017ac15e3794ce3ea25be78937da1 /Makefile | |
parent | 5857568d9db5b626fea43a414a17809afdc9f80b (diff) | |
parent | 5dd316a7fff887877c229be395db74dd62634586 (diff) |
Merge pull request #207 from sifive/tags
Proposal: TARGET_TAGS is used to configure the build and to filter list-targets
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 49 |
1 files changed, 38 insertions, 11 deletions
@@ -106,16 +106,41 @@ clean: # format or fixed text of the output without consulting the # Freedom Studio dev team. ############################################################# -# -# Metal boards are any folders that aren't the Legacy BSP or update-targets.sh -EXCLUDE_TARGET_DIRS = drivers env include libwrap update-targets.sh + +# Find all settings.mk with TARGET_REQUIRE_TAGS in TARGET_TAGS +MATCHING_SETTINGS = $(shell scripts/filter-targets $(TARGET_ROOT)/bsp $(TARGET_REQUIRE_TAGS)) + +# Get the name of the containing directory of all matching settings.mk +MATCHING_TARGETS = $(patsubst $(TARGET_ROOT)/bsp/%/,%,$(dir $(MATCHING_SETTINGS))) + +.PHONY: list-targets list-targets: - @echo bsp-list: $(sort $(filter-out $(EXCLUDE_TARGET_DIRS),$(notdir $(wildcard bsp/*)))) + @echo bsp-list: $(sort $(MATCHING_TARGETS)) + +# Lists all available TARGET_TAGS +# +# 1. Find all settings.mk +# 2. Extract the TARGET_TAGS line +# 3. Extract the value of TARGET_TAGS +# 4. Split each tag onto a newline +# 5. Sort the lines +# 6. Find unique tags +# +.PHONY: list-target-tags +list-target-tags: + @echo target-tags: $(shell find $(TARGET_ROOT)/bsp -name settings.mk | \ + xargs grep -he "TARGET_TAGS" | \ + sed -r 's/TARGET_TAGS.*=(.*)/\1/' | \ + tr ' ' '\n' | \ + sort | \ + uniq) # Metal programs are any submodules in the software folder +.PHONY: list-programs list-programs: @echo program-list: $(shell grep -o '= software/.*$$' .gitmodules | sed 's/.*\///') +.PHONY: list-options list-options: list-programs list-targets ############################################################# @@ -131,13 +156,14 @@ include scripts/libmetal.mk ifeq ($(STANDALONE_DEST),) standalone: $(error Please provide STANDALONE_DEST to create a standalone project) -else +else # STANDALONE_DEST != "" $(STANDALONE_DEST): $(STANDALONE_DEST)/%: mkdir -p $@ -ifneq ($(COREIP_MEM_WIDTH),) +ifneq ($(filter rtl,$(TARGET_TAGS)),) +# TARGETs with the "rtl" TARGET_TAG need elf2hex in their standalone project standalone: \ $(STANDALONE_DEST) \ $(STANDALONE_DEST)/bsp \ @@ -169,7 +195,7 @@ standalone: \ echo "PROGRAM = $(PROGRAM)" > $</Makefile cat scripts/standalone.mk >> $</Makefile cat scripts/libmetal.mk >> $</Makefile -else +else # "rtl" not in TARGET_TAGS standalone: \ $(STANDALONE_DEST) \ $(STANDALONE_DEST)/bsp \ @@ -195,9 +221,9 @@ standalone: \ echo "PROGRAM = $(PROGRAM)" > $</Makefile cat scripts/standalone.mk >> $</Makefile cat scripts/libmetal.mk >> $</Makefile -endif +endif # rtl in TARGET_TAGS -endif +endif # STANDALONE_DEST ############################################################# # Upload and Debug @@ -210,7 +236,7 @@ else RISCV_OPENOCD=openocd endif -ifneq ($(SEGGER_JLINK_OB),) +ifneq ($(filter jlink,$(TARGET_TAGS)),) upload: $(PROGRAM_HEX) scripts/upload --hex $(PROGRAM_HEX) --jlink $(SEGGER_JLINK_EXE) else @@ -218,7 +244,7 @@ upload: $(PROGRAM_ELF) scripts/upload --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg endif -ifneq ($(SEGGER_JLINK_OB),) +ifneq ($(filter jlink,$(TARGET_TAGS)),) debug: $(PROGRAM_ELF) scripts/debug --elf $(PROGRAM_ELF) --jlink $(SEGGER_JLINK_GDB_SERVER) --gdb $(RISCV_GDB) else @@ -226,3 +252,4 @@ debug: $(PROGRAM_ELF) scripts/debug --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg endif + |