mirror of
https://github.com/levogevo/ffmpeg-builder.git
synced 2026-01-15 19:06:17 +00:00
init darwin support
This commit is contained in:
54
lib/build.sh
54
lib/build.sh
@@ -85,19 +85,30 @@ set_compile_opts() {
|
|||||||
if [[ ${STATIC} == true ]]; then
|
if [[ ${STATIC} == true ]]; then
|
||||||
LDFLAGS+=('-static')
|
LDFLAGS+=('-static')
|
||||||
CONFIGURE_FLAGS+=('--enable-static')
|
CONFIGURE_FLAGS+=('--enable-static')
|
||||||
CMAKE_FLAGS+=("-DBUILD_SHARED_LIBS=OFF")
|
|
||||||
MESON_FLAGS+=('--default-library=static')
|
MESON_FLAGS+=('--default-library=static')
|
||||||
CMAKE_FLAGS+=("-DCMAKE_EXE_LINKER_FLAGS=-static")
|
CMAKE_FLAGS+=("-DBUILD_SHARED_LIBS=OFF")
|
||||||
RUSTFLAGS+=("-C target-feature=+crt-static")
|
RUSTFLAGS+=("-C target-feature=+crt-static")
|
||||||
PKG_CFG_FLAGS='--static'
|
PKG_CFG_FLAGS='--static'
|
||||||
LIB_SUFF='a'
|
LIB_SUFF='a'
|
||||||
|
# darwin does not support static linkage
|
||||||
|
if ! is_darwin; then
|
||||||
|
CMAKE_FLAGS+=("-DCMAKE_EXE_LINKER_FLAGS=-static")
|
||||||
|
FFMPEG_EXTRA_FLAGS+=(--extra-ldflags="${LDFLAGS[*]}")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
LDFLAGS+=("-Wl,-rpath,${LIBDIR}" "-Wl,-rpath-link,${LIBDIR}")
|
LDFLAGS+=("-Wl,-rpath,${LIBDIR}" "-Wl,-rpath-link,${LIBDIR}")
|
||||||
CONFIGURE_FLAGS+=('--enable-shared')
|
CONFIGURE_FLAGS+=('--enable-shared')
|
||||||
CMAKE_FLAGS+=("-DBUILD_SHARED_LIBS=ON")
|
CMAKE_FLAGS+=(
|
||||||
CMAKE_FLAGS+=("-DCMAKE_INSTALL_RPATH=${LIBDIR}")
|
"-DBUILD_SHARED_LIBS=ON"
|
||||||
|
"-DCMAKE_INSTALL_RPATH=${LIBDIR}"
|
||||||
|
)
|
||||||
FFMPEG_EXTRA_FLAGS+=('--enable-rpath')
|
FFMPEG_EXTRA_FLAGS+=('--enable-rpath')
|
||||||
LIB_SUFF='so'
|
# darwin has different suffix for dynamic libraries
|
||||||
|
if is_darwin; then
|
||||||
|
LIB_SUFF='dylib'
|
||||||
|
else
|
||||||
|
LIB_SUFF='so'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# architecture/cpu compile flags
|
# architecture/cpu compile flags
|
||||||
@@ -132,7 +143,6 @@ set_compile_opts() {
|
|||||||
FFMPEG_EXTRA_FLAGS+=(
|
FFMPEG_EXTRA_FLAGS+=(
|
||||||
--extra-cflags="${C_FLAGS[*]}"
|
--extra-cflags="${C_FLAGS[*]}"
|
||||||
--extra-cxxflags="${CXX_FLAGS[*]}"
|
--extra-cxxflags="${CXX_FLAGS[*]}"
|
||||||
--extra-ldflags="${LDFLAGS[*]}"
|
|
||||||
)
|
)
|
||||||
dump_arr FFMPEG_EXTRA_FLAGS
|
dump_arr FFMPEG_EXTRA_FLAGS
|
||||||
|
|
||||||
@@ -346,6 +356,16 @@ build() {
|
|||||||
done
|
done
|
||||||
do_build "ffmpeg" || return 1
|
do_build "ffmpeg" || return 1
|
||||||
|
|
||||||
|
# suggestion for path
|
||||||
|
hash -r
|
||||||
|
local ffmpeg="$(command -v ffmpeg 2>/dev/null)"
|
||||||
|
if [[ ${ffmpeg} != "${PREFIX}/bin/ffmpeg" ]]; then
|
||||||
|
echo
|
||||||
|
echo_warn "ffmpeg in path (${ffmpeg}) is not the built one (${PREFIX}/bin/ffmpeg)"
|
||||||
|
echo_info "consider adding ${PREFIX}/bin to \$PATH"
|
||||||
|
echo "echo 'export PATH=\"${PREFIX}/bin/ffmpeg:\$PATH\" >> ~/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,12 +593,12 @@ add_project_versioning_to_ffmpeg() {
|
|||||||
|
|
||||||
echo_info "found ${line} on ${lineNum}"
|
echo_info "found ${line} on ${lineNum}"
|
||||||
for info in "${FFMPEG_BUILDER_INFO[@]}"; do
|
for info in "${FFMPEG_BUILDER_INFO[@]}"; do
|
||||||
local newline="\ av_log(NULL, AV_LOG_INFO, \"${info}\\\n\");"
|
local newline=" av_log(NULL, AV_LOG_INFO, \"${info}\n\");"
|
||||||
sed -i "${lineNum}i ${newline}" "${optFile}" || return 1
|
insert_line "${newline}" "${lineNum}" "${optFile}" || return 1
|
||||||
lineNum=$((lineNum + 1))
|
lineNum=$((lineNum + 1))
|
||||||
done
|
done
|
||||||
local newline="\ av_log(NULL, AV_LOG_INFO, \"\\\n\");"
|
newline=" av_log(NULL, AV_LOG_INFO, \"\n\");"
|
||||||
sed -i "${lineNum}i ${newline}" "${optFile}" || return 1
|
insert_line "${newline}" "${lineNum}" "${optFile}" || return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -605,3 +625,17 @@ build_ffmpeg() {
|
|||||||
${SUDO_MODIFY} make -j"${JOBS}" install || return 1
|
${SUDO_MODIFY} make -j"${JOBS}" install || return 1
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
# check that ffmpeg was built correctly
|
||||||
|
sanity_check_ffmpeg() {
|
||||||
|
local ffmpeg="${PREFIX}/bin/ffmpeg"
|
||||||
|
if has_cmd ldd; then
|
||||||
|
while read -r line; do
|
||||||
|
echo "${line}"
|
||||||
|
if [[ ${STATIC} == 'true' ]]; then
|
||||||
|
echo static
|
||||||
|
else
|
||||||
|
echo hi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -158,3 +158,20 @@ line_starts_with() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_darwin() {
|
||||||
|
line_contains "$(print_os)" darwin
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_line() {
|
||||||
|
local line="$1"
|
||||||
|
local lineNum="$2"
|
||||||
|
local file="$3"
|
||||||
|
ed -s "${file}" <<EOF
|
||||||
|
${lineNum}i
|
||||||
|
${line}
|
||||||
|
.
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,10 +41,9 @@ check_compile_opts_override() {
|
|||||||
declare -n optVal="${opt}"
|
declare -n optVal="${opt}"
|
||||||
# use given value if not overridden
|
# use given value if not overridden
|
||||||
if [[ -n ${optVal} && ${optVal} != "${defOptVal}" ]]; then
|
if [[ -n ${optVal} && ${optVal} != "${defOptVal}" ]]; then
|
||||||
echo_warn "setting given value for ${opt}=${optVal[*]}"
|
echo_info "setting given value for ${opt}=${optVal}"
|
||||||
declare -g "${opt}=${optVal}"
|
declare -g "${opt}=${optVal}"
|
||||||
else
|
else
|
||||||
echo_info "setting default value for ${opt}=${defOptVal[*]}"
|
|
||||||
declare -g "${opt}=${defOptVal}"
|
declare -g "${opt}=${defOptVal}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ print_os() {
|
|||||||
OS+="-${VERSION_ID}"
|
OS+="-${VERSION_ID}"
|
||||||
fi
|
fi
|
||||||
echo "${OS}"
|
echo "${OS}"
|
||||||
|
else
|
||||||
|
local os
|
||||||
|
os="$(uname -o)"
|
||||||
|
echo "${os,,}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user