summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Graff <nathaniel.graff@sifive.com>2019-03-12 14:56:26 -0700
committerNathaniel Graff <nathaniel.graff@sifive.com>2019-03-13 09:59:50 -0700
commit266a2118af56c0fb6f123a5622192b22e0ca8a57 (patch)
treea18e7cf9392cb5e8a584ffb7ad3fe2c1609df0ad
parenta08201f87076002f585edac7e94b28c7ebf22cc1 (diff)
Enable elf2hex in standalone projects
Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
-rw-r--r--Makefile62
-rw-r--r--scripts/standalone.mk27
2 files changed, 59 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index 3853c53..7f3eafb 100644
--- a/Makefile
+++ b/Makefile
@@ -125,26 +125,6 @@ list-options: list-programs list-targets
include scripts/libmetal.mk
#############################################################
-# elf2hex
-#############################################################
-scripts/elf2hex/build/Makefile: scripts/elf2hex/configure
- @rm -rf $(dir $@)
- @mkdir -p $(dir $@)
- cd $(dir $@); \
- $(abspath $<) \
- --prefix=$(abspath $(dir $<))/install \
- --target=$(CROSS_COMPILE)
-
-scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex: scripts/elf2hex/build/Makefile
- $(MAKE) -C $(dir $<) install
- touch -c $@
-
-.PHONY: clean-elf2hex
-clean-elf2hex:
- rm -rf scripts/elf2hex/build scripts/elf2hex/install
-clean: clean-elf2hex
-
-#############################################################
# Standalone Project Export
#############################################################
@@ -157,6 +137,7 @@ $(STANDALONE_DEST):
$(STANDALONE_DEST)/%:
mkdir -p $@
+ifneq ($(COREIP_MEM_WIDTH),)
standalone: \
$(STANDALONE_DEST) \
$(STANDALONE_DEST)/bsp \
@@ -165,6 +146,7 @@ standalone: \
freedom-metal \
debug.mk \
release.mk \
+ scripts/elf2hex \
scripts/standalone.mk \
scripts/libmetal.mk
cp -r $(addprefix $(BSP_DIR)/,$(filter-out build,$(shell ls $(BSP_DIR)))) $</bsp/
@@ -173,6 +155,11 @@ standalone: \
find $</freedom-metal -name ".git*" | xargs rm
+ mkdir -p $</scripts
+ cp -r scripts/elf2hex $</scripts
+
+ find $</scripts/elf2hex -name ".git*" | xargs rm
+
$(MAKE) -C $(SRC_DIR) clean
cp -r $(SRC_DIR)/* $</src/
@@ -182,19 +169,34 @@ standalone: \
echo "PROGRAM = $(PROGRAM)" > $</Makefile
cat scripts/standalone.mk >> $</Makefile
cat scripts/libmetal.mk >> $</Makefile
+else
+standalone: \
+ $(STANDALONE_DEST) \
+ $(STANDALONE_DEST)/bsp \
+ $(STANDALONE_DEST)/src \
+ $(SRC_DIR) \
+ freedom-metal \
+ debug.mk \
+ release.mk \
+ scripts/standalone.mk \
+ scripts/libmetal.mk
+ cp -r $(addprefix $(BSP_DIR)/,$(filter-out build,$(shell ls $(BSP_DIR)))) $</bsp/
-endif
+ cp -r freedom-metal $</
-#############################################################
-# CoreIP RTL Simulation Hex File Creation
-#############################################################
+ find $</freedom-metal -name ".git*" | xargs rm
+
+ $(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
+ cat scripts/libmetal.mk >> $</Makefile
+endif
-# Use elf2hex if we're not using Segger J-Link OB (i.e. for coreip-rtl targets)
-ifeq ($(SEGGER_JLINK_OB),)
-$(PROGRAM_HEX): \
- scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex \
- $(PROGRAM_ELF)
- $< --output $@ --input $(PROGRAM_ELF) --bit-width $(COREIP_MEM_WIDTH)
endif
#############################################################
diff --git a/scripts/standalone.mk b/scripts/standalone.mk
index 17fec17..c9da448 100644
--- a/scripts/standalone.mk
+++ b/scripts/standalone.mk
@@ -155,8 +155,15 @@ $(PROGRAM_HEX): \
$(RISCV_OBJCOPY) \
$(PROGRAM_ELF)
$< -O ihex $(PROGRAM_ELF) $@
+else
+# Use elf2hex if we're not using Segger J-Link OB (i.e. for coreip-rtl targets)
+$(PROGRAM_HEX): \
+ scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex \
+ $(PROGRAM_ELF)
+ $< --output $@ --input $(PROGRAM_ELF) --bit-width $(COREIP_MEM_WIDTH)
endif
+
.PHONY: clean-software
clean-software:
$(MAKE) -C $(SRC_DIR) clean
@@ -164,3 +171,23 @@ clean-software:
.PHONY: clean
clean: clean-software
+#############################################################
+# elf2hex
+#############################################################
+scripts/elf2hex/build/Makefile: scripts/elf2hex/configure
+ @rm -rf $(dir $@)
+ @mkdir -p $(dir $@)
+ cd $(dir $@); \
+ $(abspath $<) \
+ --prefix=$(abspath $(dir $<))/install \
+ --target=$(CROSS_COMPILE)
+
+scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex: scripts/elf2hex/build/Makefile
+ $(MAKE) -C $(dir $<) install
+ touch -c $@
+
+.PHONY: clean-elf2hex
+clean-elf2hex:
+ rm -rf scripts/elf2hex/build scripts/elf2hex/install
+clean: clean-elf2hex
+