Skip to content
Snippets Groups Projects
  • Peter Maydell's avatar
    e0f3728d
    Makefile: Ensure we don't run Sphinx in parallel for manpages · e0f3728d
    Peter Maydell authored
    Sphinx will corrupt its doctree cache if we run two copies
    of it in parallel. In commit 6bda415c we worked
    around this by having separate doctrees for 'html' vs 'manpage'
    runs. However now that we have more than one manpage produced
    from a single manual we can run into this again when trying
    to produce the two manpages.
    
    Use the trick described in 'Atomic Rules in GNU Make'
    https://www.cmcrossroads.com/article/atomic-rules-gnu-make
    
    
    to ensure that we only run the Sphinx manpage builder once
    for each manual, even if we're producing several manpages.
    This fixes doctree corruption in parallel builds and also
    avoids pointlessly running Sphinx more often than we need to.
    
    (In GNU Make 4.3 there is builtin support for this, via
    the "&:" syntax, but we can't wait for that to be available
    in all the distros we support...)
    
    The generic "one invocation for multiple output files"
    machinery is provided as a macro named 'atomic' in rules.mak;
    we then wrap this in a more specific macro for defining
    the rule and dependencies for the manpages in a Sphinx
    manual, to avoid excessive repetition.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Tested-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Message-id: 20200124162606.8787-2-peter.maydell@linaro.org
    e0f3728d
    History
    Makefile: Ensure we don't run Sphinx in parallel for manpages
    Peter Maydell authored
    Sphinx will corrupt its doctree cache if we run two copies
    of it in parallel. In commit 6bda415c we worked
    around this by having separate doctrees for 'html' vs 'manpage'
    runs. However now that we have more than one manpage produced
    from a single manual we can run into this again when trying
    to produce the two manpages.
    
    Use the trick described in 'Atomic Rules in GNU Make'
    https://www.cmcrossroads.com/article/atomic-rules-gnu-make
    
    
    to ensure that we only run the Sphinx manpage builder once
    for each manual, even if we're producing several manpages.
    This fixes doctree corruption in parallel builds and also
    avoids pointlessly running Sphinx more often than we need to.
    
    (In GNU Make 4.3 there is builtin support for this, via
    the "&:" syntax, but we can't wait for that to be available
    in all the distros we support...)
    
    The generic "one invocation for multiple output files"
    machinery is provided as a macro named 'atomic' in rules.mak;
    we then wrap this in a more specific macro for defining
    the rule and dependencies for the manpages in a Sphinx
    manual, to avoid excessive repetition.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Tested-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Message-id: 20200124162606.8787-2-peter.maydell@linaro.org