-
-
Save 38github/c922e4650a09f01fb50695a07f5d8356 to your computer and use it in GitHub Desktop.
Script to build a statically linked opus-tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
In OpenSUSE Tumbleweed with GCC 13 I had to change line 72 from
cd $(ls -d opus-*/)
tocd $(ls -d opus-1*/)
. Probably because the wildcard didn't know if it should pick folderopus-1.4
oropus-tools-0.2
.I also had to run the compile as sudo because of a linking/LD error.