From 742360812845743f6eb67813fbb97ee60029c45c Mon Sep 17 00:00:00 2001
From: Nathaniel Graff <nathaniel.graff@sifive.com>
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 <nathaniel.graff@sifive.com>
---
 Makefile | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

(limited to 'Makefile')

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)))) $</bsp/
+
+	cp -r freedom-metal $</
+
+	find $</freedom-metal -name ".git*" | xargs rm
+
+	$(MAKE) -C $(SRC_DIR) clean
+	cp -r $(SRC_DIR)/* $</src/
+
+	echo "PROGRAM = $(PROGRAM)" > $</Makefile
+	cat scripts/standalone.mk >> $</Makefile
+	cat scripts/libmetal.mk >> $</Makefile
+
+else
 standalone: \
 		$(STANDALONE_DEST) \
 		$(STANDALONE_DEST)/bsp \
@@ -190,6 +212,7 @@ standalone: \
 	cat scripts/standalone.mk >> $</Makefile
 endif
 endif
+endif
 
 #############################################################
 # MEE Software Compilation
-- 
cgit v1.2.3