--- /dev/null
+# Debuginfo and stripping makes no sense for this package.
+%global debug_package %{nil}
+%global __strip /bin/true
+%global _binaries_in_noarch_packages_terminate_build 0
+
+Name: opensbi
+Version: 0.9
+Release: 1%{?dist}
+Summary: RISC-V Open Source Supervisor Binary Interface (OpenSBI)
+
+License: BSD
+URL: https://github.com/riscv-software-src/opensbi
+
+Source0: https://github.com/riscv-software-src/%{name}/archive/refs/tags/v%{version}.tar.gz
+
+BuildRequires: gcc-riscv64-linux-gnu
+BuildRequires: binutils-riscv64-linux-gnu
+
+# The -devel subpackage contains riscv64 code so you'll get:
+# > Arch dependent binaries in noarch package
+Buildarch: noarch
+
+
+%description
+The RISC-V Supervisor Binary Interface (SBI) is the firmware
+used to boot RISC-V virtual machines in qemu.
+
+
+%package devel
+Summary: Development files for %{name}
+# NB: Doesn't require the base package because it doesn't need it.
+
+
+%description devel
+This package contains development files (headers, libraries, etc)
+for %{name}.
+
+
+%prep
+%setup -q -n opensbi-%{version}
+
+
+%build
+%global platforms generic
+for platform in %{platforms}; do
+ make CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=$platform %{?_smp_mflags}
+done
+
+
+%install
+# This installs into the install/ subdirectory ...
+for platform in %{platforms}; do
+ make CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=$platform %{?_smp_mflags} \
+ install
+done
+# ... and we copy the files we want to the desired locations.
+
+mkdir -p %{buildroot}%{_libdir}
+cp -a install/usr/lib64/* %{buildroot}%{_libdir}
+
+mkdir -p %{buildroot}%{_includedir}
+cp -a install/usr/include/* %{buildroot}%{_includedir}
+
+mkdir -p %{buildroot}%{_datadir}
+cp -a install/usr/share/opensbi %{buildroot}%{_datadir}/%{name}
+
+
+%files
+%{_datadir}/%{name}
+
+
+%files devel
+%dir %{_libdir}/lp64
+%{_libdir}/lp64/libsbi*.a
+%{_libdir}/lp64/opensbi/generic/lib/libplatsbi.a
+%{_includedir}/sbi/
+%{_includedir}/sbi_utils/
+
+
+%changelog
+* Mon Sep 20 2021 Richard W.M. Jones <rjones@redhat.com> - 0.9-1
+- Initial release.