For some reason, it seems the usual way of compiling a Linux kernel does not work on Raspberry Pi platforms ; genkernel also fails. This script fixes that (please note this is a very quick hack and can obviously be improved)
Raspberry 4
#!/bin/bash
cd linux
KERNEL=kernel8
make clean
make mrproper
make -j 4 bcm2711_defconfig &&
make prepare &&
make oldconfig &&
make menuconfig &&
make -j 4 &&
make -j 4 modules dtbs &&
make modules_install &&
#cp -v arch/arm64/boot/Image /boot/kernel8-p4.img
cp -v arch/arm64/boot/Image /boot/kernel8.img
cp -v arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb /boot/
cp arch/arm64/boot/dts/broadcom/*.dtb /boot/
cp arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/
cp arch/arm64/boot/dts/overlays/README /boot/overlays/
Raspberry 3
#!/bin/bash
# building rpi3 kernel (needed anyway AFAIK)
cd linux
make distclean
make bcmrpi3_defconfig
# options for Rpi3 kernel
make menuconfig
nice -n 19 make -j4 Image modules dtbs
# now as root
cp -v arch/arm64/boot/Image /boot/kernel8.img
cp -v arch/arm64/boot/dts/broadcom/bcm{2710,2837}-rpi-3-b.dtb /boot/
cp -v arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b-plus.dtb /boot/
cp -v arch/arm64/boot/dts/broadcom/bcm2710-rpi-cm3.dtb /boot/
cp -rv arch/arm64/boot/dts/overlays/ /boot/
make modules_install
sync
# now configure and build Rpi4 kernel
make distclean
make bcm2711_defconfig
make menuconfig
read -p "Make sure to set CONFIG_LOCALVERSION to something distinct (like "-2711") to ensure the release names of the two kernels are distinct - you don't want their modules getting co-mingled in /lib/modules/<kernel-release-name>/.... Make any other changes you want, then save and exit the configuration tool, and hit [enter]"
nice -n 19 make -j4 Image modules dtbs
cp -v arch/arm64/boot/Image /boot/kernel8-p4.img
cp -v arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb /boot/
make modules_install