+ scripts/config --disable CONFIG_STACK_VALIDATION
+
+ # Cause problems with inline assembly on i386
+ scripts/config --disable CONFIG_DEBUG_SECTION_MISMATCH
+
+ # Don't build samples, they are broken on some kernel releases
+ scripts/config --disable CONFIG_SAMPLES
+ scripts/config --disable CONFIG_BUILD_DOCSRC
+
+ # Disable kcov
+ scripts/config --disable CONFIG_KCOV
+
+ # Broken on some RT kernels
+ scripts/config --disable CONFIG_HYPERV
+
+ # Broken drivers
+ scripts/config --disable CONFIG_RAPIDIO_TSI721
+ scripts/config --disable CONFIG_SGI_XP
+ scripts/config --disable CONFIG_MFD_WM8994
+ scripts/config --disable CONFIG_DRM_RADEON
+ scripts/config --disable CONFIG_SND_SOC_WM5100
+
+ # IGBVF won't build with recent gcc on 2.6.38.x
+ if { vergte "$kversion" "2.6.37" && verlt "$kversion" "2.6.38"; }; then
+ scripts/config --disable CONFIG_IGBVF
+ fi
+
+ # Don't fail the build on warnings
+ scripts/config --disable CONFIG_WERROR
+
+ # Set required options
+ scripts/config --enable CONFIG_TRACEPOINTS
+ scripts/config --enable CONFIG_KALLSYMS
+ scripts/config --enable CONFIG_HIGH_RES_TIMERS
+ scripts/config --enable CONFIG_KPROBES
+ scripts/config --enable CONFIG_FTRACE
+ scripts/config --enable CONFIG_BLK_DEV_IO_TRACE
+ scripts/config --enable CONFIG_KALLSYMS_ALL
+ scripts/config --enable CONFIG_HAVE_SYSCALL_TRACEPOINTS
+ scripts/config --enable CONFIG_PERF_EVENTS
+ scripts/config --enable CONFIG_EVENT_TRACING
+ scripts/config --enable CONFIG_KRETPROBES
+
+ # FIXME: disable objtool on vmlinux, it OOMs on allyesconfig
+ sed -i 's/objtool_link vmlinux.o//' scripts/link-vmlinux.sh || true
+ # Starting with v6.1-rc6
+ sed -i 's/^objtool-enabled := .*/objtool-enabled := /' scripts/Makefile.vmlinux_o || true
+
+ # Disable SORTTAB
+ sed -i 's/is_enabled CONFIG_BUILDTIME_TABLE_SORT/is_enabled CONFIG_NONEXISTANT/' scripts/link-vmlinux.sh || true
+
+ # Debug
+ #cat .config
+
+ make "$update_conf_target" CC="$CC"
+ make -j"$NPROC" CC="$CC"
+
+ krelease=$(make -s kernelrelease CC="$CC")
+
+ # Save the kernel and modules
+ mkdir -p "$LINUX_INSTOBJ_DIR/boot"
+ make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_MOD_STRIP=1 modules_install CC="$CC"
+ make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot" install CC="$CC"
+ rm -f "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/build"
+ ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
+ ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
+}
+
+
+extract_distro_headers() {
+
+ # Enter linux source dir
+ cd "${LINUX_SRCOBJ_DIR}"
+
+
+ # For RT kernels, copy version file
+ if [ -s localversion-rt ]; then
+ cp -a localversion-rt "${LINUX_HDROBJ_DIR}"
+ fi
+
+ # Copy all Makefile related stuff
+ find . -path './include/*' -prune \
+ -o -path './scripts/*' -prune -o -type f \
+ \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
+ -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
+ -print | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
+
+ # Copy base scripts and include dirs
+ cp -a scripts include "${LINUX_HDROBJ_DIR}"
+
+ # Copy arch includes
+ (find arch -name include -type d -print0 | \
+ xargs -0 -n1 -i: find : -type f) | \
+ cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
+
+ # Copy arch scripts
+ (find arch -name scripts -type d -print0 | \
+ xargs -0 -n1 -i: find : -type f) | \
+ cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
+
+ # Cleanup scripts
+ rm -f "${LINUX_HDROBJ_DIR}/scripts/*.o"
+ rm -f "${LINUX_HDROBJ_DIR}/scripts/*/*.o"
+
+ # On powerpc 32bits this object is required to link modules
+ if [ "${karch}" = "powerpc" ]; then
+ if [ "x$(scripts/config -s CONFIG_PPC64)" = "xy" ] && vergte "${kversion}" "5.4"; then
+ :
+ else
+ cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LINUX_HDROBJ_DIR}/"
+ fi
+ fi
+
+ # On arm64 between 4.13 and 1.15 this object is required to build with ftrace support
+ if [ "${karch}" = "arm64" ]; then
+ if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then
+ cp -a --parents arch/arm64/kernel/ftrace-mod.[So] "${LINUX_HDROBJ_DIR}/"
+ fi
+ fi
+
+ # Newer kernels need objtool to build modules when CONFIG_STACK_VALIDATION=y
+ if [ -f tools/objtool/objtool ]; then
+ cp -a --parents tools/objtool/objtool "${LINUX_HDROBJ_DIR}/"
+ fi
+
+ if [ -f "arch/x86/kernel/macros.s" ]; then
+ cp -a --parents arch/x86/kernel/macros.s "${LINUX_HDROBJ_DIR}/"
+ fi
+
+ # Copy modules related stuff, if available
+ if [ -s Module.symvers ]; then
+ cp Module.symvers "${LINUX_HDROBJ_DIR}"
+ fi
+
+ if [ -s System.map ]; then
+ cp System.map "${LINUX_HDROBJ_DIR}"
+ fi
+
+ if [ -s Module.markers ]; then
+ cp Module.markers "${LINUX_HDROBJ_DIR}"
+ fi
+
+ # Copy config file
+ cp .config "${LINUX_HDROBJ_DIR}"
+
+ # Make sure the Makefile and version.h have a matching timestamp so that
+ # external modules can be built
+ if [ -s "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h" ]; then
+ touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h"
+ elif [ -s "${LINUX_HDROBJ_DIR}/include/linux/version.h" ]; then
+ touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/linux/version.h"
+ else
+ echo "Missing version.h"
+ exit 1
+ fi
+ touch -r "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/generated/autoconf.h"
+
+ # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
+ if [ ! -f "${LINUX_HDROBJ_DIR}/include/config/auto.conf" ]; then
+ cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf"
+ fi