build 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # generic build script, for building libreboot (all of it)
  3. #
  4. # Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
  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 release archives\n"
  36. printf "Example: ./build clean all\n"
  37. printf "Example (extra option) ./build module bucts static\n"
  38. printf "Refer to the libreboot documentation for more info\n\n"
  39. exit 1
  40. fi
  41. mode="${1}"
  42. option="${2}"
  43. shift 2
  44. if [ -d "${build}/${mode}" ]; then
  45. availableoptions="$(for buildoption in ${build}/${mode}/*; do printf "%s\n" "${buildoption##*/}"; done)"
  46. if [ "${option}" = "list" ]; then
  47. printf "Available options for '%s' are:\nall\n%s\n\n" "${mode}" "${availableoptions}"
  48. elif [ -f "${build}/${mode}/${option}" ]; then
  49. "${build}/${mode}/${option}" "$@"
  50. elif [ "${option}" = "all" ]; then
  51. for option in ${availableoptions}; do
  52. "${build}/${mode}/${option}" "$@"
  53. done
  54. else
  55. printf "Invalid option for '%s'. Available options are:\nall\n%s\n\n" "${mode}" "${availableoptions}"
  56. exit 1
  57. fi
  58. else
  59. printf "Invalid mode. Available modes are:\n%s\n\n" "${availablemodes}"
  60. exit 1
  61. fi
  62. # ------------------- DONE ----------------------