diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-02-18 20:39:38 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-02-18 20:39:38 +0200 |
commit | 81f0ea009377983a845c1903352786a69c9945fe (patch) | |
tree | ff5d39d87500e5aee4ece7fcce1231f0e9f45a23 | |
parent | aa2b2ff0670c28ad999774b4ea5fb510da14a9c2 (diff) |
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 <laurent.pinchart@ideasonboard.com>
-rwxr-xr-x | kbuild.sh | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 # |