DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferdinand Thiessen <rpm@fthiessen.de>
To: bruce.richardson@intel.com
Cc: dev@dpdk.org, Ferdinand Thiessen <rpm@fthiessen.de>
Subject: [PATCH v2] build: try to get kernel version from kernel source
Date: Thu,  3 Mar 2022 14:12:30 +0100	[thread overview]
Message-ID: <20220303131230.31022-1-rpm@fthiessen.de> (raw)

When building the kernel modules, try to get the kernel
version from the kernel sources first. This fixes the
kernel modules installation directory if the target kernel
version differs from the host kernel version, like for
CI build or when packaging for linux distributions.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
---
 kernel/linux/meson.build | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index d8fb20c1c3..16a0948994 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -12,15 +12,21 @@ cross_args = []
 if not meson.is_cross_build()
     # native build
     kernel_version = run_command('uname', '-r', check: true).stdout().strip()
+    if kernel_source_dir != ''
+        # Try kernel release from sources first
+        r = run_command('make', '-s', '-C', kernel_source_dir, 'kernelrelease', check: false)
+        if r.returncode() == 0
+            kernel_version = r.stdout().strip()
+        endif
+    else
+        # use default path for native builds
+        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
+    endif
     kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
     if kernel_build_dir == ''
         # use default path for native builds
         kernel_build_dir = '/lib/modules/' + kernel_version + '/build'
     endif
-    if kernel_source_dir == ''
-        # use default path for native builds
-        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
-    endif
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-- 
2.35.1


             reply	other threads:[~2022-03-03 13:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 13:12 Ferdinand Thiessen [this message]
2022-03-03 13:37 ` Bruce Richardson
  -- strict thread matches above, loose matches on Subject: below --
2022-02-26 21:40 [PATCH] " Ferdinand Thiessen
2022-03-03 13:15 ` [PATCH v2] " Ferdinand Thiessen
2022-03-08 15:54   ` Ferruh Yigit
2022-06-08 15:39     ` David Marchand

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=20220303131230.31022-1-rpm@fthiessen.de \
    --to=rpm@fthiessen.de \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /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).