%define KMOD_PATH %{_libdir}/stability-monitor
+%ifarch aarch64
+%define buildarch arm64
+%else
+%define buildarch arm
+%endif
+
Name: stability-monitor-kmod-rpi3
Version: 6.2.1
Release: 0
Source1: %{name}.manifest
Summary: Stability monitoring kernel module
Group: System/Monitoring
-ExclusiveArch: armv7l
+BuildRequires: cmake
BuildRequires: module-init-tools
-BuildRequires: arm-rpi3-linux-kernel-devel
-BuildRequires: arm-rpi4-linux-kernel-devel
+BuildRequires: %{buildarch}-rpi3-linux-kernel-devel
+BuildRequires: %{buildarch}-rpi4-linux-kernel-devel
Provides: stability-monitor-kernel-module
+
%description
This package provides kernel module for stability monitoring daemon.
cp %{SOURCE1} ./%{name}.manifest
%build
-make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi3
-make -C kernel KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi3/
-make -C kernel modules_install KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi3 INSTALL_MOD_STRIP=1
+%cmake -DLIBPATH=%{_libdir}
+
+make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi3
+make -C kernel KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi3/
+make -C kernel modules_install KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi3 INSTALL_MOD_STRIP=1
+
+make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi4
+make -C kernel KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi4
+make -C kernel modules_install KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi4 INSTALL_MOD_STRIP=1
-make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi4
-make -C kernel KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi4
-make -C kernel modules_install KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi4 INSTALL_MOD_STRIP=1
%install
mkdir -p %{buildroot}/%{KMOD_PATH}
%clean
rm -rf %{buildroot}
-make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi3
-make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-arm-rpi4
+make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi3
+make -C kernel clean KERNELDIR=/boot/kernel/devel/kernel-devel-%{buildarch}-rpi4
rm -rf %{_builddir}/%{Name}-%{version}/lib
%files