debug: Use more unique debug ROM names
[riscv-isa-sim.git] / debug_rom / Makefile
1 # Recursive make is bad, but in this case we're cross compiling which is a
2 # pretty unusual use case.
3
4 CC = $(RISCV)/bin/riscv64-unknown-elf-gcc
5 OBJCOPY = $(RISCV)/bin/riscv64-unknown-elf-objcopy
6
7 COMPILE = $(CC) -nostdlib -nostartfiles -I.. -Tlink.ld
8
9 ELFS = debug_rom
10 DEPS = debug_rom.S link.ld
11
12 all: $(patsubst %,%.h,$(ELFS)) $(patsubst %,%_defines.h,$(ELFS))
13
14 %_defines.h: %.S
15 grep define $^ > $@
16
17 %.h: %.raw
18 xxd -i $^ | sed "s/^unsigned/static const unsigned/" > $@
19
20 %.raw: %
21 $(OBJCOPY) -O binary --only-section .text $^ $@
22
23 debug_rom: $(DEPS)
24 $(COMPILE) -o $@ $^
25
26 clean:
27 rm -f $(ELFS) debug_rom*.raw debug_rom*.h