makefile-getvar 462 B

123456789101112131415161718192021222324
  1. #! /bin/sh
  2. # Get a variable's value from a makefile:
  3. #
  4. # $ makefile-getvar Makefile VARIABLE VARIABLE ...
  5. #
  6. # If multiple variables are specified, they will be printed one per line.
  7. #
  8. # SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
  9. # SPDX-License-Identifier: GPL-2.0-only
  10. set -eu
  11. MAKEFILE=$1
  12. shift
  13. for VARIABLE in $*; do
  14. make -f - $VARIABLE.var <<EOF
  15. include $MAKEFILE
  16. %.var:
  17. @echo \$(\$*)
  18. EOF
  19. done