Skip to content

Makefile: context-aware make help (root + per-package)#7250

Merged
th0ma7 merged 14 commits into
SynoCommunity:masterfrom
th0ma7:mk-make-help
Jul 2, 2026
Merged

Makefile: context-aware make help (root + per-package)#7250
th0ma7 merged 14 commits into
SynoCommunity:masterfrom
th0ma7:mk-make-help

Conversation

@th0ma7

@th0ma7 th0ma7 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What

Make make help a first-class, context-aware entry point across spksrc.

At the repository root

make help lists the orchestration targets grouped by section (General, Build, Clean, Prepare, Digests, Lint, Toolchain & kernel, Setup), plus the per-package pattern targets (<spk>, spk-<spk>-<arch>-<tcversion>, native-<name>, toolchain-<arch>, kernel-<arch>). make help-<topic> filters by section or name, e.g. make help-clean, make help-toolchain.

Inside a package directory

make help prints the targets relevant to that context, for every tree: cross/, spk/, diyspk/, native/, toolchain/, toolkit/, kernel/ and python/:

  • Build: all, arch-<arch>-<tcvers> (cross/spk/kernel/diyspk), the <step> lifecycle (download → checksum → extract → patch → configure → compile → install [→ plist]), a reminder that all and every <step> except download need ARCH+TCVERSION, tc_vars/tk_vars (toolchain/toolkit) and the rustup <args> passthrough (e.g. make rustup show).
  • Multi-arch (cross/spk/diyspk): all-supported, all-latest, plus publish-all-supported / publish-all-latest for spk/diyspk (after make setup-synocommunity + PUBLISH_API_KEY).
  • Python wheels (spk/diyspk with PYTHON_PACKAGE or named python3*): wheel-<arch>-<tcvers>, crossenv-<arch>-<tcvers>, download-wheels, and the clean set wheelclean / wheelcleancache / wheelcleanall / crossenvclean / crossenvcleanall, with the WHEELS="pkg==ver ..." semantics in the header.
  • Inspect: dependency-tree / dependency-flat / dependency-list.
  • Cleanup / Maintenance: clean, smart-clean, download, digests (with a note that digests auto-runs download and how to force a refresh).
  • python/ tree: states the module is built as an spk dependency only, plus Inspect.

How

  • Root help (root Makefile) is generated from ##@ Section headers and trailing ## description comments — self-documenting, so it never drifts, and only documented targets appear (internal pre_*/post_*/*_msg hooks carry no ## and are hidden by construction). help-<topic> uses a help-% pattern rule so the topic is never mistaken for a build goal.
  • Package help is a new mk/spksrc.common/help.mk, included by spksrc.common.mk after default: all so the help target can never become the default goal. It only activates when the parent directory is one of the known trees and CURDIR != BASEDIR (so a checkout living under a parent named e.g. spk/ cannot shadow the root help). An include guard prevents "overriding recipe" warnings when common.mk is included more than once.
  • HELP_PYTHON is a deferred (=) variable checked at recipe time, so the wheels section shows even when PYTHON_PACKAGE is set after include spksrc.common.mk (e.g. spk/borgbackup).

Fixes folded in

  • root downloads target looped over dl but invoked make -C $${tc} (empty variable) — broken loop, now fixed since help advertises it.
  • docs aligned with the actual target inventory: build-rules.md (complete cross/spk tables, arch-<arch>-<tcvers> naming, python-wheel vs python-module include fix), build-workflow.md (make help note covering all trees), python.md (accurate wheel-clean target descriptions).

Notes

  • make with no target still builds all, at the root and in packages (verified: the help include is parsed after default: all).
  • Verified in root, cross, spk, diyspk, native, toolchain, toolkit and python contexts.

Example (inside spk/borgbackup)

borgbackup  (spk package)

Build
  all                      build this package (default target)
  arch-<arch>-<tcvers>     build for one arch/version (e.g. arch-x64-7.1)
  <step>                   run one build step, in order:
                             download checksum extract patch configure compile install plist
    all and every <step> except download need ARCH=<arch> TCVERSION=<tcvers>
  rustup <args>            run rustup for the rust toolchain (e.g. make rustup show)

Multi-arch  (needs 'make setup' once at the spksrc root first)
  all-supported            build for every supported arch
  all-latest               build for the latest toolchains only
  publish-all-supported    build and publish every supported arch (after 'make setup-synocommunity' + PUBLISH_API_KEY)
  publish-all-latest       build and publish the latest toolchains only

Python wheels  (WHEELS="pkg1==ver pkg2==ver ..." restricts the (re)build to those wheels; unset rebuilds all)
  wheel-<arch>-<tcvers>    build the package's wheels for one arch
  crossenv-<arch>-<tcvers> build the cross-compilation Python venv
  download-wheels          download the wheel sources only
  wheelclean               remove wheel build state (run before rebuilding)
  wheelcleancache          remove the local pip cache only (work-*/pip)
  wheelcleanall            wheelclean + caches, incl. the shared distrib/pip
  crossenvclean            remove the crossenv and wheel state
  crossenvcleanall         remove the crossenv, wheels and all caches

Inspect
  dependency-tree          print the resolved dependency graph
  dependency-flat          flat, de-duplicated dependency list
  dependency-list          raw per-package dependency list

Cleanup
  clean                    remove all work directories
  smart-clean              remove this package's source and cookies (needs ARCH+TCVERSION)

Maintenance
  download                 fetch the source archive(s)
  digests                  regenerate the digests file (auto-runs download)
    to refresh digests: make clean, delete the file in distrib/, then make digests

🤖 Generated with Claude Code

@th0ma7 th0ma7 changed the title Makefile: add a self-documenting make help (+ help-<topic>) Makefile: context-aware make help (root + per-package) Jul 1, 2026
@th0ma7 th0ma7 self-assigned this Jul 1, 2026
@th0ma7 th0ma7 mentioned this pull request Jul 1, 2026
27 tasks
@th0ma7
th0ma7 marked this pull request as ready for review July 1, 2026 23:43
@th0ma7
th0ma7 requested review from hgy59 and mreid-tt July 1, 2026 23:43
@th0ma7

th0ma7 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@hgy59 and @mreid-tt if you have a few cycles to spare and tryout using make help in various areas of the framework and let me know what you think or if there is something missing?

Yet to validate are all the spksrc's root directory recipe that I almost never use... but otherwise running make help from under cross|native|spk|diyspk/abc should provide meaningful info. It also detects python based spk and provide additional info.

Feedback welcomed

@th0ma7
th0ma7 force-pushed the mk-make-help branch 2 times, most recently from 5c90921 to fce7101 Compare July 2, 2026 10:48
th0ma7 and others added 10 commits July 2, 2026 10:50
Running `make` at the spksrc root, or tab-completing, only lists bare target
names with no explanation. Add a `help` target that prints the documented
targets grouped by section, plus `make help-<topic>` to filter by section or
name (e.g. `make help-clean`, `make help-toolchain`).

The listing is generated from `##@ Section` headers and trailing `## description`
comments on the targets themselves, so it never drifts out of sync — and only
documented targets appear, which naturally hides internal hook targets
(pre_*, post_*, *_msg). A "Per-package (pattern) targets" note explains the
`<spk>` / `spk-<spk>-<arch>` / `native-<name>` / `toolchain-<arch>` forms that
can't be listed literally.

`make` with no target still builds `all` as before; no target behaviour changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extend the help feature to package directories: `make help` run from a
cross/, spk/, native/, toolchain/ or kernel/ package now prints the targets
relevant to that context, via a new spksrc.common/help.mk included by
spksrc.common.mk.

- cross/ and spk/: build lifecycle (download -> ... -> install [-> plist]),
  the multi-arch targets (arch-<arch>, all-supported, all-latest, supported,
  latest) with a reminder that they need `make setup` at the root first, and
  maintenance (clean, smart-clean, digests).
- native/: same lifecycle minus plist, no arch matrix (single host build).
- toolchain/ and kernel/: minimal all + maintenance (their pipeline differs).

The target is only defined when the parent directory is one of those trees, so
it never collides with the orchestration help in the root Makefile (which pulls
in spksrc.common.mk transitively via tests.mk). An include guard avoids
"overriding recipe" warnings when common.mk is included more than once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a "Discovering targets (make help)" subsection to the build-workflow guide
explaining the context-aware root vs per-package help and `make help-<topic>`,
and list the new spksrc.common/help.mk in the makefile-system reference.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Root Makefile now includes spksrc.common.mk explicitly instead of relying on
  tests.mk to pull it in transitively (tests.mk is still evolving).
- Package help: correct the multi-arch target to arch-<arch>-<tcvers>
  (e.g. arch-x64-7.1); add an Inspect section with dependency-tree (all
  contexts) and a Python wheels section (spk only: wheel, download-wheels,
  crossenv, crossenv-install-<w>). Widen the columns to fit the longer names.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
help.mk was included before 'default: all' in common.mk, so the help target
became the first target and thus the default goal - running 'make', 'make all'
without a goal, or a recursive arch build printed the help instead of building.
Move the help.mk include after 'default: all' so the build stays the default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Only list targets that actually exist: drop the bare `supported`/`latest`
  (only `all-supported`/`all-latest` exist); add `dependency-flat` and
  `dependency-list` next to `dependency-tree`.
- Note that `all` and every `<step>` except download/digests need
  ARCH=<arch> TCVERSION=<tcvers> (and smart-clean too), for cross/spk/kernel/diyspk.
- Cover the missing contexts: toolkit (was absent), diyspk (like spk), and
  python (built only as an spk dependency - no direct build); toolchain/toolkit
  show `download` + `tc_vars`/`tk_vars` instead of the full pipeline.
- Root Makefile: widen columns so `setup-synocommunity` aligns, and fix the
  pattern target to `spk-<spk>-<arch>-<tcversion>`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…intenance

- diyspk now shows the Multi-arch section (all-supported/all-latest) like spk;
  everything applicable to spk applies to diyspk.
- Python wheels section only for spk/diyspk packages that set PYTHON_PACKAGE or
  are python3*, and lists the real targets: wheel-<arch>-<tcvers>,
  crossenv-<arch>-<tcvers>, download-wheels, wheelclean, crossenvclean, with a
  note about WHEELS="pkg==ver" on-demand (bare wheel/crossenv are not entry
  points).
- Add `download` explicitly under Maintenance everywhere (moved out of the
  toolchain/toolkit Build block).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
HELP_PYTHON used := (immediate), so it was evaluated when help.mk was
parsed via 'include spksrc.common.mk' - before packages that set
PYTHON_PACKAGE *after* that include (e.g. spk/borgbackup). The wheels
section was then gated out at parse time and never shown.

Make HELP_PYTHON deferred (=) and move the gate into a recipe-time shell
conditional so PYTHON_PACKAGE is seen regardless of include order. Also
add the missing wheelcleancache and crossenvcleanall targets, and reword
the WHEELS header to explain that WHEELS="pkg1==ver pkg2==ver ..."
restricts the (re)build while leaving it unset rebuilds all wheels or
the default crossenv.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move clean/smart-clean into their own Cleanup section; keep download and
digests under Maintenance. Note that digests auto-runs download, and that
refreshing digests needs 'make clean' plus deleting the distrib/ file to
force a re-download.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The rustup passthrough (make rustup <args>, e.g. make rustup show) inspects
and manages the shared rust toolchain and resolves in every buildable
context (cross, spk, diyspk, native, toolchain, toolkit, kernel) via
spksrc.rules.mk. Add it to the context-aware Build help (the python context
has no direct build, so it is naturally excluded).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
th0ma7 and others added 4 commits July 2, 2026 21:30
- build-rules.md: complete the cross/spk target tables to match the
  context-aware make help (arch-<arch>-<tcvers>, all-supported/all-latest,
  dependency-tree/flat/list, smart-clean, digests, rustup, and the Python
  wheel/crossenv targets); fix arch-<arch>-<version> -> arch-<arch>-<tcvers>.
- build-rules.md: fix the mislabelled include - Python wheels use
  spksrc.python-wheel.mk (or -meson), not spksrc.python-module.mk (which
  builds a cross-compiled extension); drop the unresolvable 'publish' target.
- build-workflow.md: broaden the make help note to all package types and
  fix arch-<arch> -> arch-<arch>-<tcvers>.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The publish-all-<supported|latest> targets (build + publish every supported
or latest arch, from spksrc.spk/publish.mk) are available in spk and diyspk
packages but were missing from make help; document them in the Multi-arch
section and in build-rules.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
publish-all-<supported|latest> require 'make setup'/'make setup-synocommunity'
at the spksrc root first (like the all-* targets), plus PUBLISH_API_KEY. Make
that explicit in make help and build-rules.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review pass over the make-help work:

- help.mk: fix the wheelcleancache description (it only removes the local
  work-*/pip cache; it does not include wheelclean nor touch the shared
  cache) and add the missing wheelcleanall target (wheelclean +
  wheelcleancache + shared distrib/pip cache), matching spksrc.spk.mk.
- help.mk: never activate the package help at the repo root, even when the
  checkout lives under a parent directory named like a package tree
  (e.g. /home/user/spk/spksrc) which would override the root help.
- Makefile: fix the 'downloads' target iterating over dl but invoking
  make -C $${tc} (empty variable) - broken loop now advertised by help.
- docs python.md: wheelcleancache is not a superset of wheelclean; drop the
  'increasing scope' wording and describe each clean target accurately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@th0ma7
th0ma7 merged commit 5fd4e98 into SynoCommunity:master Jul 2, 2026
3 checks passed
@th0ma7
th0ma7 deleted the mk-make-help branch July 2, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant