aboutsummaryrefslogtreecommitdiff
path: root/builddeps-flashrom
blob: b54f1d730972398c0ebbef63c66979380dde375c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash

#  builddeps-flashrom: builds flashrom source code
#
#	Copyright (C) 2014 Francis Rowe <info@gluglug.org.uk>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script is used by the main "builddeps" script in libreboot src/meta archives.
# The reason it is seperated here is so that flashrom can be built separately aswell.

# To build flashrom, you will need the dependencies in "builddeb".
# Run it, or adapt it if you do not use an "apt-get" distro.

set -u -e -v

# Build "flashrom" (utility for flashing/dumping ROM's)
# --------------------------------------------------------------------

cd flashrom

# clean it first
make clean
# remove modified binaries aswell
rm -f flashrom_lenovobios_sst
rm -f flashrom_lenovobios_macronix

# patch flashchips.c to remove the useless Macronix entries (for X60/T60)
# makes flashrom work without having to use "-c" switch
mv flashchips.c flashchips.c_
cp ../resources/flashrom/patch/flashchips.c .
# build flashrom
if (( $# != 1 )); then
	make
else
	make SHARED=0 CC='gcc -static'
fi
# restore default flashchips.c
rm -f flashchips.c

# backup those files
mv flashrom flashrom_

# build patched version for MX25L1605D flash chip on Lenovo BIOS X60/T60
cp ../resources/flashrom/patch/flashchips.c_lenovobios_macronix flashchips.c
if (( $# != 1 )); then
	make
else
	make SHARED=0 CC='gcc -static'
fi
mv flashrom flashrom_lenovobios_macronix
rm -f flashchips.c

# build patched version for SST25VF016B flash chip on Lenovo BIOS X60/T60
cp ../resources/flashrom/patch/flashchips.c_lenovobios_sst flashchips.c
if (( $# != 1 )); then
	make
else
	make SHARED=0 CC='gcc -static'
fi
mv flashrom flashrom_lenovobios_sst
rm -f flashchips.c

# restore default binary/source
mv flashchips.c_ flashchips.c
mv flashrom_ flashrom

# done. go back to main directory
cd ../

# ------------------- DONE ----------------------