aboutsummaryrefslogtreecommitdiff
path: root/debug_rom/Makefile
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-04-23 10:18:05 -0700
committerTim Newsome <tim@sifive.com>2016-05-23 12:12:11 -0700
commit7facb160390cbd6a1b19d62966fe5140425ee72a (patch)
tree031a5bd46d9933b6c84f11d08a48d8aa906ffad6 /debug_rom/Makefile
parent6835847f4798cc38f933ba877004eacfc1cbf593 (diff)
downloadspike-7facb160390cbd6a1b19d62966fe5140425ee72a.zip
spike-7facb160390cbd6a1b19d62966fe5140425ee72a.tar.gz
spike-7facb160390cbd6a1b19d62966fe5140425ee72a.tar.bz2
Clean up how Debug ROM is included.
I'm not thrilled about including a static copy in so many cc files, and making the compiler throw it out. But without really grokking the Makefile this is the best it's going to be.
Diffstat (limited to 'debug_rom/Makefile')
-rw-r--r--debug_rom/Makefile20
1 files changed, 20 insertions, 0 deletions
diff --git a/debug_rom/Makefile b/debug_rom/Makefile
new file mode 100644
index 0000000..d66b84f
--- /dev/null
+++ b/debug_rom/Makefile
@@ -0,0 +1,20 @@
+# Recursive make is bad, but in this case we're cross compiling which is a
+# pretty unusual use case.
+
+CC = $(RISCV)/bin/riscv64-unknown-elf-gcc
+OBJCOPY = $(RISCV)/bin/riscv64-unknown-elf-objcopy
+
+%.o: %.S
+ $(CC) -c $<
+
+debug_rom.h: debug_rom.raw
+ xxd -i $^ | sed "s/^unsigned/static const unsigned/" > $@
+
+debug_rom.raw: debug_rom
+ $(OBJCOPY) -O binary --only-section .text debug_rom debug_rom.raw
+
+debug_rom: debug_rom.o
+ $(CC) -nostdlib -nostartfiles -Tlink.ld -o $@ $^
+
+clean:
+ rm -f debug_rom debug_rom.o debug_rom.raw debug_rom.h