Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to build a statically linked opus-tools
#!/bin/sh
# ==============================================================
# Script to build a statically linked version of opus-tools
#
# Release tarballs:
# http://downloads.xiph.org/releases/opus/
# http://downloads.xiph.org/releases/ogg/
# http://downloads.xiph.org/releases/flac/
#
# Build deps: autoconf automake libtool pkg-config
#
# ==============================================================
export BUILD_DIR=`pwd`/build
export PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig"
export OPT_FLAGS="-fno-strict-aliasing -O3 -march=native"
RELEASES_URL=http://downloads.xiph.org/releases
SUFFIX="-static"
echo "Download source tarballs..."
for i in opus opus-tools libopusenc opusfile ogg flac ; do
echo "\nDownload $i"
case $i in
"opus"|"opus-tools"|"libopusenc"|"opusfile")
[ -f $i*tar* ] && ls $i*tar* || wget -q --show-progress "$RELEASES_URL/opus/$(wget -qO- $RELEASES_URL/opus/ | grep -oE 'href="'$i'-[0-9\.]+tar\.(gz|xz)"' | cut -d '"' -f 2 | sort -Vr | head -n 1)"
;;
"ogg")
[ -f lib${i}*tar* ] && ls lib$i*tar* || wget -q --show-progress "$RELEASES_URL/$i/$(wget -qO- $RELEASES_URL/$i/ | grep -oE 'href="'lib$i'-[0-9\.]+tar\.(gz|xz)"' | cut -d '"' -f 2 | sort -Vr | head -n 1)"
;;
"flac")
[ -f $i*tar* ] && ls $i*tar* || wget -q --show-progress "$RELEASES_URL/$i/$(wget -qO- $RELEASES_URL/$i/ | grep -oE 'href="'$i'-[0-9\.]+tar\.(gz|xz)"' | cut -d '"' -f 2 | sort -Vr | head -n 1)"
;;
esac
done
echo "\nDone\n"
for file in *.tar.gz; do tar -xzf "$file"; done
for file in *.tar.xz; do tar -xJf "$file"; done
[ -d "$BUILD_DIR" ] || mkdir "$BUILD_DIR"
# build libogg
cd $(ls -d libogg-*/)
autoreconf -fi && \
CFLAGS="$OPT_FLAGS" \
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-dependency-tracking
make clean
make -j $(nproc) install
cd ..
# build FLAC
cd $(ls -d flac-*/)
autoreconf -fi && \
CFLAGS="$OPT_FLAGS" \
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-dependency-tracking \
--disable-debug \
--disable-oggtest \
--disable-cpplibs \
--disable-doxygen-docs \
--with-ogg="$BUILD_DIR"
make clean
make -j $(nproc) install
cd ..
# build Opus
cd $(ls -d opus-*/)
CFLAGS="$OPT_FLAGS" \
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-dependency-tracking \
--disable-maintainer-mode \
--disable-doc \
--disable-extra-programs
make clean
make -j $(nproc) install
cd ..
# build opusfile
cd $(ls -d opusfile-*/)
CFLAGS="$OPT_FLAGS" \
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-dependency-tracking \
--disable-maintainer-mode \
--disable-examples \
--disable-doc \
--disable-http
make clean
make -j $(nproc) install
cd ..
# build libopusenc
cd $(ls -d libopusenc-*/)
CFLAGS="$OPT_FLAGS" \
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-dependency-tracking \
--disable-maintainer-mode \
--disable-examples \
--disable-doc
make clean
make -j $(nproc) install
cd ..
# build opus-tools
cd $(ls -d opus-tools-*/)
CFLAGS="$OPT_FLAGS" \
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-dependency-tracking \
--disable-maintainer-mode
make clean
make -j $(nproc) install
cd ..
if ls $BUILD_DIR/bin/opus* > /dev/null 2>&1 ; then
for file in $BUILD_DIR/bin/opus* ; do
cp $file $PWD/$(basename $file)$SUFFIX
strip $PWD/$(basename $file)$SUFFIX
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.