From 81f0ea009377983a845c1903352786a69c9945fe Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 18 Feb 2020 20:39:38 +0200 Subject: Add simple mechanism to specify version-based extra CFLAGS Platform files can specify extra CFLAGS by extending the kcflags environment variable. When a kernel tree for a platform contains both BSP and mainline branches, different CFLAGS may be needed, as BSPs are usually littered with warnings. Make it possible to specify extra CFLAGS per kernel version through a new extra_kcflags array. This mechanism can be extended later if needed by storing version comparison strings as array keys (e.g. "<=4.19"). Signed-off-by: Laurent Pinchart --- kbuild.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kbuild.sh b/kbuild.sh index a0086a8..7980463 100755 --- a/kbuild.sh +++ b/kbuild.sh @@ -6,6 +6,7 @@ set -e kbuild_root=$(dirname $(readlink -f "$0")) declare -A cross_compile +declare -A extra_kcflags declare -A target_root if [[ -r $kbuild_root/config.sh ]] ; then @@ -16,6 +17,15 @@ fi #kbuild_options='C=1' kbuild_options="KALLSYMS_EXTRA_PASS=0" +get_kernel_version() { + local version=$(cat Makefile | grep '^VERSION = ' | sed 's/.* = //') + local patchlevel=$(cat Makefile | grep '^PATCHLEVEL = ' | sed 's/.* = //') + local sublevel=$(cat Makefile | grep '^SUBLEVEL = ' | sed 's/.* = //') + echo "$version.$patchlevel.$sublevel" +} + +version=$(get_kernel_version) + # # Options parsing # @@ -103,6 +113,10 @@ fi source "${kbuild_root}/platforms/$platform.sh" || exit 1 +# Apply version-specific kcflags, useful to suppress warnings based on the +# kernel version. +[[ -z "${extra_kcflags[$version]+_}" ]] || kcflags="$kcflags ${extra_kcflags[$version]}" + # # Architecture # -- cgit v1.2.3