summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2018-04-27 14:49:26 +0100
committerBruce Richardson <bruce.richardson@intel.com>2018-05-08 22:21:38 +0200
commit89200580ef0f89ef247ca32e9299c670beb95cc0 (patch)
treeeae0aa6e06c2020efaf5f46f5d774579dc92134a /kernel
parent776d64ffb7cff60a5500c8f33704787d0bae428a (diff)
downloaddpdk-89200580ef0f89ef247ca32e9299c670beb95cc0.zip
dpdk-89200580ef0f89ef247ca32e9299c670beb95cc0.tar.gz
dpdk-89200580ef0f89ef247ca32e9299c670beb95cc0.tar.xz
kernel: fix cross-build of Linux modules with meson
When cross-compiling, if no kernel_dir was specified, then the kernel modules were still being compiled for the build machine. Fix this by only building modules on cross-compile when we have a kernel_dir value set. Print out a message indicating why we are skipping kernel compilation, and in case that the headers for kernel compile are not found, print a warning instead of erroring out. Fixes: a52f4574f798 ("igb_uio: build with meson") Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Luca Boccassi <bluca@debian.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/linux/igb_uio/meson.build6
-rw-r--r--kernel/linux/meson.build40
2 files changed, 37 insertions, 9 deletions
diff --git a/kernel/linux/igb_uio/meson.build b/kernel/linux/igb_uio/meson.build
index 356f4ab..71ed2e7 100644
--- a/kernel/linux/igb_uio/meson.build
+++ b/kernel/linux/igb_uio/meson.build
@@ -1,12 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
-kernel_dir = get_option('kernel_dir')
-if kernel_dir == ''
- kernel_version = run_command('uname', '-r').stdout().strip()
- kernel_dir = '/lib/modules/' + kernel_version + '/build'
-endif
-
mkfile = custom_target('igb_uio_makefile',
output: 'Makefile',
command: ['touch', '@OUTPUT@'])
diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index a5b88f0..a924c7b 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -3,6 +3,40 @@
subdirs = ['igb_uio']
-foreach d:subdirs
- subdir(d)
-endforeach
+WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-compiling'
+WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
+
+# if we are cross-compiling we need kernel_dir specified
+# NOTE: warning() function only available from version 0.44 onwards
+if get_option('kernel_dir') == '' and meson.is_cross_build()
+ if meson.version().version_compare('>=0.44')
+ warning(WARN_CROSS_COMPILE)
+ else
+ message('WARNING: ' + WARN_CROSS_COMPILE)
+ endif
+else
+
+ kernel_dir = get_option('kernel_dir')
+ if kernel_dir == ''
+ # use default path for native builds
+ kernel_version = run_command('uname', '-r').stdout().strip()
+ kernel_dir = '/lib/modules/' + kernel_version + '/build'
+ endif
+
+ # test running make in kernel directory, using "make kernelversion"
+ make_returncode = run_command('make', '-sC', kernel_dir,
+ 'kernelversion').returncode()
+ if make_returncode != 0
+ if meson.version().version_compare('>=0.44')
+ warning(WARN_NO_HEADERS)
+ else
+ message('WARNING: ' + WARN_NO_HEADERS)
+ endif
+ else # returncode == 0
+
+# DO ACTUAL MODULE BUILDING
+ foreach d:subdirs
+ subdir(d)
+ endforeach
+ endif
+endif