bianbu-linux-6.6/scripts/build_kernel.sh
lijuan a622772a43 scripts: support build 6.6 linux
Change-Id: I9f9b187b48336aa07384a5eb0b88b9f5b3fd24be
Signed-off-by: lijuan <juan.li@spacemit.com>
2025-02-07 14:47:56 +08:00

65 lines
1.5 KiB
Bash
Executable file

#!/bin/bash -e
SCRIPT="./scripts/build_kernel.sh"
CLEAN=false
BUILD_DEB=false
while getopts "cdh" opt
do
case $opt in
c)
CLEAN=true
;;
d)
BUILD_DEB=true
;;
?)
echo "Usage: Run on the top of linux directory"
echo "$SCRIPT [-c] [-d]"
exit 1
;;
esac
done
if [ $0 != $SCRIPT ]
then
echo "Run $(basename $SCRIPT) on the top of linux directory"
exit 1
fi
command -v riscv64-unknown-linux-gnu-gcc > /dev/null || \
(echo "Install cross compile and add to PATH" && exit 1)
VERSION=$(grep -oP '^VERSION\s*=\s*\K\d+' Makefile)
PATCHLEVEL=$(grep -oP '^PATCHLEVEL\s*=\s*\K\d+' Makefile)
SUBLEVEL=$(grep -oP '^SUBLEVEL\s*=\s*\K\d+' Makefile)
export ARCH=riscv
export CROSS_COMPILE=riscv64-unknown-linux-gnu-
export KERNELRELEASE=$VERSION.$PATCHLEVEL.$SUBLEVEL
export LOCALVERSION=""
if [ $CLEAN = true ]
then
make distclean
if [ $BUILD_DEB = true ]
then
rm -f ../linux-headers-$KERNELRELEASE_*_riscv64.deb
rm -f ../linux-image-$KERNELRELEASE_*_riscv64.deb
rm -f ../linux-image-$KERNELRELEASE-dbg_*_riscv64.deb
rm -f ../linux-libc-dev_*_riscv64.deb
rm -f ../linux-riscv-spacemit_*_riscv64.*
fi
fi
make k1_defconfig
if [ $BUILD_DEB = true ]
then
KDEB_SOURCENAME=linux-riscv-spacemit \
KDEB_PKGVERSION=$KERNELRELEASE-$(TZ=Asia/Shanghai date +"%Y%m%d%H%M%S") \
KDEB_CHANGELOG_DIST=mantic-porting \
make -j$(nproc) bindeb-pkg
else
make -j$(nproc)
fi