# Build only the akmod package and no kernel module packages: %define buildforkernels akmod %global debug_package %{nil} Name: whalemod-kmod Version: 0.3.1 Release: %autorelease Summary: Kernel module with whales License: MIT URL: https://github.com/xbt573/whalemod Source0: https://github.com/xbt573/whalemod/archive/refs/tags/%{version}.tar.gz # Get the needed BuildRequires (in parts depending on what we build for): BuildRequires: kmodtool # kmodtool does its magic here %{expand:%(kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) } %description Kernel module with whales %prep # error out if there was something wrong with kmodtool %{?kmodtool_check} # print kmodtool output for debugging purposes: kmodtool --target %{_target_cpu} --repo %{repo} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null %setup -q -c -T -a 0 for kernel_version in %{?kernel_versions} ; do cp -a foo-%{version} _kmod_build_${kernel_version%%___*} done %build for kernel_version in %{?kernel_versions}; do make %{?_smp_mflags} -C "${kernel_version##*___}" SUBDIRS=${PWD}/_kmod_build_${kernel_version%%___*} modules done %install rm -rf ${RPM_BUILD_ROOT} for kernel_version in %{?kernel_versions}; do make install DESTDIR=${RPM_BUILD_ROOT} KMODPATH=%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix} # install -D -m 755 _kmod_build_${kernel_version%%___*}/foo/foo.ko ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/foo.ko done %{?akmod_install} %clean rm -rf $RPM_BUILD_ROOT %changelog %autochangelog