From 8601cd3c6555b95698495dd122e2edd9ea031a9f Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Tue, 12 Feb 2019 15:33:43 -0800 Subject: Move libmetal make targets to scripts/libmetal.mk Signed-off-by: Nathaniel Graff --- Makefile | 46 ++-------------------------------------------- scripts/libmetal.mk | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 scripts/libmetal.mk diff --git a/Makefile b/Makefile index 91ff31f..053e1a2 100644 --- a/Makefile +++ b/Makefile @@ -131,54 +131,12 @@ list-options: list-programs list-targets endif ############################################################# -# Compiles an instance of the MEE targeted at $(TARGET) +# Import rules to build Freedom Metal ############################################################# ifeq ($(BSP),metal) -MEE_SOURCE_PATH ?= freedom-metal -MEE_LDSCRIPT = $(BSP_DIR)/metal.lds -MEE_HEADER = $(BSP_DIR)/metal.h - -.PHONY: metal -metal: $(BSP_DIR)/install/stamp - -$(BSP_DIR)/build/Makefile: - @rm -rf $(dir $@) - @mkdir -p $(dir $@) - cd $(dir $@) && \ - CFLAGS="-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -g -mcmodel=medany" \ - $(abspath $(MEE_SOURCE_PATH)/configure) \ - --host=$(CROSS_COMPILE) \ - --prefix=$(abspath $(BSP_DIR)/install) \ - --disable-maintainer-mode \ - --with-preconfigured \ - --with-machine-name=$(TARGET) \ - --with-machine-header=$(abspath $(MEE_HEADER)) \ - --with-machine-ldscript=$(abspath $(MEE_LDSCRIPT)) \ - --with-builtin-libgloss - touch -c $@ - -$(BSP_DIR)/install/stamp: $(BSP_DIR)/build/Makefile - $(MAKE) -C $(abspath $(BSP_DIR)/build) install - date > $@ - -$(BSP_DIR)/install/lib/libriscv%.a: $(BSP_DIR)/install/stamp ;@: - -$(BSP_DIR)/install/lib/libmetal.a: $(BSP_DIR)/install/lib/libriscv__mmachine__$(TARGET).a - cp $< $@ - -$(BSP_DIR)/install/lib/libmetal-gloss.a: $(BSP_DIR)/install/lib/libriscv__menv__metal.a - cp $< $@ - -.PHONY: clean-metal -clean-metal: - rm -rf $(BSP_DIR)/install - rm -rf $(BSP_DIR)/build -clean: clean-metal +include scripts/libmetal.mk endif -metal_install: metal - $(MAKE) -C $(MEE_SOURCE_PATH) install - ############################################################# # elf2hex ############################################################# diff --git a/scripts/libmetal.mk b/scripts/libmetal.mk new file mode 100644 index 0000000..7cdb7c5 --- /dev/null +++ b/scripts/libmetal.mk @@ -0,0 +1,48 @@ + +############################################################# +# Compiles an instance of the MEE targeted at $(TARGET) +############################################################# +MEE_SOURCE_PATH ?= freedom-metal +MEE_LDSCRIPT = $(BSP_DIR)/metal.lds +MEE_HEADER = $(BSP_DIR)/metal.h + +.PHONY: metal +metal: $(BSP_DIR)/install/stamp + +$(BSP_DIR)/build/Makefile: + @rm -rf $(dir $@) + @mkdir -p $(dir $@) + cd $(dir $@) && \ + CFLAGS="-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) -g -mcmodel=medany" \ + $(abspath $(MEE_SOURCE_PATH)/configure) \ + --host=$(CROSS_COMPILE) \ + --prefix=$(abspath $(BSP_DIR)/install) \ + --disable-maintainer-mode \ + --with-preconfigured \ + --with-machine-name=$(TARGET) \ + --with-machine-header=$(abspath $(MEE_HEADER)) \ + --with-machine-ldscript=$(abspath $(MEE_LDSCRIPT)) \ + --with-builtin-libgloss + touch -c $@ + +$(BSP_DIR)/install/stamp: $(BSP_DIR)/build/Makefile + $(MAKE) -C $(abspath $(BSP_DIR)/build) install + date > $@ + +$(BSP_DIR)/install/lib/libriscv%.a: $(BSP_DIR)/install/stamp ;@: + +$(BSP_DIR)/install/lib/libmetal.a: $(BSP_DIR)/install/lib/libriscv__mmachine__$(TARGET).a + cp $< $@ + +$(BSP_DIR)/install/lib/libmetal-gloss.a: $(BSP_DIR)/install/lib/libriscv__menv__metal.a + cp $< $@ + +.PHONY: clean-metal +clean-metal: + rm -rf $(BSP_DIR)/install + rm -rf $(BSP_DIR)/build +clean: clean-metal + +metal_install: metal + $(MAKE) -C $(MEE_SOURCE_PATH) install + -- cgit v1.2.3 From 742360812845743f6eb67813fbb97ee60029c45c Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Tue, 12 Feb 2019 15:40:39 -0800 Subject: Create standalone target which copies metal source Don't include .git* files in the copied metal sources. Signed-off-by: Nathaniel Graff --- Makefile | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 053e1a2..19347b8 100644 --- a/Makefile +++ b/Makefile @@ -171,8 +171,30 @@ $(STANDALONE_DEST): $(STANDALONE_DEST)/%: mkdir -p $@ -# We have to use $$(shell ls ...) in this recipe instead of $$(wildcard) so that we -# pick up $$(BSP_DIR)/install +ifneq ($(INCLUDE_METAL_SOURCES),) + +standalone: \ + $(STANDALONE_DEST) \ + $(STANDALONE_DEST)/bsp \ + $(STANDALONE_DEST)/src \ + $(SRC_DIR) \ + freedom-metal \ + scripts/standalone.mk \ + scripts/libmetal.mk + cp -r $(addprefix $(BSP_DIR)/,$(filter-out build,$(shell ls $(BSP_DIR)))) $ $> $> $> $ Date: Wed, 13 Feb 2019 10:22:14 -0800 Subject: Document INCLUDE_METAL_SOURCES for standalone target Signed-off-by: Nathaniel Graff --- Makefile | 3 ++- README.md | 7 ++++++- doc/sphinx/userguide/standalone.rst | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 19347b8..20a4a5d 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,8 @@ help: @echo " Launch OpenOCD and attach GDB to the running program." @echo "" @echo " standalone BSP=metal STANDALONE_DEST=/path/to/desired/location" - @echo " [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:" + @echo " [INCLUDE_METAL_SOURCES=1] [PROGRAM=$(PROGRAM)]" + @echo " [TARGET=$(TARGET)]:" @echo " Export a program for a single target into a standalone" @echo " project directory at STANDALONE_DEST." @echo "" diff --git a/README.md b/README.md index 4ba9ee8..2484c5f 100644 --- a/README.md +++ b/README.md @@ -248,8 +248,13 @@ Legacy Freedom E SDK. `STANDALONE_DEST` is a required argument to provide the desired project location. +You can include the argument `INCLUDE_METAL_SOURCES=1` if you would like to +include the sources for the Freedom Metal library in the generated standalone +project. If this argument is not included, then the Freedom Metal library will +be included in the generated project as a pre-built archive. + ``` -make BSP=metal [PROGRAM=hello] [TARGET=sifive-hifive1] STANDALONE_DEST=/path/to/desired/location standalone +make BSP=metal [PROGRAM=hello] [TARGET=sifive-hifive1] [INCLUDE_METAL_SOURCES=1] STANDALONE_DEST=/path/to/desired/location standalone ``` Run `make help` for more commands. diff --git a/doc/sphinx/userguide/standalone.rst b/doc/sphinx/userguide/standalone.rst index 58f7f51..61214d2 100644 --- a/doc/sphinx/userguide/standalone.rst +++ b/doc/sphinx/userguide/standalone.rst @@ -8,7 +8,12 @@ Legacy Freedom E SDK. ``STANDALONE_DEST`` is a required argument to provide the desired project location. +You can include the argument ``INCLUDE_METAL_SOURCES=1`` if you would like to +include the sources for the Freedom Metal library in the generated standalone +project. If this argument is not included, then the Freedom Metal library will +be included in the generated project as a pre-built archive. + .. code-block:: bash - make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] STANDALONE_DEST=/path/to/desired/location standalone + make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] [INCLUDE_METAL_SOURCES=1] STANDALONE_DEST=/path/to/desired/location standalone -- cgit v1.2.3