2023-03-16 13:35:55 +00:00
|
|
|
#!/bin/sh
|
2024-02-12 15:09:10 +00:00
|
|
|
# SPDX-License-Identifier: 0BSD
|
|
|
|
|
2023-03-16 13:35:55 +00:00
|
|
|
#############################################################################
|
|
|
|
#
|
2024-04-19 12:15:17 +00:00
|
|
|
# While it's possible to use the Doxyfile as is to generate liblzma API
|
|
|
|
# documentation, it is recommended to use this script because this adds
|
|
|
|
# the XZ Utils version number to the generated HTML.
|
2023-03-16 13:35:55 +00:00
|
|
|
#
|
2024-04-19 12:15:17 +00:00
|
|
|
# Other features:
|
|
|
|
# - Generate documentation of the XZ Utils internals.
|
|
|
|
# - Set input and output paths for out-of-tree builds.
|
2023-03-16 13:35:55 +00:00
|
|
|
#
|
|
|
|
#############################################################################
|
|
|
|
#
|
|
|
|
# Authors: Jia Tan
|
|
|
|
# Lasse Collin
|
|
|
|
#
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2024-04-19 12:15:17 +00:00
|
|
|
show_usage()
|
|
|
|
{
|
|
|
|
echo "Usage: $0 <api|internal> [ABS_TOP_SRCDIR ABS_OUTDIR]"
|
|
|
|
echo
|
|
|
|
echo "Supported modes:"
|
|
|
|
echo " - 'api' (default): liblzma API docs into doc/api"
|
|
|
|
echo " - 'internal': internal docs into doc/internal"
|
|
|
|
echo
|
|
|
|
echo "Absolute source and output dirs may be set" \
|
|
|
|
"to do an out-of-tree build."
|
|
|
|
echo "The output directory must already exist."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
api|internal)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
show_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-03-16 13:35:55 +00:00
|
|
|
if type doxygen > /dev/null 2>&1; then
|
|
|
|
:
|
|
|
|
else
|
2024-04-19 12:15:17 +00:00
|
|
|
echo "$0: 'doxygen' command not found" >&2
|
2023-03-16 13:35:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-19 12:15:17 +00:00
|
|
|
case $# in
|
|
|
|
1)
|
|
|
|
# One argument: Building inside the source tree
|
|
|
|
ABS_TOP_SRCDIR=`dirname "$0"`/..
|
|
|
|
ABS_OUTDIR=$ABS_TOP_SRCDIR/doc
|
|
|
|
;;
|
|
|
|
3)
|
|
|
|
# Three arguments: Possibly an out of tree build
|
|
|
|
ABS_TOP_SRCDIR=$2
|
|
|
|
ABS_OUTDIR=$3
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
show_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if test ! -f "$ABS_TOP_SRCDIR/doxygen/Doxyfile"; then
|
|
|
|
echo "$0: Source dir '$ABS_TOP_SRCDIR/doxygen/Doxyfile' not found" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if test ! -d "$ABS_OUTDIR"; then
|
|
|
|
echo "$0: Output dir '$ABS_OUTDIR' not found" >&2
|
|
|
|
exit 1
|
2023-03-16 13:35:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Get the package version so that it can be included in the generated docs.
|
2024-04-19 12:15:17 +00:00
|
|
|
PACKAGE_VERSION=`cd "$ABS_TOP_SRCDIR" && sh build-aux/version.sh`
|
2023-03-16 13:35:55 +00:00
|
|
|
|
|
|
|
case $1 in
|
2024-04-19 12:15:17 +00:00
|
|
|
api)
|
2023-03-16 13:35:55 +00:00
|
|
|
# Remove old documentation before re-generating the new.
|
2024-04-19 12:15:17 +00:00
|
|
|
rm -rf "$ABS_OUTDIR/api"
|
2023-03-16 13:35:55 +00:00
|
|
|
|
|
|
|
# Generate the HTML documentation by preparing the Doxyfile
|
|
|
|
# in stdin and piping the result to the doxygen command.
|
|
|
|
# With Doxygen, the last assignment of a value to a tag will
|
|
|
|
# override any earlier assignment. So, we can use this
|
|
|
|
# feature to override the tags that need to change between
|
2023-03-16 17:30:36 +00:00
|
|
|
# "api" and "internal" modes.
|
2024-04-19 12:15:17 +00:00
|
|
|
ABS_SRCDIR=$ABS_TOP_SRCDIR/src/liblzma/api
|
2023-03-16 13:35:55 +00:00
|
|
|
(
|
2024-04-19 12:15:17 +00:00
|
|
|
cat "$ABS_TOP_SRCDIR/doxygen/Doxyfile"
|
2023-03-16 13:35:55 +00:00
|
|
|
echo "PROJECT_NUMBER = $PACKAGE_VERSION"
|
2024-04-19 12:15:17 +00:00
|
|
|
echo "OUTPUT_DIRECTORY = $ABS_OUTDIR"
|
|
|
|
echo "STRIP_FROM_PATH = $ABS_SRCDIR"
|
|
|
|
echo "INPUT = $ABS_SRCDIR"
|
|
|
|
) | doxygen -q -
|
2023-03-16 13:35:55 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
internal)
|
2024-04-19 12:15:17 +00:00
|
|
|
rm -rf "$ABS_OUTDIR/internal"
|
2023-03-16 13:35:55 +00:00
|
|
|
(
|
2024-04-19 12:15:17 +00:00
|
|
|
cat "$ABS_TOP_SRCDIR/doxygen/Doxyfile"
|
2023-03-16 13:35:55 +00:00
|
|
|
echo 'PROJECT_NAME = "XZ Utils"'
|
2024-04-19 12:15:17 +00:00
|
|
|
echo "PROJECT_NUMBER = $PACKAGE_VERSION"
|
|
|
|
echo "OUTPUT_DIRECTORY = $ABS_OUTDIR"
|
|
|
|
echo "STRIP_FROM_PATH = $ABS_TOP_SRCDIR"
|
|
|
|
echo "INPUT = $ABS_TOP_SRCDIR/src"
|
2023-03-16 13:35:55 +00:00
|
|
|
echo 'HTML_OUTPUT = internal'
|
|
|
|
echo 'SEARCHENGINE = YES'
|
2024-04-19 12:15:17 +00:00
|
|
|
) | doxygen -q -
|
2023-03-16 13:35:55 +00:00
|
|
|
;;
|
|
|
|
esac
|