%build
-make \
+mkdir build32 build64
+# Build 32 bit firmware.
+%make_build \
+ O=build32 \
+ CROSS_COMPILE=riscv64-linux-gnu- \
+ PLATFORM=generic \
+ PLATFORM_RISCV_XLEN=32
+# Build 64 bit firmware.
+%make_build \
+ O=build32 \
CROSS_COMPILE=riscv64-linux-gnu- \
PLATFORM=generic
%install
-make \
+# Install 32 bit firmware.
+%make_install \
+ O=build32 \
CROSS_COMPILE=riscv64-linux-gnu- \
PLATFORM=generic \
+ PLATFORM_RISCV_XLEN=32 \
I=%{buildroot} \
- INSTALL_LIB_PATH=lib64 \
- INSTALL_FIRMWARE_PATH=%{_datadir}/%{name} \
- install
-
-rm -rfv %{buildroot}/lib64
+ INSTALL_LIB_PATH=%{_libdir} \
+ INSTALL_FIRMWARE_PATH=%{_datadir}/%{name}
+pushd %{buildroot}%{_datadir}/%{name}/generic/firmware
+for f in fw_*.bin fw_*.elf; do
+ mv $f riscv32_$f
+done
+popd
+
+# Install 64 bit firmware.
+%make_install \
+ O=build64 \
+ CROSS_COMPILE=riscv64-linux-gnu- \
+ PLATFORM=generic \
+ I=%{buildroot} \
+ INSTALL_LIB_PATH=%{_libdir} \
+ INSTALL_FIRMWARE_PATH=%{_datadir}/%{name}
+pushd %{buildroot}%{_datadir}/%{name}/generic/firmware
+for f in fw_*.bin fw_*.elf; do
+ mv $f riscv64_$f
+done
+popd
+
+# Remove development libraries and headers for the time being.
+rm -rfv %{buildroot}%{_libdir}
rm -rfv %{buildroot}/include
+
+# Remove the example/testing payloads.
rm -rfv %{buildroot}%{_datadir}/%{name}/*/firmware/payloads