cbutils 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bash
  2. # helper script: build various coreboot utilities
  3. #
  4. # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # This script assumes that the current working directory is the root
  20. [ "x${DEBUG+set}" = 'xset' ] && set -v
  21. set -u -e
  22. printf "Building coreboot utils\n"
  23. buildutils() {
  24. cbtree="${1}"
  25. if [ ! -d "coreboot/${cbtree}/" ]; then
  26. ./download coreboot $cbtree || return 1
  27. fi
  28. if [ ! -d "coreboot/${cbtree}/" ]; then
  29. printf "build/cbutils: coreboot/%s not found. Exiting\n" "${cbtree}"
  30. return 1
  31. fi
  32. for util in {cbfs,ifd}tool; do
  33. (
  34. cd "coreboot/${cbtree}/util/${util}/"
  35. make -j$(nproc) || return 1
  36. )
  37. done
  38. return 0
  39. }
  40. buildfromboardconfig() {
  41. board="${1}"
  42. if [ ! -d "resources/coreboot/${board}" ]; then
  43. continue
  44. fi
  45. if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
  46. continue
  47. fi
  48. cbtree="undefined"
  49. source "resources/coreboot/${board}/board.cfg"
  50. if [ "${cbtree}" = "undefined" ]; then
  51. printf "build/cbutils: improper cbtree definition for '%s'" "${board}"
  52. return 1
  53. fi
  54. buildutils "${cbtree}" || return 1
  55. return 0
  56. }
  57. if [ $# -gt 0 ]; then
  58. for board in "${@}"; do
  59. buildfromboardconfig ${board} || exit 1
  60. done
  61. else
  62. for boarddir in resources/coreboot/*; do
  63. if [ ! -d "${boarddir}" ]; then
  64. continue
  65. fi
  66. buildfromboardconfig ${boarddir##*/} || exit 1
  67. done
  68. fi
  69. printf "\n\n"
  70. exit 0