+prepare_lnx_sources() {
+
+ outdir=$1
+
+ if [ "$outdir" = "." ]; then
+ koutput=""
+ else
+ koutput="O=\"${outdir}\""
+ fi
+
+ # Generate kernel configuration
+ case "$kversion" in
+ Ubuntu*)
+ fakeroot debian/rules clean
+ fakeroot debian/rules genconfigs
+ cp CONFIGS/${ubuntu_config} "${outdir}"/.config
+ ;;
+ *)
+ # Que sera sera
+ make ${koutput} allyesconfig
+ ;;
+ esac
+
+ # GCC 4.8
+ sed -i "s/CONFIG_CC_STACKPROTECTOR_STRONG=y/# CONFIG_CC_STACKPROTECTOR_STRONG is not set/g" "${outdir}"/.config
+
+ # Don't try to sign modules
+ sed -i "s/CONFIG_MODULE_SIG=y/# CONFIG_MODULE_SIG is not set/g" "${outdir}"/.config
+
+ # Disable kernel stack frame correctness validation, introduced in 4.6.0 and currently fails
+ sed -i "s/CONFIG_STACK_VALIDATION=y/# CONFIG_STACK_VALIDATION is not set/g" "${outdir}"/.config
+
+ # Enable CONFIG_KALLSYMS_ALL
+ echo "CONFIG_KPROBES=y" >> "${outdir}"/.config
+ echo "CONFIG_FTRACE=y" >> "${outdir}"/.config
+ echo "CONFIG_BLK_DEV_IO_TRACE=y" >> "${outdir}"/.config
+ echo "CONFIG_TRACEPOINTS=y" >> "${outdir}"/.config
+ echo "CONFIG_KALLSYMS_ALL=y" >> "${outdir}"/.config
+
+
+ make ${koutput} silentoldconfig
+ make ${koutput} modules_prepare
+
+ # Version specific tasks
+ case "$kversion" in
+ Ubuntu*)
+ # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
+ ABINUM=$(echo $kversion | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')
+ echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> ${outdir}/include/generated/utsrelease.h
+ ;;
+ esac
+
+ # On powerpc this object is required to link modules
+ if [ "${karch}" = "powerpc" ]; then
+ make ${koutput} arch/powerpc/lib/crtsavres.o
+ fi
+}
+
+
+