crossgcc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #!/usr/bin/env bash
  2. # Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. arguments() {
  17. project_arguments_targets "$project" "$@"
  18. }
  19. usage() {
  20. project_usage_actions "$project" "prefix"
  21. project_usage_arguments "$project" "$@"
  22. }
  23. download() {
  24. local repository="coreboot"
  25. git_project_prepare "$project" "$repository" "$@"
  26. }
  27. download_check() {
  28. local repository="coreboot"
  29. git_project_prepare_check "$project" "$repository" "$@"
  30. }
  31. extract() {
  32. local arguments=$@
  33. local repository="coreboot"
  34. local tarball
  35. project_extract "$project" "$@"
  36. crossgcc_tarballs "$@" | while read tarball
  37. do
  38. local tarball_sources_path=$(crossgcc_tarball_sources_path "$tarball")
  39. local tarball_install_path=$(crossgcc_tarball_install_path "$tarball" "$@")
  40. local tarball_install_directory_path=$(dirname "$tarball_install_path")
  41. if [[ -f "$tarball_sources_path" ]] && ! [[ -f "$tarball_install_path" ]]
  42. then
  43. printf '%s\n' "Copying source archive $tarball for $project (with ${arguments:-no argument})"
  44. mkdir -p "$tarball_install_directory_path"
  45. file_verification_check "$tarball_sources_path"
  46. cp "$tarball_sources_path" "$tarball_install_path"
  47. fi
  48. done
  49. }
  50. extract_check() {
  51. local repository="coreboot"
  52. local tarball
  53. project_extract_check "$project" "$@"
  54. crossgcc_tarballs "$@" | while read tarball
  55. do
  56. local tarball_install_path=$(crossgcc_tarball_install_path "$tarball" "$@")
  57. test ! -f "$tarball_install_path"
  58. done
  59. }
  60. update() {
  61. local arguments=$@
  62. local repository="coreboot"
  63. local tarball
  64. project_update_git $project $repository $arguments
  65. crossgcc_tarballs "$@" | while read tarball
  66. do
  67. local tarball_sources_path=$(crossgcc_tarball_sources_path "$tarball")
  68. local tarball_install_path=$(crossgcc_tarball_install_path "$tarball" "$@")
  69. local tarball_install_directory_path=$(dirname "$tarball_install_path")
  70. if [[ -f $tarball_sources_path ]]
  71. then
  72. printf '%s\n' "Copying source archive $tarball for $project (with ${arguments:-no argument})"
  73. mkdir -p "$tarball_install_directory_path"
  74. file_verification_check "$tarball_sources_path"
  75. cp "$tarball_sources_path" "$tarball_install_path"
  76. fi
  77. done
  78. }
  79. update_check() {
  80. local repository="coreboot"
  81. local tarball
  82. project_update_check_git "$project" "$repository" "$@"
  83. crossgcc_tarballs "$@" | while read tarball
  84. do
  85. local tarball_sources_path=$(crossgcc_tarball_sources_path "$tarball" "$@")
  86. test ! -f "$tarball_sources_path"
  87. done
  88. }
  89. prefix() {
  90. local arch=$1
  91. local build_path=$(project_build_path "$project" "$@")
  92. case $arch in
  93. "arm")
  94. printf '\n%s\n' "$build_path/bin/arm-eabi-"
  95. ;;
  96. "i386")
  97. printf '\n%s\n' "$build_path/bin/i386-elf-"
  98. ;;
  99. esac
  100. }
  101. build() {
  102. local arch=$1
  103. local repository="coreboot"
  104. project_sources_directory_missing_empty_error "$project" "$repository" "$@"
  105. local sources_path=$(project_sources_path "$project" "$repository" "$@")
  106. local build_path=$(project_build_path "$project" "$@")
  107. if git_project_check "$repository"
  108. then
  109. git_project_checkout "$project" "$repository" "$@"
  110. fi
  111. mkdir -p "$build_path"
  112. local bootstrap_flag
  113. if ! crossgcc_same_major_version_test; then
  114. printf '\n%s' 'GCC major versions differ. Bootstrapping' 1>&2
  115. printf '%s\n\n' ' to avoid potential build failure' 1>&2
  116. bootstrap_flag='-b'
  117. fi
  118. make -C "$sources_path" "$bootstrap_flag" CPUS="$TASKS" DEST="$build_path" "crossgcc-$arch"
  119. }
  120. build_check() {
  121. project_build_check "$project" "$@"
  122. }
  123. install() {
  124. project_install "$project" "$@"
  125. }
  126. install_check() {
  127. project_install_check "$project" "$@"
  128. }
  129. release() {
  130. local arguments=$@
  131. local repository="coreboot"
  132. local tarball
  133. project_release_install_archive "$project" "$TOOLS" "$@"
  134. project_release_sources_git "$project" "$repository" "$@"
  135. crossgcc_tarballs "$@" | while read tarball
  136. do
  137. local tarball_install_path=$(crossgcc_tarball_install_path "$tarball" "$@")
  138. local tarball_release_path=$(crossgcc_tarball_release_path "$tarball" "$@")
  139. local release_path=$(project_release_path "$project" "$SOURCES" "$@")
  140. mkdir -p "$release_path"
  141. if [[ -f "$tarball_install_path" ]] && ! [[ -f "$tarball_release_path" ]]
  142. then
  143. printf '%s\n' "Releasing source archive $tarball for $project (with ${arguments:-no argument})"
  144. cp "$tarball_install_path" "$tarball_release_path"
  145. file_verification_create "$tarball_release_path"
  146. fi
  147. done
  148. }
  149. release_check() {
  150. local repository="coreboot"
  151. local tarball
  152. project_release_install_archive_check "$project" "$TOOLS" "$@"
  153. project_release_check_sources_git "$project" "$repository" "$@"
  154. crossgcc_tarballs "$@" | while read tarball
  155. do
  156. local tarball_release_path=$(crossgcc_tarball_release_path "$tarball" "$@")
  157. test -f "$tarball_release_path"
  158. done
  159. }
  160. clean() {
  161. project_clean "$project" "$@"
  162. }