builddeps-flashrom 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. # builddeps-flashrom: builds flashrom source code
  3. #
  4. # Copyright (C) 2014 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. # To build flashrom, you will need the dependencies (see docs).
  20. set -u -e -v
  21. # Build "flashrom" (utility for flashing/dumping ROM's)
  22. # --------------------------------------------------------------------
  23. cd flashrom/
  24. # build regular flashrom (redundant flash chip definitions removed)
  25. make clean
  26. if (( $# != 1 )); then
  27. # build it dynamically linked
  28. make
  29. else
  30. # build it statically linked
  31. make SHARED=0 CC='gcc -static'
  32. fi
  33. mv flashrom flashrom_normal
  34. # build patched binaries for MX25L1605D and SST25VF016B flash chips
  35. # - these patches are needed for initial installation on an X60 or T60
  36. # - these patches are for people who have lenovo bios running
  37. for patchname in "lenovobios_macronix" "lenovobios_sst"
  38. do
  39. # first remove the existing build
  40. make clean
  41. rm -f flashrom_"$patchname"
  42. # backup the unpatched flashchips.c (it will be patched)
  43. cp flashchips.c flashchips.c_
  44. # patch flashchips.c
  45. patch flashchips.c < ../resources/flashrom/patch/"$patchname".diff
  46. if (( $# != 1 )); then
  47. # build it dynamically linked
  48. make
  49. else
  50. # build it statically linked
  51. make SHARED=0 CC='gcc -static'
  52. fi
  53. # Rename the binary based on the patch name
  54. mv flashrom flashrom_"$patchname"
  55. # restore unpatched flashchips.c
  56. rm -f flashchips.c
  57. mv flashchips.c_ flashchips.c
  58. done
  59. mv flashrom_normal flashrom
  60. cd ../
  61. # ------------------- DONE ----------------------