summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-02-18 20:39:38 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-02-18 20:39:38 +0200
commit81f0ea009377983a845c1903352786a69c9945fe (patch)
treeff5d39d87500e5aee4ece7fcce1231f0e9f45a23
parentaa2b2ff0670c28ad999774b4ea5fb510da14a9c2 (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-xkbuild.sh14
1 files changed, 14 insertions, 0 deletions
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
#