2022-11-11 18:15:45 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
SCRIPT_REPO="https://github.com/xiph/opus.git"
|
2024-10-16 18:12:45 +08:00
|
|
|
SCRIPT_COMMIT="7db26934e4156597cb0586bb4d2e44dccdde1a59"
|
2022-11-11 18:15:45 +08:00
|
|
|
|
|
|
|
|
ffbuild_enabled() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ffbuild_dockerbuild() {
|
|
|
|
|
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" opus
|
|
|
|
|
cd opus
|
|
|
|
|
|
|
|
|
|
./autogen.sh
|
|
|
|
|
|
|
|
|
|
local myconf=(
|
|
|
|
|
--prefix="$FFBUILD_PREFIX"
|
|
|
|
|
--disable-shared
|
|
|
|
|
--enable-static
|
|
|
|
|
--disable-extra-programs
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if [[ $TARGET == win* || $TARGET == linux* ]]; then
|
|
|
|
|
myconf+=(
|
|
|
|
|
--host="$FFBUILD_TOOLCHAIN"
|
|
|
|
|
)
|
2024-02-24 00:07:11 +08:00
|
|
|
elif [[ $TARGET == mac* ]]; then
|
|
|
|
|
:
|
2022-11-11 18:15:45 +08:00
|
|
|
else
|
|
|
|
|
echo "Unknown target"
|
|
|
|
|
return -1
|
|
|
|
|
fi
|
|
|
|
|
|
2024-12-20 15:13:59 +08:00
|
|
|
if [[ $TARGET == linux* || $TARGET == mac* ]] && [[ $TARGET == *arm64 ]]; then
|
|
|
|
|
myconf+=(
|
|
|
|
|
--with-NE10-libraries="$FFBUILD_PREFIX"/lib
|
|
|
|
|
--with-NE10-includes="$FFBUILD_PREFIX"/include/libNE10
|
|
|
|
|
)
|
|
|
|
|
fi
|
|
|
|
|
|
2024-12-20 21:58:50 +08:00
|
|
|
# reset CLFAGS because libopus may give up optimization if current CFLAGS contains value
|
|
|
|
|
CFLAGS_BACKUP="$CFLAGS"
|
2024-12-21 00:39:41 +08:00
|
|
|
|
|
|
|
|
# For some reason libopus will not add optimization flag, we have to set it ourselves
|
|
|
|
|
if [[ $TARGET == mac* ]]; then
|
2024-12-21 00:44:23 +08:00
|
|
|
export CFLAGS="-O3"
|
|
|
|
|
else
|
|
|
|
|
export CFLAGS="-O3 -fPIC -DPIC"
|
|
|
|
|
fi
|
2024-12-20 21:58:50 +08:00
|
|
|
|
2022-11-11 18:15:45 +08:00
|
|
|
./configure "${myconf[@]}"
|
|
|
|
|
make -j$(nproc)
|
|
|
|
|
make install
|
2024-12-20 15:13:59 +08:00
|
|
|
|
2024-12-20 21:58:50 +08:00
|
|
|
export CFLAGS="$CFLAGS_BACKUP"
|
|
|
|
|
|
2024-12-20 15:13:59 +08:00
|
|
|
if [[ $TARGET == *arm64 ]]; then
|
|
|
|
|
if [[ $TARGET == mac* ]]; then
|
|
|
|
|
gsed -i 's/-lopus/-lopus -lNE10/' "$FFBUILD_PREFIX"/lib/pkgconfig/opus.pc
|
|
|
|
|
gsed -i 's/-I${includedir}\/opus/-I${includedir}\/opus -I${includedir}\/libNE10/' "$FFBUILD_PREFIX"/lib/pkgconfig/opus.pc
|
|
|
|
|
else
|
|
|
|
|
sed -i 's/-lopus/-lopus -lNE10/' "$FFBUILD_PREFIX"/lib/pkgconfig/opus.pc
|
|
|
|
|
sed -i 's/-I${includedir}\/opus/-I${includedir}\/opus -I${includedir}\/libNE10/' "$FFBUILD_PREFIX"/lib/pkgconfig/opus.pc
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2022-11-11 18:15:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ffbuild_configure() {
|
|
|
|
|
echo --enable-libopus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ffbuild_unconfigure() {
|
|
|
|
|
echo --disable-libopus
|
|
|
|
|
}
|