1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00
flashrom/doc/sphinx-wrapper.sh
Anton Samsonov 8b074c8b7c Makefile,meson.build: Add support for Sphinx versions prior to 4.x
As of version 3.x, `sphinx-build` outputs man pages to "8" directory
instead of "man8" expected by Makefile and doc/meson.build. See:
    https://github.com/sphinx-doc/sphinx/issues/7996
    https://github.com/sphinx-doc/sphinx/issues/9217

Current solution is to rename "8" to "man8" after documentation build.
That enables successful build and installation, as well as dependency
tracking at build-system level, but not on `sphinx-build` own level
upon which `meson` build blindly relies.

Change-Id: I9cd280551a1ba4d17edb2e857d56f80431b61e1b
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/77778
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-02-21 11:07:24 +00:00

30 lines
937 B
Bash
Executable File

#!/bin/sh
OUTPUT_HOME="$1"
MAN_OUTPUTS="$2"
SPHINXBUILD="$3"
shift 3
"${SPHINXBUILD}" "$@" || exit $?
SPHINXBUILD_MAJOR="$("${SPHINXBUILD}" --version | cut -d' ' -f2 | cut -d'.' -f1)"
if [ "${SPHINXBUILD_MAJOR}" -ge 4 ]; then
exit 0
fi
# sphinx-build 3.x outputs man pages to "8" directory instead of expected "man8".
# The following block checks for "man8" (and other output paths in ${MAN_OUTPUTS})
# and, if that is missing, but "8" dir exists instead, it renames "8" to "man8"
# and creates a symlink named "8" that points to "man8", so that anyone is happy
# during the rest of current build and subsequent builds as well.
for MAN_OUTPUT in ${MAN_OUTPUTS}; do
PATH_TARGET="${OUTPUT_HOME}/${MAN_OUTPUT}"
PATH_ACTUAL="${OUTPUT_HOME}/${MAN_OUTPUT#man}"
if [ -d "${PATH_ACTUAL}" -a ! -L "${PATH_ACTUAL}" ]; then
rm -rf "${PATH_TARGET}"
mv "${PATH_ACTUAL}" "${PATH_TARGET}"
ln -s "${MAN_OUTPUT}" "${PATH_ACTUAL}"
fi
done