flashrom 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # helper script: builds flashrom source code
  3. #
  4. # Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
  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 working directory is the root
  20. # of libreboot_src or git
  21. [ "x${DEBUG+set}" = 'xset' ] && set -v
  22. set -u -e
  23. # Build "flashrom" (utility for flashing/dumping ROM's)
  24. # --------------------------------------------------------------------
  25. printf "Building flashrom\n"
  26. cd "flashrom/"
  27. make clean
  28. if (( $# != 1 )); then
  29. make
  30. else
  31. if [ "${1}" = "static" ]; then
  32. make SHARED=0 CC='gcc -static'
  33. else
  34. make
  35. fi
  36. fi
  37. mv "flashrom" "flashrom_normal"
  38. # build patched binaries for MX25L1605D and SST25VF016B flash chips
  39. # - these patches are needed for initial installation on an X60 or T60
  40. # - these patches are for people who have lenovo bios running
  41. for patchname in "lenovobios_macronix" "lenovobios_sst"
  42. do
  43. # first remove the existing build
  44. rm -f "flashrom_${patchname}"
  45. # backup the unpatched flashchips.c (it will be patched)
  46. cp "flashchips.c" "flashchips.c_"
  47. # patch flashchips.c
  48. patch "flashchips.c" < "../resources/flashrom/patch/${patchname}.diff"
  49. make clean
  50. if (( $# != 1 )); then
  51. make
  52. else
  53. if [ "${1}" = "static" ]; then
  54. make SHARED=0 CC='gcc -static'
  55. else
  56. make
  57. fi
  58. fi
  59. # Rename the binary based on the patch name
  60. mv "flashrom" "flashrom_${patchname}"
  61. # restore unpatched flashchips.c
  62. rm -f "flashchips.c"
  63. mv "flashchips.c_" "flashchips.c"
  64. done
  65. mv "flashrom_normal" "flashrom"
  66. cd "../"
  67. printf "\n\n"
  68. # ------------------- DONE ----------------------