roms 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/env bash
  2. #
  3. # helper script: build coreboot images with various payloads
  4. #
  5. # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org>
  6. # Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. # This script assumes that the working directory is the root
  22. # of git or release archive
  23. [ "x${DEBUG+set}" = 'xset' ] && set -v
  24. set -u -e
  25. projectname="$(cat projectname)"
  26. listboards() {
  27. for boarddir in resources/coreboot/*; do
  28. if [ ! -d "${boarddir}" ]; then continue; fi
  29. board="${boarddir##resources/coreboot/}"
  30. board="${board%/}"
  31. printf '%s\n' "${board##*/}"
  32. done
  33. }
  34. help() {
  35. cat <<- EOF
  36. USAGE: ./build boot roms boardname
  37. To build *all* boards, do this: ./build boot roms all
  38. To list *all* boards, do this: ./build boot roms list
  39. possible values for 'options':
  40. $(listboards)
  41. Example: ./build boot roms x60
  42. Example: ./build boot roms x200_8mb x60
  43. Refer to the ${projectname} documentation for more information.
  44. EOF
  45. }
  46. die() {
  47. printf 'Error: %s\n' "${@}" 1>&2
  48. exit 1
  49. }
  50. # Build ROM images for supported boards
  51. buildrom() {
  52. board="$1"
  53. if [ -d "resources/coreboot/${board}/" ]; then
  54. ./build boot roms_helper "${board}"
  55. else
  56. die "\nbuild/roms: target not defined in the build system: %s\n" "${board}"
  57. fi
  58. }
  59. if [ $# -gt 0 ]; then
  60. firstoption="${1}"
  61. if [ "${firstoption}" = "help" ]; then
  62. help
  63. exit 0
  64. fi
  65. if [ "${firstoption}" = "list" ]; then
  66. listboards
  67. exit 0
  68. fi
  69. printf "Building %s ROM images\n" "${projectname}"
  70. if [ "${firstoption}" = "all" ]; then
  71. for boardname in $(listboards); do
  72. buildrom "${boardname}" || die "build/roms: something went wrong"
  73. done
  74. else
  75. for board in ${@}; do
  76. buildrom "${board}" || die "build/roms: something went wrong"
  77. done
  78. fi
  79. else
  80. help
  81. exit 1
  82. fi
  83. printf "\n\nDone! Your ROMs are in bin/\n\n"