diff options
author | Ross Burton <ross.burton@arm.com> | 2024-06-12 11:06:58 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-06-13 09:11:17 +0100 |
commit | 4574919d30f66fa0b13eb0b25dd32650c23b8f1c (patch) | |
tree | 21c93d1e41caf7b0077b85a9e9504287a6ca15d4 /scripts | |
parent | b82d066887d154c2f70d5f284cbb3ec7ec832daf (diff) | |
download | poky-4574919d30f66fa0b13eb0b25dd32650c23b8f1c.tar.gz |
scripts/makefile-getvar: add script to get values from Makefiles
There is often a need to extract a value from a Makefile, and standard
GNU Make doesn't provide a way to do this. This script lets you access
values from Makefiles directly:
$ makefile-getvar curl/tests/server/Makefile noinst_PROGRAMS
getpart resolve rtspd sockfilt sws tftpd fake_ntlm socksd disabled mqttd
(From OE-Core rev: 881aa40d12d9dde73a932277093e5ceca8eb5c68)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/makefile-getvar | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/makefile-getvar b/scripts/makefile-getvar new file mode 100755 index 0000000000..4a07055e68 --- /dev/null +++ b/scripts/makefile-getvar | |||
@@ -0,0 +1,24 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | # Get a variable's value from a makefile: | ||
4 | # | ||
5 | # $ makefile-getvar Makefile VARIABLE VARIABLE ... | ||
6 | # | ||
7 | # If multiple variables are specified, they will be printed one per line. | ||
8 | # | ||
9 | # SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com> | ||
10 | # SPDX-License-Identifier: GPL-2.0-only | ||
11 | |||
12 | set -eu | ||
13 | |||
14 | MAKEFILE=$1 | ||
15 | shift | ||
16 | |||
17 | for VARIABLE in $*; do | ||
18 | make -f - $VARIABLE.var <<EOF | ||
19 | include $MAKEFILE | ||
20 | |||
21 | %.var: | ||
22 | @echo \$(\$*) | ||
23 | EOF | ||
24 | done | ||