fedora-zen-custom/SPECS/linux-zen.spec

85 lines
2.2 KiB
RPMSpec

%global debug_package %{nil}
%global zen zen1
Name: linux-zen
Version: 6.7.6
Release: 2%{?dist}
Summary: Linux kernel and modules with Zen patches
License: GPL-2.0-only
URL: http://www.zen-kernel.org/
Source0: v%{version}-%{zen}.tar.gz
BuildRequires: gcc, make, flex, bison, ncurses-devel, elfutils-libelf-devel, openssl-devel
%description
Linux kernel and modules with Zen patches (%{version} series) compiled with Clang.
%prep
%setup -q -n zen-kernel-%{version}-%{zen}
cp %{_sourcedir}/.config .config
# Apply all patch files in a shell loop
for patch in %{_sourcedir}/*.patch; do
echo "Applying $patch"
patch -p1 < $patch
done
%build
# Set environment variables for Clang and LLVM tools
export CC=clang
export CXX=clang++
export LD=ld.lld
export AR=llvm-ar
export NM=llvm-nm
export STRIP=llvm-strip
export OBJCOPY=llvm-objcopy
export OBJDUMP=llvm-objdump
export HOSTCC=clang
export HOSTCXX=clang++
export HOSTLD=ld.lld
export HOSTAR=llvm-ar
export HOSTNM=llvm-nm
export HOSTSTRIP=llvm-strip
export HOSTOBJCOPY=llvm-objcopy
export HOSTOBJDUMP=llvm-objdump
# Adjust CFLAGS and LDFLAGS to remove unsupported and unused arguments when using Clang
%if "%{__cc}" == "clang"
export CFLAGS=$(echo %{optflags} | sed 's/-ffat-lto-objects//')
export CXXFLAGS=$(echo %{optflags} | sed 's/-ffat-lto-objects//')
export LDFLAGS=$(echo %{__global_ldflags} | sed 's/-specs=\/usr\/lib\/rpm\/redhat\/redhat-hardened-ld//')
%else
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
export LDFLAGS="%{__global_ldflags}"
%endif
make LLVM=1 %{?_smp_mflags}
%install
make modules_install INSTALL_MOD_PATH=%{buildroot}
VMLINUX_PATH=%{buildroot}/boot
mkdir -p $VMLINUX_PATH
cd %{_builddir}/zen-kernel-%{version}-zen1/arch/x86/boot
cp bzImage $VMLINUX_PATH/vmlinuz-%{version}-%{zen}.fc39.x86_64
cd %{_builddir}/zen-kernel-%{version}-zen1
cp %{_sourcedir}/.config $VMLINUX_PATH/config-%{version}-%{zen}.fc39.x86_64
make headers_install INSTALL_HDR_PATH=%{buildroot}/usr/include
%files
/boot/vmlinuz-%{version}-%{zen}.fc39.x86_64
/boot/config-%{version}-%{zen}.fc39.x86_64
/lib/modules/*
/usr/include/*
%changelog
* Fri Jan 27 2024 Wizzard <rich@bandaholics.cash>
- Initial package version