Skip to content

Rebuild all tangled .mk files (and latexmkrc) from .nw as part of the rules #76

Description

@dbosk

Summary

The tangled outputs of this repo (the .mk fragments and latexmkrc) cannot be
rebuilt from their .nw sources via the included rules themselves. Only the
repo's own top-level Makefile knows how to tangle them. As a result:

  1. A downstream project that includes e.g. tex.mk has no automatic way to
    regenerate a stale or missing tex.mk/latexmkrc from tex.mk.nw.
  2. Even inside this repo, make latexmkrc is broken by a target-name collision
    (see below), so it never actually tangles latexmkrc.

Request: add rules so all .mk files (and latexmkrc) are rebuilt from their
.nw sources automatically as part of the rules
, so both this repo and its
downstream consumers self-heal instead of relying on a committed copy.

Motivation (how this surfaced)

In a downstream project that uses this repo as a submodule, latexmkrc was a
gitignored generated artifact (commit 53e54b0). After a git submodule update
the file was gone, the downstream latexmkrc symlink dangled, latexmk ran
without the PythonTeX cus_dep, and the PDFs showed ?? PythonTeX ??.

Worked around downstream by committing the tangled latexmkrc so it ships with
the submodule (makefiles@f88f075) and by depending on the latexmkrc target so
the symlink is recreated. But the root cause is that the build can't regenerate
its own tangled outputs.

Bug: latexmkrc target-name collision

Makefile defines the tangle recipe:

latexmkrc: tex.mk.nw
	${NOTANGLE}

but the included tex.mk also defines a latexmkrc: target (the symlink
helper):

latexmkrc:
	[ -e $@ -o "${INCLUDE_MAKEFILES}" = "." ] || \
	${LN} -s ${INCLUDE_MAKEFILES}/latexmkrc $@

Since tex.mk is included after the explicit rule, its recipe wins. Running
make latexmkrc (or make all, via OTHERS+= latexmkrc) emits:

tex.mk:91: warning: overriding recipe for target 'latexmkrc'
Makefile:35: warning: ignoring old recipe for target 'latexmkrc'

and runs only the symlink helper — which is a no-op here (INCLUDE_MAKEFILES=.
makes the guard short-circuit). The tangled latexmkrc is therefore never
produced by make; it only exists because it is now committed.

Suggested direction (non-prescriptive)

  • Resolve the latexmkrc name collision so the tangle rule applies when
    building inside this repo and the symlink helper applies downstream (rename
    one target, or guard the recipes on INCLUDE_MAKEFILES).

  • Provide a generic tangle pattern rule for fragments, e.g. %.mk: %.mk.nw
    (and an equivalent for latexmkrc) in noweb.mk/tex.mk, so any included
    .mk self-rebuilds from its .nw whenever the .nw source is present. The
    generic NOTANGLE recipe already exists in noweb.mk:

    NOTANGLE?= notangle ${NOTANGLEFLAGS} -R"[[$(notdir $@)]]" $(filter %.nw,$^) | \
                 ${CPIF} $@ && noroots $(filter %.nw,$^)

Repro

git clone git@github.com:dbosk/makefiles.git && cd makefiles
make latexmkrc   # prints the "overriding recipe" warnings; no tangled latexmkrc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions