diff options
author | Nathaniel Graff <nathaniel.graff@sifive.com> | 2019-03-12 10:09:10 -0700 |
---|---|---|
committer | Nathaniel Graff <nathaniel.graff@sifive.com> | 2019-03-12 15:37:07 -0700 |
commit | 1b72ca73835d6064b467a126a392f4539fa2f10a (patch) | |
tree | 2cadf4a3e7d05df28a8f8cbeb5cf386456f8e0f4 | |
parent | ebe73c01fbdf73b3b4c6beaf089edb7ee394aa0b (diff) |
Build metal libs into install/lib/CONFIGURATION
Removes the INCLUDE_METAL_SOURCES option. If we want to be able to
support multiple build configurations for standalone projects, the Metal
library must be rebuilt to take into account those options.
An alternative is to put back the prebuilt library option and just
remove the configuration option from standalone projects without the
Metal library sources.
Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
-rw-r--r-- | Makefile | 27 | ||||
-rw-r--r-- | doc/sphinx/userguide/standalone.rst | 7 | ||||
-rw-r--r-- | scripts/libmetal.mk | 23 | ||||
-rw-r--r-- | scripts/standalone.mk | 4 |
4 files changed, 18 insertions, 43 deletions
@@ -88,8 +88,7 @@ help: @echo " running program." @echo "" @echo " standalone STANDALONE_DEST=/path/to/desired/location" - @echo " [INCLUDE_METAL_SOURCES=1] [PROGRAM=$(PROGRAM)]" - @echo " [TARGET=$(TARGET)] [CONFIGURATION=$(CONFIGURATION)]:" + @echo " [PROGRAM=$(PROGRAM)] [TARGET=$(TARGET)]:" @echo " Exports a program for a single target into a standalone" @echo " project directory at STANDALONE_DEST." @echo "" @@ -158,8 +157,6 @@ $(STANDALONE_DEST): $(STANDALONE_DEST)/%: mkdir -p $@ -ifneq ($(INCLUDE_METAL_SOURCES),) - standalone: \ $(STANDALONE_DEST) \ $(STANDALONE_DEST)/bsp \ @@ -186,28 +183,6 @@ standalone: \ cat scripts/standalone.mk >> $</Makefile cat scripts/libmetal.mk >> $</Makefile -else -standalone: \ - $(STANDALONE_DEST) \ - $(STANDALONE_DEST)/bsp \ - $(STANDALONE_DEST)/src \ - $(BSP_DIR)/install/lib/libmetal.a \ - $(BSP_DIR)/install/lib/libmetal-gloss.a \ - $(SRC_DIR) \ - debug.mk \ - release.mk \ - scripts/standalone.mk - cp -r $(addprefix $(BSP_DIR)/,$(filter-out build,$(shell ls $(BSP_DIR)))) $</bsp/ - - $(MAKE) -C $(SRC_DIR) clean - cp -r $(SRC_DIR)/* $</src/ - - cp debug.mk $</debug.mk - cp release.mk $</release.mk - - echo "PROGRAM = $(PROGRAM)" > $</Makefile - cat scripts/standalone.mk >> $</Makefile -endif endif ############################################################# diff --git a/doc/sphinx/userguide/standalone.rst b/doc/sphinx/userguide/standalone.rst index 0703ddb..e71ecaa 100644 --- a/doc/sphinx/userguide/standalone.rst +++ b/doc/sphinx/userguide/standalone.rst @@ -8,12 +8,7 @@ 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 [PROGRAM=hello] [TARGET=sifive-hifive1] [CONFIGURATION=debug] [INCLUDE_METAL_SOURCES=1] STANDALONE_DEST=/path/to/desired/location standalone + make [PROGRAM=hello] [TARGET=sifive-hifive1] STANDALONE_DEST=/path/to/desired/location standalone diff --git a/scripts/libmetal.mk b/scripts/libmetal.mk index 97ce543..b443ca7 100644 --- a/scripts/libmetal.mk +++ b/scripts/libmetal.mk @@ -6,17 +6,22 @@ METAL_SOURCE_PATH ?= freedom-metal METAL_LDSCRIPT = $(BSP_DIR)/metal.lds METAL_HEADER = $(BSP_DIR)/metal.h +METAL_PREFIX = $(abspath $(BSP_DIR)/install) +METAL_BUILD_DIR = $(abspath $(BSP_DIR)/build/$(CONFIGURATION)) +METAL_LIB_DIR = $(abspath $(BSP_DIR)/install/lib/$(CONFIGURATION)) + .PHONY: metal -metal: $(BSP_DIR)/install/stamp +metal: $(METAL_LIB_DIR)/stamp -$(BSP_DIR)/build/Makefile: +$(METAL_BUILD_DIR)/Makefile: @rm -rf $(dir $@) @mkdir -p $(dir $@) cd $(dir $@) && \ CFLAGS="$(RISCV_CFLAGS)" \ $(abspath $(METAL_SOURCE_PATH)/configure) \ --host=$(CROSS_COMPILE) \ - --prefix=$(abspath $(BSP_DIR)/install) \ + --prefix=$(METAL_PREFIX) \ + --libdir=$(METAL_LIB_DIR) \ --disable-maintainer-mode \ --with-preconfigured \ --with-machine-name=$(TARGET) \ @@ -25,21 +30,21 @@ $(BSP_DIR)/build/Makefile: --with-builtin-libgloss touch -c $@ -$(BSP_DIR)/install/stamp: $(BSP_DIR)/build/Makefile - $(MAKE) -C $(abspath $(BSP_DIR)/build) install +$(METAL_LIB_DIR)/stamp: $(BSP_DIR)/build/$(CONFIGURATION)/Makefile + $(MAKE) -C $(abspath $(BSP_DIR)/build/$(CONFIGURATION)) install date > $@ -$(BSP_DIR)/install/lib/libriscv%.a: $(BSP_DIR)/install/stamp ;@: +$(METAL_LIB_DIR)/libriscv%.a: $(METAL_LIB_DIR)/stamp ;@: -$(BSP_DIR)/install/lib/libmetal.a: $(BSP_DIR)/install/lib/libriscv__mmachine__$(TARGET).a +$(METAL_LIB_DIR)/libmetal.a: $(METAL_LIB_DIR)/libriscv__mmachine__$(TARGET).a cp $< $@ -$(BSP_DIR)/install/lib/libmetal-gloss.a: $(BSP_DIR)/install/lib/libriscv__menv__metal.a +$(METAL_LIB_DIR)/libmetal-gloss.a: $(METAL_LIB_DIR)/libriscv__menv__metal.a cp $< $@ .PHONY: clean-metal clean-metal: - rm -rf $(BSP_DIR)/install + rm -rf $(METAL_PREFIX) rm -rf $(BSP_DIR)/build clean: clean-metal diff --git a/scripts/standalone.mk b/scripts/standalone.mk index ac5635f..73b9776 100644 --- a/scripts/standalone.mk +++ b/scripts/standalone.mk @@ -132,8 +132,8 @@ PROGRAM_SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.h) $(wildcard $(PROGRAM_ELF): \ $(PROGRAM_SRCS) \ - $(BSP_DIR)/install/lib/libmetal.a \ - $(BSP_DIR)/install/lib/libmetal-gloss.a \ + $(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal.a \ + $(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal-gloss.a \ $(BSP_DIR)/metal.lds $(MAKE) -C $(dir $@) $(basename $(notdir $@)) \ AR=$(RISCV_AR) \ |