mirror of
https://github.com/HandBrake/HandBrake-docs.git
synced 2025-12-10 00:44:52 -06:00
build: Add libpng, pngquant, zlib, and zopfli targets.
Refactor build scripts.
This commit is contained in:
parent
356aad1aa7
commit
9e68f4574a
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,9 @@
|
||||
# Prevent overwriting user config
|
||||
config.yaml
|
||||
|
||||
# Ignore tools directories
|
||||
tools/local
|
||||
|
||||
# Ignore generated documents but keep the docs directory
|
||||
docs/*
|
||||
!docs/.gitkeep
|
||||
|
||||
20
build-docs
20
build-docs
@ -2,16 +2,16 @@
|
||||
|
||||
# vars
|
||||
SELF="${BASH_SOURCE[0]}"
|
||||
BASE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
||||
BASE_DIR="${BASE_DIR:-$(pwd)}"
|
||||
CONFIG="${BASE_DIR}/config.yaml"
|
||||
DOCS_DIR="${BASE_DIR}/docs"
|
||||
SOURCE_DIR="${BASE_DIR}/source"
|
||||
TEMPLATE_DIR="${BASE_DIR}/templates"
|
||||
TOOLS_DIR="${BASE_DIR}/tools"
|
||||
SELF_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
||||
SELF_DIR="${SELF_DIR:-$(pwd)}"
|
||||
CONFIG="${SELF_DIR}/config.yaml"
|
||||
DOCS_DIR="${SELF_DIR}/docs"
|
||||
SOURCE_DIR="${SELF_DIR}/source"
|
||||
TEMPLATE_DIR="${SELF_DIR}/templates"
|
||||
TOOLS_BIN="${SELF_DIR}/tools/local/bin"
|
||||
|
||||
# dependencies
|
||||
MARKDOWN="${BASE_DIR}/tools/discount/markdown"
|
||||
MARKDOWN="${TOOLS_BIN}/markdown"
|
||||
DEPS=("${MARKDOWN}")
|
||||
|
||||
# optional dependencies
|
||||
@ -213,7 +213,7 @@ function build_source {
|
||||
}
|
||||
|
||||
# base directory (absolute)
|
||||
cd "${BASE_DIR}"
|
||||
cd "${SELF_DIR}"
|
||||
|
||||
# check deps
|
||||
check_dependencies "${DEPS[@]}" || exit 1
|
||||
@ -293,7 +293,7 @@ else
|
||||
done
|
||||
cd "${SOURCE_DIR}"
|
||||
done
|
||||
cd "${BASE_DIR}"
|
||||
cd "${SELF_DIR}"
|
||||
|
||||
# sources
|
||||
SOURCES=($(find "${DOCS_DIR}" | sed 's/^\.\///' | grep -i '.markdown'))
|
||||
|
||||
74
build-tools
74
build-tools
@ -2,41 +2,75 @@
|
||||
|
||||
# vars
|
||||
SELF="${BASH_SOURCE[0]}"
|
||||
BASE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
||||
BASE_DIR="${BASE_DIR:-$(pwd)}"
|
||||
TOOLS_DIR="${BASE_DIR}/tools"
|
||||
SYSTEM_NAME=$(uname -s)
|
||||
SELF_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
||||
SELF_DIR="${SELF_DIR:-$(pwd)}"
|
||||
TOOLS_DIR="${SELF_DIR}/tools"
|
||||
BUILD_DIR="${TOOLS_DIR}/local/build"
|
||||
INSTALL_DIR="${TOOLS_DIR}/local"
|
||||
TOOLS=('discount' 'zlib' 'libpng' 'pngquant' 'zopfli')
|
||||
|
||||
# discount
|
||||
function build_discount {
|
||||
cd "${TOOLS_DIR}/discount"
|
||||
if make clean; then
|
||||
make distclean
|
||||
fi
|
||||
if [[ "${SYSTEM_NAME}" == "Darwin" ]]; then
|
||||
./configure.sh --mandir=/usr/local/share/man
|
||||
else
|
||||
./configure.sh
|
||||
fi
|
||||
make
|
||||
./configure.sh --prefix="${INSTALL_DIR}" || return 1
|
||||
make || return 1
|
||||
make install || return 1
|
||||
}
|
||||
|
||||
# base directory (absolute)
|
||||
cd "${BASE_DIR}"
|
||||
# zlib
|
||||
function build_zlib {
|
||||
./configure --static --prefix="${INSTALL_DIR}" || return 1
|
||||
make || return 1
|
||||
make install || return 1
|
||||
rm -f "${INSTALL_DIR}/lib/libz*.dylib"
|
||||
}
|
||||
|
||||
# libpng
|
||||
function build_libpng {
|
||||
rm -rf Makefile.in aclocal.m4 automate.cache/ compile config.guess config.h.in config.sub configure depcomp install-sh ltmain.sh missing scripts/libtool.m4 scripts/ltoptions.m4 scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4 test-driver || return 1
|
||||
./autogen.sh || return 1
|
||||
CFLAGS="-I${INSTALL_DIR}/include" CPPFLAGS="-I${INSTALL_DIR}/include" LDFLAGS="-L${INSTALL_DIR}/lib -lz" ./configure --with-zlib-prefix="${INSTALL_DIR}" --prefix="${INSTALL_DIR}" --disable-shared --enable-static || return 1
|
||||
make || return 1
|
||||
make install || return 1
|
||||
}
|
||||
|
||||
# pngquant
|
||||
function build_pngquant {
|
||||
./configure --extra-cflags="-I${INSTALL_DIR}/include" --extra-ldflags="-L${INSTALL_DIR}/lib -lz" --prefix="${INSTALL_DIR}" --with-libpng="${INSTALL_DIR}" --without-cocoa || return 1
|
||||
sed -i.sedbak -e 's:-L/usr/lib -lz::g' config.mk || return 1
|
||||
rm -f config.mk.sedbak
|
||||
make || return 1
|
||||
make install || return 1
|
||||
}
|
||||
|
||||
# zopfli
|
||||
function build_zopfli {
|
||||
make zopfli zopflipng || return 1
|
||||
cp zopfli zopflipng "${INSTALL_DIR}/bin" || return 1
|
||||
}
|
||||
|
||||
# main
|
||||
cd "${TOOLS_DIR}"
|
||||
rm -rf "${INSTALL_DIR}"
|
||||
rm -rf "${BUILD_DIR}"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
cd "${BUILD_DIR}"
|
||||
ERROR=false
|
||||
for TOOL in */; do
|
||||
TOOL="${TOOL%/}" # strip trailing slash
|
||||
echo "Building:"
|
||||
for TOOL in "${TOOLS[@]}"; do
|
||||
echo " ${TOOL}"
|
||||
cp -R "${TOOLS_DIR}/${TOOL}" "${BUILD_DIR}/"
|
||||
rm -rf "${BUILD_DIR}/${TOOL}/.git"
|
||||
cd "${BUILD_DIR}/${TOOL}"
|
||||
if ! build_${TOOL} >/dev/null 2>&1; then
|
||||
ERROR=true
|
||||
echo "Error: Unable to build tool '${TOOL}'." >&2
|
||||
echo "Unable to build tool: ${TOOL}" >&2
|
||||
break
|
||||
fi
|
||||
done
|
||||
rm -rf "${BUILD_DIR}"
|
||||
|
||||
# done
|
||||
if [[ "${ERROR}" == true ]]; then
|
||||
exit 1
|
||||
fi
|
||||
echo "Complete."
|
||||
exit 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user