@@ -11,6 +11,18 @@ VPD_VERSION="release-R74-11895.B"
11
11
rm -rf " ${OUTDIR} "
12
12
mkdir -p " ${OUTDIR} "
13
13
14
+ check_if_statically_linked () {
15
+ f=$1
16
+ # ldd exits with an error if it's not a dynamic executable, so exit 0 here
17
+ # means error,
18
+ ldd " ${f} " && \
19
+ (
20
+ echo " ERROR: $f is not statically linked"
21
+ exit 1
22
+ ) || \
23
+ true # all good
24
+ }
25
+
14
26
# build kexec-tools
15
27
cd " ${OUTDIR} "
16
28
git clone git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
@@ -19,11 +31,11 @@ git checkout -b "${KEXEC_TOOLS_VERSION}"
19
31
./bootstrap
20
32
# just optimize for space. Kexec uses kernel headers so we cannot use musl-gcc
21
33
# here. See https://wiki.musl-libc.org/faq.html#Q:-Why-am-I-getting-
22
- CFLAGS=-Os ./configure
34
+ CFLAGS=-Os LDFLAGS=-static ./configure
23
35
make
24
36
strip build/sbin/kexec
25
37
du -hs build/sbin/kexec
26
- ldd build/sbin/kexec
38
+ check_if_statically_linked build/sbin/kexec
27
39
28
40
# build flashrom
29
41
cd " ${OUTDIR} "
@@ -32,10 +44,13 @@ cd flashrom
32
44
git checkout -b " ${FLASHROM_VERSION} "
33
45
# no musl-gcc here either, as flashrom needs libpci-dev (we may remove PCI
34
46
# programmers from the build at a later stage though)
35
- CFLAGS=-Os make
47
+ CONFIG_STATIC=yes \
48
+ CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no \
49
+ CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no \
50
+ make
36
51
strip flashrom
37
52
du -hs flashrom
38
- ldd flashrom
53
+ check_if_statically_linked flashrom
39
54
40
55
# build memtester
41
56
cd " ${OUTDIR} "
@@ -45,14 +60,17 @@ ln -s "memtester-${MEMTESTER_VERSION}" memtester
45
60
cd " memtester-${MEMTESTER_VERSION} "
46
61
CFLAGS=-Os CC=musl-gcc make # build statically
47
62
du -hs memtester
48
- ldd memtester
63
+ check_if_statically_linked memtester
49
64
50
65
# build vpd
51
66
cd " ${OUTDIR} "
52
67
git clone https://chromium.googlesource.com/chromiumos/platform/vpd
53
68
cd vpd
54
69
git checkout " ${VPD_VERSION} "
55
70
make
71
+ # rename vpd_s to vpd for our purposes. This overwrites the original,
72
+ # dynamically linked, vpd binary, but we don't need it.
73
+ mv vpd_s vpd
56
74
strip vpd
57
75
du -hs vpd
58
- ldd vpd
76
+ check_if_statically_linked vpd
0 commit comments