From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40E23A0352; Sat, 26 Feb 2022 22:41:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C755C4068F; Sat, 26 Feb 2022 22:41:52 +0100 (CET) Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [46.38.247.118]) by mails.dpdk.org (Postfix) with ESMTP id 1FFBD4013F for ; Sat, 26 Feb 2022 22:41:51 +0100 (CET) Received: from mors-relay-8404.netcup.net (localhost [127.0.0.1]) by mors-relay-8404.netcup.net (Postfix) with ESMTPS id 4K5g8G5nvyz80XC; Sat, 26 Feb 2022 22:41:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fthiessen.de; s=key2; t=1645911710; bh=Wi067m23XttlbClHF4Ro/zX/kD//+jb7dQ+4hqgqpFs=; h=From:To:Cc:Subject:Date:From; b=jIu6IbLBTI9zOmPwDRnfI78A9goOL/4MNZI8YolQF1wE9vPrplC4fxkydGzQOw0WZ YlrVxecdn//y+wQw7uDR9JwZD6YFCcJUEybqMwm30BacBEE79eCZvZWT+NIaboBtM9 +zTmu3EW7bAeBy7SnxLikZ95mBpSen1mKe1VbinxnB2xddCrRfZVNg8p+2HuNI/0iL NQLUbv11UaSEmkzEifbmTEHTXgTzbUldy7pa2cadkvtQXGPS478DZcGqzoeC5QC93N gbG19O6RasltHkPBo/qs1fA4u14OK890CngZ6hT7l3Kunej8Bf1ZYgSo7EDCDSxdRe bV03Dw5qKeMhg== Received: from policy02-mors.netcup.net (unknown [46.38.225.53]) by mors-relay-8404.netcup.net (Postfix) with ESMTPS id 4K5g8G5J0tz4xb3; Sat, 26 Feb 2022 22:41:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at policy02-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from mx2ec0.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy02-mors.netcup.net (Postfix) with ESMTPS id 4K5g8F67V2z8sgM; Sat, 26 Feb 2022 22:41:49 +0100 (CET) Received: from localhost.localdomain (ip5f5a9c28.dynamic.kabel-deutschland.de [95.90.156.40]) by mx2ec0.netcup.net (Postfix) with ESMTPSA id 1ECDD1A0039; Sat, 26 Feb 2022 22:41:49 +0100 (CET) Authentication-Results: mx2ec0; spf=pass (sender IP is 95.90.156.40) smtp.mailfrom=rpm@fthiessen.de smtp.helo=localhost.localdomain Received-SPF: pass (mx2ec0: connection is authenticated) From: Ferdinand Thiessen To: bruce.richardson@intel.com Cc: dev@dpdk.org, Ferdinand Thiessen Subject: [PATCH] build: try to get kernel version from kernel source Date: Sat, 26 Feb 2022 22:40:45 +0100 Message-Id: <20220226214045.19902-1-rpm@fthiessen.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-PPP-Message-ID: <164591170938.26763.3481498977230188658@mx2ec0.netcup.net> X-PPP-Vhost: familiethiessen.de X-NC-CID: KdOKo2WFRBOY2PUBgzeE1A10PxkvdI/nkxKIHmb/k3+fH22BS5JZLwIhng0= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- kernel/linux/meson.build | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build index d8fb20c1c3..78f28ffb0c 100644 --- a/kernel/linux/meson.build +++ b/kernel/linux/meson.build @@ -10,17 +10,23 @@ install = not meson.is_cross_build() cross_args = [] if not meson.is_cross_build() - # native build - kernel_version = run_command('uname', '-r', check: true).stdout().strip() + # native target build + kernel_version = run_command('uname', '-r').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