summaryrefslogtreecommitdiffstats
path: root/scripts/pahole-version.sh
diff options
context:
space:
mode:
authorNathan Chancellor <nathan@kernel.org>2022-02-01 21:56:21 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2022-02-02 11:19:33 +0100
commit613fe169237785a4bb1d06397b52606b2967da53 (patch)
treebd040d3f8b8891c73747c1cbe11f0220f7898856 /scripts/pahole-version.sh
parentMAINTAINERS: Add scripts/pahole-flags.sh to BPF section (diff)
downloadlinux-613fe169237785a4bb1d06397b52606b2967da53.tar.xz
linux-613fe169237785a4bb1d06397b52606b2967da53.zip
kbuild: Add CONFIG_PAHOLE_VERSION
There are a few different places where pahole's version is turned into a three digit form with the exact same command. Move this command into scripts/pahole-version.sh to reduce the amount of duplication across the tree. Create CONFIG_PAHOLE_VERSION so the version code can be used in Kconfig to enable and disable configuration options based on the pahole version, which is already done in a couple of places. Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220201205624.652313-3-nathan@kernel.org
Diffstat (limited to 'scripts/pahole-version.sh')
-rwxr-xr-xscripts/pahole-version.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/pahole-version.sh b/scripts/pahole-version.sh
new file mode 100755
index 000000000000..f8a32ab93ad1
--- /dev/null
+++ b/scripts/pahole-version.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Usage: $ ./pahole-version.sh pahole
+#
+# Prints pahole's version in a 3-digit form, such as 119 for v1.19.
+
+if [ ! -x "$(command -v "$@")" ]; then
+ echo 0
+ exit 1
+fi
+
+"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'