Skip to content

Commit

Permalink
docs/Makefile.am, docs/man/Makefile.am: .prep-src-docs: play nice wit…
Browse files Browse the repository at this point in the history
…h different MKDIR_P as we "cd" around [#722]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jan 3, 2025
1 parent 5c42be8 commit 4fef10c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 9 additions & 2 deletions docs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,15 @@ A2X_COMMON_OPTS = $(ASCIIDOC_VERBOSE) \

# Note we only remove the original target (if present), if it is a directory -
# e.g. created by "html-chunked" targets.

# NOTE: MKDIR_P may be defined via expanded $(top_builddir)/install-sh
# so should be run from $(abs_builddir) to be safe, as we jump around
# the build workspace
DOCBUILD_BEGIN = { \
if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \
rm -rf "./$${A2X_OUTDIR}" || true ; \
test -d "$@" && rm -rf "$@" || true ; \
$(MKDIR_P) "./$${A2X_OUTDIR}" || exit ; \
_CWD="`pwd`" && (cd '$(abs_builddir)' && $(MKDIR_P) "$${_CWD}/$${A2X_OUTDIR}") || exit ; \
case "$${A2X_OUTDIR}" in \
tmp/pdf.*) ln -s ../../images "./$${A2X_OUTDIR}" ;; \
esac; \
Expand Down Expand Up @@ -862,6 +866,9 @@ PREP_SRC = $(EXTRA_DIST) $(SPELLCHECK_SRC_DEFAULT)
# source texts located in/under parent dirs.
# We also handle man page links (section-aware) for platforms where they
# differ from common defaults.
# NOTE: MKDIR_P may be defined via expanded $(top_builddir)/install-sh
# so should be run from $(abs_builddir) to be safe, as we jump around
# the build workspace
$(abs_top_builddir)/docs/.prep-src-docs: $(PREP_SRC)
@cd "$(@D)" || exit ; \
linkroot="$(abs_builddir)" ; \
Expand Down Expand Up @@ -919,7 +926,7 @@ $(abs_top_builddir)/docs/.prep-src-docs: $(PREP_SRC)
cd "$(abs_top_builddir)" ;; \
esac ; \
D="`dirname "$$F"`" ; \
$(MKDIR_P) "$${linkroot}/$$D" || { rm -f "$@.working" ; exit 1 ; } ; \
(cd '$(abs_builddir)' && $(MKDIR_P) "$${linkroot}/$$D") || { rm -f "$@.working" ; exit 1 ; } ; \
if ! test -s "$${linkroot}/$$F" && test -s "$${linksrcroot}/$$F" ; then \
echo " LN '$${linksrcroot}/$$F' => '$${linkroot}/$$F' (PWD = '`pwd`')" ; \
ln -fs "$${linksrcroot}/$$F" "$${linkroot}/$$F" || { rm -f "$@.working" ; exit 1 ; } ; \
Expand Down
10 changes: 8 additions & 2 deletions docs/man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,14 @@ CLEANFILES += *.$(MAN_SECTION_CMD_USR) *.$(MAN_SECTION_API) *.$(MAN_SECTION_CFG)

# Working around a2x not friendly to parallelized runs.
# See more details in the main NUT docs/Makefile.am
# NOTE: MKDIR_P may be defined via expanded $(top_builddir)/install-sh
# so should be run from $(abs_builddir) to be safe, as we jump around
# the build workspace
DOCBUILD_BEGIN = { \
if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \
rm -rf "./$${A2X_OUTDIR}" || true ; \
test -d "$@" && rm -rf "$@" || true ; \
$(MKDIR_P) "./$${A2X_OUTDIR}" || exit ; \
_CWD="`pwd`" && (cd '$(abs_builddir)' && $(MKDIR_P) "$${_CWD}/$${A2X_OUTDIR}") || exit ; \
for F in $(LINKMAN_INCLUDE_GENERATED) ; do \
if [ -s "./$$F" ] ; then ln -f -s "../../$$F" "./$${A2X_OUTDIR}/" ; else \
if [ -s "$(abs_srcdir)/$$F" ] ; then ln -f -s "$(abs_srcdir)/$$F" "./$${A2X_OUTDIR}/" ; fi ; fi ; \
Expand Down Expand Up @@ -1260,6 +1263,9 @@ PREP_SRC = $(LINKMAN_INCLUDE_GENERATED) $(SRC_ALL_PAGES) asciidoc.conf
# with the title, followed by another with a sequence of "===" characters
# of same length, give or take one (or so). Currently we do not bother to
# adjust the second line, as we expect minor length changes like "8"=>"1m".
# NOTE: MKDIR_P may be defined via expanded $(top_builddir)/install-sh
# so should be run from $(abs_builddir) to be safe, as we jump around
# the build workspace
$(abs_top_builddir)/docs/man/.prep-src-docs: $(PREP_SRC)
@cd "$(@D)" || exit ; \
linkroot="$(abs_builddir)" ; \
Expand Down Expand Up @@ -1320,7 +1326,7 @@ $(abs_top_builddir)/docs/man/.prep-src-docs: $(PREP_SRC)
cd "$(abs_top_builddir)" ;; \
esac ; \
D="`dirname "$$F"`" ; \
$(MKDIR_P) "$${linkroot}/$$D" || { rm -f "$@.working" ; exit 1 ; } ; \
(cd '$(abs_builddir)' && $(MKDIR_P) "$${linkroot}/$$D") || { rm -f "$@.working" ; exit 1 ; } ; \
if ! test -e "$${linkroot}/$$F" && test -s "$${linksrcroot}/$$F" ; then \
echo " LN '$${linksrcroot}/$$F' => '$${linkroot}/$$F' (PWD = '`pwd`')" >&2 ; \
ln -fs "$${linksrcroot}/$$F" "$${linkroot}/$$F" || { rm -f "$@.working" ; exit 1 ; } ; \
Expand Down

0 comments on commit 4fef10c

Please sign in to comment.