-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·166 lines (140 loc) · 6.94 KB
/
build.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
set -e
FIRMWARE=${FIRMWARE:=0.38}
export builddir="${builddir:-$(pwd)}"
date +%F >"${builddir}/RELEASE-VERSION.txt"
export releaseinfo="${builddir}/RELEASE-INFO.md"
echo -n >"${releaseinfo}"
# Setup Toolchain
if [ -z "${tools}" -a -n "$(command -v arm-linux-gnueabihf-gcc)" ] ; then
export tools=$(dirname $(dirname $(command -v arm-linux-gnueabihf-gcc)))
echo "- Compiler: $(arm-linux-gnueabihf-gcc --version | head -1)" >>"${releaseinfo}"
fi
if [ -z "${tools}" -a -d "gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf" ] ; then
export tools="${builddir}/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf"
export PATH="${tools}/bin:$PATH"
echo '- Compiler: gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf' >>"${releaseinfo}"
fi
if [ -z "${tools}" -a -d "gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf" ] ; then
export tools="${builddir}/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf"
export PATH="${tools}/bin:$PATH"
echo '- Compiler: gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf' >>"${releaseinfo}"
fi
if [ -z "${tools}" -a -d "/opt/Xilinx/SDK/2019.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi" ] ; then
export tools="/opt/Xilinx/SDK/2019.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi"
export PATH="${tools}/bin:$PATH"
echo "- Compiler: $(arm-linux-gnueabihf-gcc --version | head -1)" >>"${releaseinfo}"
fi
if [ -z "${tools}" ] ; then
echo 'Toolchain "arm-linux-gnueabihf" not found. On Debian try:'
echo '$ sudo apt-get install -y crossbuild-essential-armhf'
echo 'Or a standalone toolchain:'
echo '$ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2019.01/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf.tar.xz'
echo '$ tar xf gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf.tar.xz'
echo 'Or for newer firmware versions:'
echo '$ wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-linux-gnueabihf/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz'
echo '$ tar xf gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz'
exit 1
fi
# Setup Sysroot
if [ ! -d staging ] ; then
[ -f sysroot-v${FIRMWARE}.tar.gz ] || wget https://github.com/analogdevicesinc/plutosdr-fw/releases/download/v${FIRMWARE}/sysroot-v${FIRMWARE}.tar.gz
tar xzf sysroot-v${FIRMWARE}.tar.gz
fi
echo "- plutosdr-fw: sysroot v${FIRMWARE}" >>"${releaseinfo}"
export sysroot="${sysroot:-${builddir}/staging}"
export stagedir="${stagedir:-${builddir}/stage}"
export toolchain="${toolchain:-${builddir}/Toolchain-arm-linux-gnueabi.cmake}"
# Compile Apps
#export CFLAGS="-Werror"
#export CXXFLAGS="-Werror -Wno-psabi"
[ -d SoapySDR ] || git clone --depth 1 https://github.com/pothosware/SoapySDR.git
pushd SoapySDR
echo -n '- SoapySDR: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
rm -rf build ; mkdir build
cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_PYTHON=OFF -DENABLE_PYTHON3=OFF -B build
cmake --build build -- install
popd
[ -d SoapyPlutoSDR ] || git clone --depth 1 https://github.com/pothosware/SoapyPlutoSDR.git
pushd SoapyPlutoSDR
echo -n '- SoapyPlutoSDR: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
rm -rf build ; mkdir build
cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" -B build
cmake --build build -- install
popd
[ -d SoapyRemote ] || git clone --depth 1 https://github.com/pothosware/SoapyRemote.git
pushd SoapyRemote
echo -n '- SoapyRemote: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
rm -rf build ; mkdir build
cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" -B build
cmake --build build -- install
popd
[ -d rtl_433 ] || git clone --depth 1 https://github.com/merbanan/rtl_433.git
pushd rtl_433
echo -n '- rtl_433: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
rm -rf build ; mkdir build
cmake -DENABLE_RTLSDR=OFF -DENABLE_SOAPYSDR=ON -DENABLE_OPENSSL=OFF -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" -B build
cmake --build build -- install
popd
[ -d rx_tools ] || git clone --depth 1 https://github.com/rxseger/rx_tools.git
pushd rx_tools
echo -n '- rx_tools: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
rm -rf build ; mkdir build
cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" -B build
cmake --build build -- install
popd
[ -d tx_tools ] || git clone --depth 1 https://github.com/triq-org/tx_tools.git
pushd tx_tools
echo -n '- tx_tools: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
rm -rf build ; mkdir build
cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" -B build
cmake --build build -- install
popd
# Note: dumb http transport does not support shallow capabilities
[ -d chrony ] || git clone https://git.tuxfamily.org/chrony/chrony.git
pushd chrony
echo -n '- chrony: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
CC="arm-linux-gnueabihf-gcc" CFLAGS="--sysroot ${sysroot}" ./configure --prefix=/usr
# sudo apt-get install -y bison
make
# make install DESTDIR=${stagedir} BINDIR=/bin SBINDIR=/bin
cp -a chronyc chronyd "${stagedir}/bin/"
popd
[ -d gpsd ] || git clone --depth 1 git://git.savannah.gnu.org/gpsd.git
pushd gpsd
echo -n '- gpsd: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
# sudo apt-get install -y scons
DESTDIR="${stagedir}" scons libgpsmm=No ncurses=No python=No sbindir=bin prefix=/ sysroot="${sysroot}" target=arm-linux-gnueabihf build install
popd
[ -d iperf ] || git clone --depth 1 https://github.com/esnet/iperf.git
pushd iperf
echo -n '- iperf: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
CFLAGS="--sysroot ${sysroot}" ./configure --without-openssl --prefix=/usr --host=arm-linux-gnueabihf --enable-static --disable-shared
make
make install DESTDIR=${stagedir} prefix=/
popd
[ -d socat ] || git clone --depth 1 git://repo.or.cz/socat.git
pushd socat
echo -n '- socat: ' >>"${releaseinfo}"
git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}"
autoconf
CFLAGS="--sysroot ${sysroot}" ./configure --disable-openssl --prefix=/usr --host=arm-linux-gnueabihf
# this might be wrongly detected
echo '#undef HAVE_SYS_STROPTS_H' >>config.h
# sudo apt-get install -y yodl
make
make install DESTDIR=${stagedir} prefix=/
popd
# Dist Package
cd "${stagedir}"
find . -ls
tar czf "${builddir}/plutosdr-apps.tar.gz" bin lib/lib* lib/SoapySDR