build 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # generic build script, for building libreboot (all of it)
  3. #
  4. # Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
  5. # 2015 Patrick "P. J." McDermott <pj@pehjota.net>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. [ "x${DEBUG+set}" = 'xset' ] && set -v
  21. set -u -e
  22. build="./resources/scripts/helpers/build"
  23. mode="unknown"
  24. option="unknown"
  25. usage="./build mode option"
  26. availablemodes="$(for mode in ${build}/*; do printf "%s\n" "${mode##*/}"; done)"
  27. availableoptions="unknown" # unknown until the mode is determined
  28. # User specified no or too few/many parameters
  29. if [ $# -lt 2 ]; then
  30. printf "%s\n\n" "${usage}"
  31. printf "possible values for 'mode':\n%s\n\n" "${availablemodes}"
  32. printf "Example: ./build module all\n"
  33. printf "Example: ./build module flashrom\n"
  34. printf "Example: ./build roms withgrub\n"
  35. printf "Example: ./build clean all\n"
  36. printf "Example (extra option) ./build module bucts static\n"
  37. printf "Refer to the libreboot documentation for more info\n\n"
  38. exit 1
  39. fi
  40. mode="${1}"
  41. option="${2}"
  42. shift 2
  43. if [ -d "${build}/${mode}" ]; then
  44. availableoptions="$(for buildoption in ${build}/${mode}/*; do printf "%s\n" "${buildoption##*/}"; done)"
  45. if [ "${option}" = "list" ]; then
  46. printf "Available options for '%s' are:\nall\n%s\n\n" "${mode}" "${availableoptions}"
  47. elif [ -f "${build}/${mode}/${option}" ]; then
  48. "${build}/${mode}/${option}" "$@"
  49. elif [ "${option}" = "all" ]; then
  50. for option in ${availableoptions}; do
  51. "${build}/${mode}/${option}" "$@"
  52. done
  53. else
  54. printf "Invalid option for '%s'. Available options are:\nall\n%s\n\n" "${mode}" "${availableoptions}"
  55. exit 1
  56. fi
  57. else
  58. printf "Invalid mode. Available modes are:\n%s\n\n" "${availablemodes}"
  59. exit 1
  60. fi
  61. # ------------------- DONE ----------------------