@@ -11,6 +11,18 @@ VPD_VERSION="release-R74-11895.B"
1111rm -rf " ${OUTDIR} "
1212mkdir -p " ${OUTDIR} "
1313
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+
1426# build kexec-tools
1527cd " ${OUTDIR} "
1628git clone git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
@@ -19,11 +31,11 @@ git checkout -b "${KEXEC_TOOLS_VERSION}"
1931./bootstrap
2032# just optimize for space. Kexec uses kernel headers so we cannot use musl-gcc
2133# here. See https://wiki.musl-libc.org/faq.html#Q:-Why-am-I-getting-
22- CFLAGS=-Os ./configure
34+ CFLAGS=-Os LDFLAGS=-static ./configure
2335make
2436strip build/sbin/kexec
2537du -hs build/sbin/kexec
26- ldd build/sbin/kexec
38+ check_if_statically_linked build/sbin/kexec
2739
2840# build flashrom
2941cd " ${OUTDIR} "
@@ -32,10 +44,13 @@ cd flashrom
3244git checkout -b " ${FLASHROM_VERSION} "
3345# no musl-gcc here either, as flashrom needs libpci-dev (we may remove PCI
3446# 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
3651strip flashrom
3752du -hs flashrom
38- ldd flashrom
53+ check_if_statically_linked flashrom
3954
4055# build memtester
4156cd " ${OUTDIR} "
@@ -45,14 +60,17 @@ ln -s "memtester-${MEMTESTER_VERSION}" memtester
4560cd " memtester-${MEMTESTER_VERSION} "
4661CFLAGS=-Os CC=musl-gcc make # build statically
4762du -hs memtester
48- ldd memtester
63+ check_if_statically_linked memtester
4964
5065# build vpd
5166cd " ${OUTDIR} "
5267git clone https://chromium.googlesource.com/chromiumos/platform/vpd
5368cd vpd
5469git checkout " ${VPD_VERSION} "
5570make
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
5674strip vpd
5775du -hs vpd
58- ldd vpd
76+ check_if_statically_linked vpd
0 commit comments