Skip to content

Instantly share code, notes, and snippets.

@guest271314
Forked from spvkgn/opus-tools_static_build.sh
Last active November 6, 2022 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guest271314/12a93ff775590867c0862be45fc71161 to your computer and use it in GitHub Desktop.
Save guest271314/12a93ff775590867c0862be45fc71161 to your computer and use it in GitHub Desktop.
Script to build a statically linked opus-tools from github
#!/bin/sh
# ==============================================================
# Script to build a statically linked version of opus-tools
# https://gist.github.com/spvkgn/60c12010d4cae1243dfee45b0821f692
#
# https://github.com/xiph/ogg.git
# https://github.com/xiph/opus.git
# https://github.com/xiph/opusfile.git
# https://github.com/xiph/opus-tools.git
# https://github.com/xiph/flac.git
# https://github.com/xiph/libopusenc.git
#
# 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"
XIPH=https://github.com/xiph/
LIBS=(ogg opus opusfile opus-tools flac libopusenc)
SUFFIX="-static"
echo "Cloning git repositories..."
for LIB in "${LIBS[@]}"
do
git clone "$XIPH$LIB"
done
[ -d "$BUILD_DIR" ] || mkdir "$BUILD_DIR"
# build libogg
cd ${LIBS[0]}
./autogen.sh
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static
make clean
make -j $(nproc) install
cd ..
# build Opus
cd ${LIBS[1]}
./autogen.sh
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-maintainer-mode \
--disable-doc \
--disable-extra-programs
make clean
make -j $(nproc) install
cd ..
# build opusfile
cd ${LIBS[2]}
./autogen.sh
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-maintainer-mode \
--disable-examples \
--disable-doc \
--disable-http
make clean
make -j $(nproc) install
cd ..
# build opus-tools
cd ${LIBS[3]}
./autogen.sh
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-maintainer-mode
make clean
make -j $(nproc) install
cd ..
# build FLAC
cd ${LIBS[4]}
./autogen.sh
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-debug \
--disable-oggtest \
--disable-cpplibs \
--disable-doxygen-docs \
--with-ogg="$BUILD_DIR"
make clean
make -j $(nproc) install
cd ..
# build libopusenc
cd ${LIBS[5]}
./autogen.sh
./configure --prefix=$BUILD_DIR \
--disable-shared --enable-static \
--disable-maintainer-mode \
--disable-examples \
--disable-doc
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
@38github
Copy link

38github commented Jul 26, 2022

opusfile complained that it could not find libopusenc so I rearranged the order of the packages under LIBS and I managed to compile successfully.

Old line 22: (ogg opus opusfile opus-tools flac libopusenc)
New Line 22: LIBS=(flac ogg opus libopusenc opusfile opus-tools)

I guess I should have changed ${LIBS[0]} numbers instead so that the packages recieves its correct parameters.

@guest271314
Copy link
Author

@38github Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment