-
Notifications
You must be signed in to change notification settings - Fork 50
/
build_linux.sh
executable file
·82 lines (73 loc) · 2.52 KB
/
build_linux.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_linux.sh
#
# Build script for Ubuntu and Fedora Linux, git pulls codec2 and
# lpcnet repos so they are available for parallel development.
# Echo what you are doing, and fail if any of the steps fail:
set -x -e
UT_ENABLE=${UT_ENABLE:-0}
LPCNET_DISABLE=${LPCNET_DISABLE:-0}
# Allow building of either PulseAudio or PortAudio variants
FREEDV_VARIANT=${1:-pulseaudio}
if [[ "$FREEDV_VARIANT" != "portaudio" && "$FREEDV_VARIANT" != "pulseaudio" ]]; then
echo "Usage: build_linux.sh [portaudio|pulseaudio]"
exit -1
fi
export FREEDVGUIDIR=${PWD}
export CODEC2DIR=$FREEDVGUIDIR/codec2
export LPCNETDIR=$FREEDVGUIDIR/LPCNet
# change this when working on combined codec2/freedv-gui changes
CODEC2_BRANCH=1.2.0
LPCNET_BRANCH=v0.5
# OK, build and test LPCNet
cd $FREEDVGUIDIR
if [ $LPCNET_DISABLE == 0 ]; then
if [ ! -d LPCNet ]; then
git clone https://github.com/drowe67/LPCNet.git
fi
cd $LPCNETDIR && git switch master && git pull && git checkout $LPCNET_BRANCH
mkdir -p build_linux && cd build_linux && rm -Rf *
cmake ..
if [ $? == 0 ]; then
make
if [ $? == 0 ]; then
# sanity check test
cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null
else
echo "Warning: LPCNet build failed, disabling"
LPCNET_DISABLE=1
fi
else
echo "Warning: LPCNet build failed, disabling"
LPCNET_DISABLE=1
fi
fi
if [ $LPCNET_DISABLE == 0 ]; then
LPCNET_CMAKE_CMD="-DLPCNET_BUILD_DIR=$LPCNETDIR/build_linux"
fi
# First build and install vanilla codec2 as we need -lcodec2 to build LPCNet
cd $FREEDVGUIDIR
if [ ! -d codec2 ]; then
git clone https://github.com/drowe67/codec2.git
fi
cd codec2 && git switch main && git pull && git checkout $CODEC2_BRANCH
mkdir -p build_linux && cd build_linux && rm -Rf * && cmake $LPCNET_CMAKE_CMD .. && make VERBOSE=1
if [ $LPCNET_DISABLE == 0 ]; then
# sanity check test
cd src
export LD_LIBRARY_PATH=$LPCNETDIR/build_linux/src
./freedv_tx 2020 $LPCNETDIR/wav/wia.wav - | ./freedv_rx 2020 - /dev/null
fi
# Finally, build freedv-gui
cd $FREEDVGUIDIR
if [ -d .git ]; then
git pull
fi
mkdir -p build_linux && cd build_linux && rm -Rf *
if [[ "$FREEDV_VARIANT" == "pulseaudio" ]]; then
PULSEAUDIO_PARAM="-DUSE_PULSEAUDIO=1"
else
PULSEAUDIO_PARAM="-DUSE_PULSEAUDIO=0"
fi
cmake $PULSEAUDIO_PARAM -DUNITTEST=$UT_ENABLE -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/build_linux $LPCNET_CMAKE_CMD ..
make VERBOSE=1