mirror of
https://github.com/HandBrake/HandBrake-docs.git
synced 2025-12-11 13:54:49 -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
|
# Prevent overwriting user config
|
||||||
config.yaml
|
config.yaml
|
||||||
|
|
||||||
|
# Ignore tools directories
|
||||||
|
tools/local
|
||||||
|
|
||||||
# Ignore generated documents but keep the docs directory
|
# Ignore generated documents but keep the docs directory
|
||||||
docs/*
|
docs/*
|
||||||
!docs/.gitkeep
|
!docs/.gitkeep
|
||||||
|
|||||||
20
build-docs
20
build-docs
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
# vars
|
# vars
|
||||||
SELF="${BASH_SOURCE[0]}"
|
SELF="${BASH_SOURCE[0]}"
|
||||||
BASE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
SELF_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
||||||
BASE_DIR="${BASE_DIR:-$(pwd)}"
|
SELF_DIR="${SELF_DIR:-$(pwd)}"
|
||||||
CONFIG="${BASE_DIR}/config.yaml"
|
CONFIG="${SELF_DIR}/config.yaml"
|
||||||
DOCS_DIR="${BASE_DIR}/docs"
|
DOCS_DIR="${SELF_DIR}/docs"
|
||||||
SOURCE_DIR="${BASE_DIR}/source"
|
SOURCE_DIR="${SELF_DIR}/source"
|
||||||
TEMPLATE_DIR="${BASE_DIR}/templates"
|
TEMPLATE_DIR="${SELF_DIR}/templates"
|
||||||
TOOLS_DIR="${BASE_DIR}/tools"
|
TOOLS_BIN="${SELF_DIR}/tools/local/bin"
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
MARKDOWN="${BASE_DIR}/tools/discount/markdown"
|
MARKDOWN="${TOOLS_BIN}/markdown"
|
||||||
DEPS=("${MARKDOWN}")
|
DEPS=("${MARKDOWN}")
|
||||||
|
|
||||||
# optional dependencies
|
# optional dependencies
|
||||||
@ -213,7 +213,7 @@ function build_source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# base directory (absolute)
|
# base directory (absolute)
|
||||||
cd "${BASE_DIR}"
|
cd "${SELF_DIR}"
|
||||||
|
|
||||||
# check deps
|
# check deps
|
||||||
check_dependencies "${DEPS[@]}" || exit 1
|
check_dependencies "${DEPS[@]}" || exit 1
|
||||||
@ -293,7 +293,7 @@ else
|
|||||||
done
|
done
|
||||||
cd "${SOURCE_DIR}"
|
cd "${SOURCE_DIR}"
|
||||||
done
|
done
|
||||||
cd "${BASE_DIR}"
|
cd "${SELF_DIR}"
|
||||||
|
|
||||||
# sources
|
# sources
|
||||||
SOURCES=($(find "${DOCS_DIR}" | sed 's/^\.\///' | grep -i '.markdown'))
|
SOURCES=($(find "${DOCS_DIR}" | sed 's/^\.\///' | grep -i '.markdown'))
|
||||||
|
|||||||
74
build-tools
74
build-tools
@ -2,41 +2,75 @@
|
|||||||
|
|
||||||
# vars
|
# vars
|
||||||
SELF="${BASH_SOURCE[0]}"
|
SELF="${BASH_SOURCE[0]}"
|
||||||
BASE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
SELF_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
|
||||||
BASE_DIR="${BASE_DIR:-$(pwd)}"
|
SELF_DIR="${SELF_DIR:-$(pwd)}"
|
||||||
TOOLS_DIR="${BASE_DIR}/tools"
|
TOOLS_DIR="${SELF_DIR}/tools"
|
||||||
SYSTEM_NAME=$(uname -s)
|
BUILD_DIR="${TOOLS_DIR}/local/build"
|
||||||
|
INSTALL_DIR="${TOOLS_DIR}/local"
|
||||||
|
TOOLS=('discount' 'zlib' 'libpng' 'pngquant' 'zopfli')
|
||||||
|
|
||||||
# discount
|
# discount
|
||||||
function build_discount {
|
function build_discount {
|
||||||
cd "${TOOLS_DIR}/discount"
|
./configure.sh --prefix="${INSTALL_DIR}" || return 1
|
||||||
if make clean; then
|
make || return 1
|
||||||
make distclean
|
make install || return 1
|
||||||
fi
|
|
||||||
if [[ "${SYSTEM_NAME}" == "Darwin" ]]; then
|
|
||||||
./configure.sh --mandir=/usr/local/share/man
|
|
||||||
else
|
|
||||||
./configure.sh
|
|
||||||
fi
|
|
||||||
make
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# base directory (absolute)
|
# zlib
|
||||||
cd "${BASE_DIR}"
|
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
|
# main
|
||||||
cd "${TOOLS_DIR}"
|
rm -rf "${INSTALL_DIR}"
|
||||||
|
rm -rf "${BUILD_DIR}"
|
||||||
|
mkdir -p "${BUILD_DIR}"
|
||||||
|
cd "${BUILD_DIR}"
|
||||||
ERROR=false
|
ERROR=false
|
||||||
for TOOL in */; do
|
echo "Building:"
|
||||||
TOOL="${TOOL%/}" # strip trailing slash
|
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
|
if ! build_${TOOL} >/dev/null 2>&1; then
|
||||||
ERROR=true
|
ERROR=true
|
||||||
echo "Error: Unable to build tool '${TOOL}'." >&2
|
echo "Unable to build tool: ${TOOL}" >&2
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
rm -rf "${BUILD_DIR}"
|
||||||
|
|
||||||
# done
|
# done
|
||||||
if [[ "${ERROR}" == true ]]; then
|
if [[ "${ERROR}" == true ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "Complete."
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user