1 #=======================================================================
2 # UCB VLSI FLOW: Makefile for riscv-bmarks
3 #-----------------------------------------------------------------------
4 # Yunsup Lee (yunsup@cs.berkeley.edu)
11 instname
= riscv-bmarks
12 instbasedir
= $(UCB_VLSI_HOME
)/install
14 #--------------------------------------------------------------------
16 #--------------------------------------------------------------------
42 #--------------------------------------------------------------------
44 #--------------------------------------------------------------------
46 HOST_OPTS
= -std
=gnu99
-DPREALLOCATE
=0 -DHOST_DEBUG
=1
47 HOST_COMP
= gcc
$(HOST_OPTS
)
49 RISCV_PREFIX ?
= riscv64-unknown-elf-
50 RISCV_GCC ?
= $(RISCV_PREFIX
)gcc
51 RISCV_GCC_OPTS ?
= -static
-std
=gnu99
-O2
-ffast-math
-fno-common
-fno-builtin-printf
52 RISCV_LINK ?
= $(RISCV_GCC
) -T
$(bmarkdir
)/common
/test.
ld $(incs
)
53 RISCV_LINK_MT ?
= $(RISCV_GCC
) -T
$(bmarkdir
)/common
/test-mt.
ld
54 RISCV_LINK_OPTS ?
= -nostdlib
-nostartfiles
-ffast-math
-lc
-lgcc
55 RISCV_OBJDUMP ?
= $(RISCV_PREFIX
)objdump
--disassemble-all
--disassemble-zeroes
--section
=.text
--section
=.text.startup
--section
=.data
58 VPATH
+= $(addprefix $(bmarkdir
)/, $(bmarks
))
59 VPATH
+= $(bmarkdir
)/common
61 incs
+= -I
$(bmarkdir
)/..
/env
-I
$(bmarkdir
)/common
$(addprefix -I
$(bmarkdir
)/, $(bmarks
))
64 include $(patsubst %, $(bmarkdir
)/%/bmark.mk
, $(bmarks
))
66 #------------------------------------------------------------
67 # Build and run benchmarks on riscv simulator
69 bmarks_riscv_bin
= $(addsuffix .riscv
, $(bmarks
))
70 bmarks_riscv_dump
= $(addsuffix .riscv.dump
, $(bmarks
))
71 bmarks_riscv_hex
= $(addsuffix .riscv.hex
, $(bmarks
))
72 bmarks_riscv_out
= $(addsuffix .riscv.out
, $(bmarks
))
74 bmarks_defs
= -DPREALLOCATE
=1 -DHOST_DEBUG
=0
78 elf2hex
16 32768 $< > $@
80 $(bmarks_riscv_dump
): %.riscv.dump
: %.riscv
81 $(RISCV_OBJDUMP
) $< > $@
83 $(bmarks_riscv_out
): %.riscv.out
: %.riscv
87 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) \
91 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) -D__ASSEMBLY__
=1 \
94 riscv
: $(bmarks_riscv_dump
) $(bmarks_riscv_hex
)
95 run-riscv
: $(bmarks_riscv_out
)
96 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
97 $(bmarks_riscv_out
); echo
;
99 junk
+= $(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(bmarks_riscv_hex
) $(bmarks_riscv_out
)
101 #------------------------------------------------------------
102 # Build and run benchmarks on host machine
104 bmarks_host_bin
= $(addsuffix .host
, $(bmarks_host
))
105 bmarks_host_out
= $(addsuffix .host.out
, $(bmarks_host
))
107 $(bmarks_host_out
): %.host.out
: %.host
110 host
: $(bmarks_host_bin
)
111 run-host
: $(bmarks_host_out
)
112 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
113 $(bmarks_host_out
); echo
;
115 junk
+= $(bmarks_host_bin
) $(bmarks_host_out
)
117 #------------------------------------------------------------
122 #------------------------------------------------------------
125 date_suffix
= $(shell date
+%Y-
%m-
%d_
%H-
%M
)
126 install_dir
= $(instbasedir
)/$(instname
)-$(date_suffix
)
127 latest_install
= $(shell ls
-1 -d
$(instbasedir
)/$(instname
)* | tail
-n
1)
131 cp
-r
$(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(install_dir
)
134 rm -rf
$(instbasedir
)/$(instname
)
135 ln
-s
$(latest_install
) $(instbasedir
)/$(instname
)
137 #------------------------------------------------------------
141 rm -rf
$(objs
) $(junk
)