From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: hemant.agrawal@nxp.com, bluca@debian.org,
Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH v2 1/3] build: fix kernel compile on cross-build
Date: Fri, 27 Apr 2018 14:49:26 +0100 [thread overview]
Message-ID: <20180427134928.4716-2-bruce.richardson@intel.com> (raw)
In-Reply-To: <20180427134928.4716-1-bruce.richardson@intel.com>
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>
---
kernel/linux/igb_uio/meson.build | 6 ------
kernel/linux/meson.build | 40 +++++++++++++++++++++++++++++++++++++---
meson.build | 6 +++++-
3 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/kernel/linux/igb_uio/meson.build b/kernel/linux/igb_uio/meson.build
index 356f4ab32..71ed2e7a8 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 a5b88f0c6..a924c7b6f 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
diff --git a/meson.build b/meson.build
index cc16595cb..52a8746c5 100644
--- a/meson.build
+++ b/meson.build
@@ -26,7 +26,6 @@ subdir('config')
# build libs and drivers
subdir('lib')
-subdir('kernel')
subdir('buildtools')
subdir('drivers')
@@ -40,6 +39,11 @@ if get_option('examples') != ''
subdir('examples')
endif
+# build kernel modules if enabled
+if get_option('enable_kmods')
+ subdir('kernel')
+endif
+
# write the build config
build_cfg = 'rte_build_config.h'
configure_file(output: build_cfg,
--
2.14.3
next prev parent reply other threads:[~2018-04-27 13:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 21:05 [dpdk-dev] [PATCH 0/2] small fixes for meson build Bruce Richardson
2018-04-18 21:05 ` [dpdk-dev] [PATCH 1/2] build: fix kernel compile on cross-build Bruce Richardson
2018-04-19 15:46 ` Hemant Agrawal
2018-04-19 16:12 ` Bruce Richardson
2018-04-19 17:06 ` Hemant Agrawal
2018-04-18 21:05 ` [dpdk-dev] [PATCH 2/2] build: fix check for libbsd in meson Bruce Richardson
2018-04-27 13:49 ` [dpdk-dev] [PATCH v2 0/3] small improvements to meson build Bruce Richardson
2018-04-27 13:49 ` Bruce Richardson [this message]
2018-04-27 13:49 ` [dpdk-dev] [PATCH v2 2/3] build: fix check for libbsd in meson Bruce Richardson
2018-04-27 13:51 ` Bruce Richardson
2018-04-27 17:51 ` Vladimir Medvedkin
2018-04-27 13:49 ` [dpdk-dev] [PATCH v2 3/3] build: ensure compatibility with future meson versions Bruce Richardson
2018-04-27 14:37 ` [dpdk-dev] [PATCH v2 0/3] small improvements to meson build Luca Boccassi
2018-05-08 20:22 ` Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180427134928.4716-2-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=bluca@debian.org \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).