many small fixes to allow user-overridable defaults

This commit is contained in:
2025-08-17 18:25:06 -05:00
parent 4345ca5878
commit 65d8d24480
6 changed files with 119 additions and 90 deletions

View File

@@ -3,26 +3,49 @@
# variables used externally
# shellcheck disable=SC2034
# default compile options
# clean build directories before building
CLEAN=true
DEFAULT_CLEAN=true
# enable link time optimization
LTO=false
DEFAULT_LTO=true
# optimization level (0-3)
OPT_LVL=0
DEFAULT_OPT_LVL=3
# static or shared build
STATIC=true
DEFAULT_STATIC=true
# CPU type (amd64/v{1,2,3}...)
CPU=native
DEFAULT_CPU=native
# architecture type
ARCH=native
# prefix to install, leave empty for non-system install (local)
PREFIX=''
DEFAULT_ARCH=native
# prefix to install to, default is local install
DEFAULT_PREFIX='local'
# configure what ffmpeg enables
FFMPEG_ENABLES=(
libopus
libdav1d
libsvtav1_psy
libaom
librav1e
libvmaf
DEFAULT_FFMPEG_ENABLES="\
libsvtav1_psy \
libopus \
libdav1d \
libaom \
librav1e \
libvmaf \
"
# user-overridable compile option variable names
FB_COMP_OPTS=(
CLEAN LTO OPT_LVL STATIC CPU ARCH PREFIX FFMPEG_ENABLES
)
# sets FB_COMP_OPTS to allow for user-overriding
check_compile_opts_override() {
for opt in "${FB_COMP_OPTS[@]}"; do
declare -n defOptVal="DEFAULT_${opt}"
declare -n optVal="${opt}"
# use given value if not overridden
if [[ -n ${optVal} && ${optVal} != "${defOptVal}" ]]; then
echo_warn "setting given value for ${opt}=${optVal[*]}"
declare -g "${opt}=${optVal}"
else
echo_info "setting default value for ${opt}=${defOptVal[*]}"
declare -g "${opt}=${defOptVal}"
fi
done
}