-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathbuild_static.sh
executable file
·83 lines (66 loc) · 2.12 KB
/
build_static.sh
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
#!/usr/bin/env bash
#
# Build a static (or mostly static) version of fwup
#
# Inputs:
# CROSS_COMPILE - if set to a gcc tuple, tries to crosscompile
# (e.g., x86_64-w64-mingw32)
#
# This script creates a static build of fwup to avoid dependency issues
# with libconfuse and libarchive.
#
# To build the Windows executable on Linux:
# sudo apt-get install gcc-mingw-w64-x86-64
# CROSS_COMPILE=x86_64-w64-mingw32 ./scripts/build_pkg.sh
#
set -e
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
source $BASE_DIR/scripts/common.sh
# Initial sanity checks
if [ ! -e $BASE_DIR/configure ]; then
echo "Please run from the fwup base directory and make sure that the ./configure file exists."
echo "If you're building from source, you may need to run ./autogen.sh."
exit 1
fi
if [ -e $BASE_DIR/Makefile ]; then
# Run distclean to ensure that we have a clean build.
make -C $BASE_DIR distclean
fi
# Build the dependencies
$BASE_DIR/scripts/build_deps.sh
# Initialize some directories
mkdir -p $BUILD_DIR
mkdir -p $FWUP_INSTALL_DIR
cd $BUILD_DIR
# Build fwup (symlink now, since out-of-tree fwup build is broke)
ln -sf $BASE_DIR $BUILD_DIR/fwup
cd $BUILD_DIR/fwup
PKG_CONFIG_PATH=$PKG_CONFIG_PATH ./configure $CONFIGURE_ARGS --prefix=$FWUP_INSTALL_DIR --enable-shared=no || cat config.log
make clean
make $MAKE_FLAGS
if [ -z "$CROSS_COMPILE" ]; then
# Verify that it was statically linked
for CHECK_LIB in libz confuse archive; do
if $LDD src/fwup | grep $CHECK_LIB; then
echo "fwup was dynamically linked to $CHECK_LIB. This should not happen.";
exit 1
fi
done
fi
if [ "$CROSS_COMPILE" != "arm-linux-gnueabihf" ]; then
# Run the regression tests
if [ "$MODE" = "windows" ]; then
# Make sure that wine is initialized by running it once.
wine src/fwup.exe || true
fi
if ! make $MAKE_FLAGS check; then
cat tests/test-suite.log
exit 1
fi
fi
make install-strip
make dist
# Return to the base directory
cd $BASE_DIR
echo "Static build successful."
echo "The fwup installation is in $FWUP_INSTALL_DIR."