# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Parameters
+arch=${arch:-}
+cross_arch=${cross_arch:-}
+ktag=${ktag:-}
+
+
## FUNCTIONS ##
# Kernel version compare functions
verlte() {
- [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
+ [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" ]
}
verlt() {
- [ "$1" = "$2" ] && return 1 || verlte $1 $2
+ [ "$1" = "$2" ] && return 1 || verlte "$1" "$2"
}
vergte() {
- [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
+ [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -n1)" ]
}
vergt() {
- [ "$1" = "$2" ] && return 1 || vergte $1 $2
+ [ "$1" = "$2" ] && return 1 || vergte "$1" "$2"
}
if [ "$outdir" = "." ]; then
koutput=""
else
- koutput="O=\"${outdir}\""
+ koutput="O=${outdir}"
fi
# Generate kernel configuration
- case "$kversion" in
+ case "$ktag" in
Ubuntu*)
+ if [ "${cross_arch}" = "powerpc" ]; then
+ if vergte "$KVERSION" "4.10"; then
+ echo "Ubuntu removed big endian powerpc configuration from kernel >= 4.10. Don't try to build it."
+ exit 0
+ fi
+ fi
fakeroot debian/rules clean
fakeroot debian/rules genconfigs
- cp CONFIGS/${ubuntu_config} "${outdir}"/.config
+ cp CONFIGS/"${ubuntu_config}" "${outdir}"/.config
;;
*)
# Que sera sera
- make ${koutput} ${vanilla_config} CC=$CC
+ make "${vanilla_config}" CC="$CC" ${koutput}
;;
esac
# 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
+ # Set required options
+ {
+ echo "CONFIG_KPROBES=y";
+ echo "CONFIG_FTRACE=y";
+ echo "CONFIG_BLK_DEV_IO_TRACE=y";
+ echo "CONFIG_TRACEPOINTS=y";
+ echo "CONFIG_KALLSYMS_ALL=y";
+ } >> "${outdir}"/.config
+
+
+ make "$oldconf_target" CC="$CC" ${koutput}
+ make modules_prepare CC="$CC" ${koutput}
+
+ # Debug
+ #cat "${outdir}"/.config
+ # On powerpc this object is required to link modules
+ if [ "${karch}" = "powerpc" ]; then
+ make arch/powerpc/lib/crtsavres.o CC="$CC" ${koutput}
+ fi
- make ${koutput} olddefconfig CC=$CC
- make ${koutput} modules_prepare CC=$CC
+ # On arm64 this object is required to build with ftrace support
+ if [ "${karch}" = "arm64" ]; then
+ if vergte "$KVERSION" "4.13-rc1"; then
+ make arch/arm64/kernel/ftrace-mod.o CC="$CC" ${koutput}
+ fi
+ fi
# Version specific tasks
- case "$kversion" in
+ case "$ktag" 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
+ ABINUM="$(echo "$ktag" | 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 CC=$CC
- fi
}
kdir="$1"
bdir="$2"
- # Get kernel version from source tree
- cd "${kdir}"
- kversion=$(make kernelversion)
-
# Enter lttng-modules source dir
cd "${LTTSRCDIR}"
# kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
# timekeeping subsystem. We want those build to fail.
- if { vergte "$kversion" "3.10" && verlte "$kversion" "3.10.13"; } || \
- { vergte "$kversion" "3.11" && verlte "$kversion" "3.11.2"; }; then
+ if { vergte "$KVERSION" "3.10" && verlte "$KVERSION" "3.10.13"; } || \
+ { vergte "$KVERSION" "3.11" && verlte "$KVERSION" "3.11.2"; }; then
set +e
# Build modules
- KERNELDIR="${kdir}" make -j${NPROC} V=1 CC=$CC
+ KERNELDIR="${kdir}" make -j"${NPROC}" V=1 CC="$CC"
# We expect this build to fail, if it doesn't, fail the job.
if [ "$?" -eq 0 ]; then
set -e
- KERNELDIR="${kdir}" make clean CC=$CC
+ KERNELDIR="${kdir}" make clean CC="$CC"
else # Regular build
# Build modules against full kernel sources
- KERNELDIR="${kdir}" make -j${NPROC} V=1 CC=$CC
+ KERNELDIR="${kdir}" make -j"${NPROC}" V=1 CC="$CC"
# Install modules to build dir
- KERNELDIR="${kdir}" make INSTALL_MOD_PATH="${bdir}" modules_install CC=$CC
+ KERNELDIR="${kdir}" make INSTALL_MOD_PATH="${bdir}" modules_install CC="$CC"
# Clean build dir
- KERNELDIR="${kdir}" make clean CC=$CC
+ KERNELDIR="${kdir}" make clean CC="$CC"
fi
}
# Setup cross compile env if available
-if [ "x${cross_arch:-}" != "x" ]; then
+if [ "x${cross_arch}" != "x" ]; then
case "$cross_arch" in
"armhf")
;;
*)
- echo "Unsupported cross arch $arch"
+ echo "Unsupported cross arch $cross_arch"
exit 1
;;
esac
- # Use default gcc when cross-compiling
- CC="${cross_compile}gcc"
+ # Use gcc 4.9, older kernel don't build with gcc 5
+ CC="${cross_compile}gcc-4.9"
# Export variables used by Kbuild for cross compilation
export ARCH="${karch}"
export CROSS_COMPILE="${cross_compile}"
+ oldconf_target="olddefconfig"
+
# Set arch specific values if we are not cross compiling
-elif [ "x${arch:-}" != "x" ]; then
+elif [ "x${arch}" != "x" ]; then
case "$arch" in
"x86-32")
# Use gcc 4.9, older kernel don't build with gcc 5
CC=gcc-4.9
+ oldconf_target="silentoldconfig"
+
else
echo "Not arch or cross_arch specified"
exit 1
# Enter linux source dir
cd "${LNXSRCDIR}"
+# Get kernel version from source tree
+KVERSION=$(make kernelversion)
+
prepare_lnx_sources "."
# For RT kernels, copy version file
cp -a scripts include "${LNXHDRDIR}"
# Copy arch includes
-(find arch -name include -type d -print | \
- xargs -n1 -i: find : -type f) | \
+(find arch -name include -type d -print0 | \
+ xargs -0 -n1 -i: find : -type f) | \
cpio -pd --preserve-modification-time "${LNXHDRDIR}"
# Copy arch scripts
-(find arch -name scripts -type d -print | \
- xargs -n1 -i: find : -type f) | \
+(find arch -name scripts -type d -print0 | \
+ xargs -0 -n1 -i: find : -type f) | \
cpio -pd --preserve-modification-time "${LNXHDRDIR}"
# Cleanup scripts
cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LNXHDRDIR}/"
fi
+# On arm64 this object is required to build with ftrace support
+if [ "${karch}" = "arm64" ]; then
+ if vergte "$KVERSION" "4.13-rc1"; then
+ cp -a --parents arch/arm64/kernel/ftrace-mod.[So] "${LNXHDRDIR}/"
+ fi
+fi
+
# Copy modules related stuff, if available
if [ -s Module.symvers ]; then
cp Module.symvers "${LNXHDRDIR}"