Make builds incremental by preserving source/build dirs (#45)
This commit is contained in:
@@ -5,23 +5,22 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
FFMPEG_VERSION="7.1"
|
||||
ZLIB_VERSION="da607da739fa6047df13e66a2af6b8bec7c2a498" # v1.3.2
|
||||
X264_BRANCH="stable"
|
||||
INSTALL_DIR="$DIR/ffmpeg/install"
|
||||
|
||||
# Idempotent: skip if already built
|
||||
if [ -x "$INSTALL_DIR/bin/ffmpeg" ]; then
|
||||
echo "ffmpeg already present, skipping build."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||
CC="ccache ${CC:-cc}"
|
||||
PREFIX="$DIR/build/prefix"
|
||||
mkdir -p "$DIR/build"
|
||||
|
||||
# --- Build zlib (static) ---
|
||||
if [ ! -d "zlib-src" ]; then
|
||||
git clone https://github.com/madler/zlib.git zlib-src
|
||||
git -C zlib-src checkout da607da739fa6047df13e66a2af6b8bec7c2a498 # pin to v1.3.2
|
||||
if [ ! -d "zlib-src/.git" ]; then
|
||||
rm -rf zlib-src
|
||||
git clone --depth 1 https://github.com/madler/zlib.git zlib-src
|
||||
fi
|
||||
git -C zlib-src fetch --depth 1 origin "$ZLIB_VERSION"
|
||||
git -C zlib-src checkout --force "$ZLIB_VERSION"
|
||||
|
||||
cd zlib-src
|
||||
./configure --prefix="$PREFIX" --static
|
||||
@@ -30,9 +29,12 @@ make install
|
||||
cd "$DIR"
|
||||
|
||||
# --- Build x264 (static) ---
|
||||
if [ ! -d "x264-src" ]; then
|
||||
git clone --depth 1 --branch stable https://code.videolan.org/videolan/x264.git x264-src
|
||||
if [ ! -d "x264-src/.git" ]; then
|
||||
rm -rf x264-src
|
||||
git clone --depth 1 https://code.videolan.org/videolan/x264.git x264-src
|
||||
fi
|
||||
git -C x264-src fetch --depth 1 origin "$X264_BRANCH"
|
||||
git -C x264-src checkout --force FETCH_HEAD
|
||||
|
||||
cd x264-src
|
||||
CFLAGS="-fno-finite-math-only" ./configure \
|
||||
@@ -47,13 +49,17 @@ make install
|
||||
cd "$DIR"
|
||||
|
||||
# --- Build FFmpeg ---
|
||||
if [ ! -d "ffmpeg-src" ]; then
|
||||
git clone --depth 1 --branch "n${FFMPEG_VERSION}" https://github.com/FFmpeg/FFmpeg.git ffmpeg-src
|
||||
if [ ! -d "ffmpeg-src/.git" ]; then
|
||||
rm -rf ffmpeg-src
|
||||
git clone --depth 1 https://github.com/FFmpeg/FFmpeg.git ffmpeg-src
|
||||
fi
|
||||
git -C ffmpeg-src fetch --depth 1 origin "n${FFMPEG_VERSION}"
|
||||
git -C ffmpeg-src checkout --force FETCH_HEAD
|
||||
|
||||
cd ffmpeg-src
|
||||
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" \
|
||||
./configure \
|
||||
--cc="${CC:-cc}" \
|
||||
--prefix="$PREFIX" \
|
||||
--enable-gpl \
|
||||
--enable-static \
|
||||
@@ -100,8 +106,5 @@ done
|
||||
# Strip binaries
|
||||
strip "$INSTALL_DIR/bin/ffmpeg" "$INSTALL_DIR/bin/ffprobe" 2>/dev/null || true
|
||||
|
||||
# Clean up
|
||||
rm -rf zlib-src x264-src ffmpeg-src "$DIR/build"
|
||||
|
||||
echo "Installed ffmpeg to $INSTALL_DIR"
|
||||
du -sh "$INSTALL_DIR"
|
||||
|
||||
Reference in New Issue
Block a user