1 #=======================================================================
2 # UCB VLSI FLOW: Makefile for riscv-bmarks
3 #-----------------------------------------------------------------------
4 # Yunsup Lee (yunsup@cs.berkeley.edu)
13 instname
= riscv-bmarks
14 instbasedir
= $(UCB_VLSI_HOME
)/install
16 #--------------------------------------------------------------------
18 #--------------------------------------------------------------------
33 #--------------------------------------------------------------------
35 #--------------------------------------------------------------------
37 RISCV_PREFIX ?
= riscv
$(XLEN
)-unknown-elf-
38 RISCV_GCC ?
= $(RISCV_PREFIX
)gcc
39 RISCV_GCC_OPTS ?
= -mcmodel
=medany
-static
-std
=gnu99
-O2
-ffast-math
-fno-common
-fno-builtin-printf
40 RISCV_LINK ?
= $(RISCV_GCC
) -T
$(src_dir
)/common
/test.
ld $(incs
)
41 RISCV_LINK_MT ?
= $(RISCV_GCC
) -T
$(src_dir
)/common
/test-mt.
ld
42 RISCV_LINK_OPTS ?
= -static
-nostdlib
-nostartfiles
-lgcc
43 RISCV_OBJDUMP ?
= $(RISCV_PREFIX
)objdump
--disassemble-all
--disassemble-zeroes
--section
=.text
--section
=.text.startup
--section
=.data
44 RISCV_SIM ?
= spike
--isa
=rv
$(XLEN
)gc
46 VPATH
+= $(addprefix $(src_dir
)/, $(bmarks
))
47 VPATH
+= $(src_dir
)/common
49 incs
+= -I
$(src_dir
)/..
/env
-I
$(src_dir
)/common
$(addprefix -I
$(src_dir
)/, $(bmarks
))
52 include $(patsubst %, $(src_dir
)/%/bmark.mk
, $(bmarks
))
54 #------------------------------------------------------------
55 # Build and run benchmarks on riscv simulator
57 bmarks_riscv_bin
= $(addsuffix .riscv
, $(bmarks
))
58 bmarks_riscv_dump
= $(addsuffix .riscv.dump
, $(bmarks
))
59 bmarks_riscv_out
= $(addsuffix .riscv.out
, $(bmarks
))
61 bmarks_defs
= -DPREALLOCATE
=1
64 $(bmarks_riscv_dump
): %.riscv.dump
: %.riscv
65 $(RISCV_OBJDUMP
) $< > $@
67 $(bmarks_riscv_out
): %.riscv.out
: %.riscv
71 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) \
75 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) -D__ASSEMBLY__
=1 \
78 riscv
: $(bmarks_riscv_dump
)
79 run-riscv
: $(bmarks_riscv_out
)
80 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
81 $(bmarks_riscv_out
); echo
;
83 junk
+= $(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(bmarks_riscv_hex
) $(bmarks_riscv_out
)
85 #------------------------------------------------------------
90 #------------------------------------------------------------
93 date_suffix
= $(shell date
+%Y-
%m-
%d_
%H-
%M
)
94 install_dir
= $(instbasedir
)/$(instname
)-$(date_suffix
)
95 latest_install
= $(shell ls
-1 -d
$(instbasedir
)/$(instname
)* | tail
-n
1)
99 cp
-r
$(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(install_dir
)
102 rm -rf
$(instbasedir
)/$(instname
)
103 ln
-s
$(latest_install
) $(instbasedir
)/$(instname
)
105 #------------------------------------------------------------
109 rm -rf
$(objs
) $(junk
)