Skip to content

feat(make): add makefile help and idiomatic cleanup#139

Closed
cds-amal wants to merge 2 commits intomasterfrom
cds/make-it-if-you-try
Closed

feat(make): add makefile help and idiomatic cleanup#139
cds-amal wants to merge 2 commits intomasterfrom
cds/make-it-if-you-try

Conversation

@cds-amal
Copy link
Copy Markdown
Collaborator

@cds-amal cds-amal commented Mar 8, 2026

You can make it if you try

Add a make help target that uses an awk script to parse structured comments in the Makefile itself. ## comments describe individual targets; ### comments act as section headers. The output is grouped into four sections: Build, Test, Code quality, and Graph generation. Internal helper targets (like check-graphviz and rustup-clear-toolchain) are intentionally left without ## comments so they stay hidden from the help output.

Idiomatic fixes applied across the board:

  • .DEFAULT_GOAL := build replaces the old default: build target. The old approach created a real target called default that showed up in tab-completion and could collide with other tooling; .DEFAULT_GOAL is the built-in make mechanism for this.

  • $(MAKE) replaces bare make in the golden target. When make is invoked with flags (e.g., make -j4), a bare make in a recipe starts a fresh make process that loses those flags and, critically, the jobserver file descriptors. $(MAKE) preserves both.

  • .PHONY is now declared immediately above every phony target. A phony target is one that doesn't produce a file of the same name (i.e., make build doesn't create a file called build). Without the declaration, if a file named build or clean happened to exist, make would see it as up-to-date and skip the target entirely. Previously several targets (build, clean, golden, format, style-check) were missing their declarations.

  • Variable references normalized from ${VAR} to $(VAR). Both work identically in GNU make, but $(VAR) is the conventional style. ${VAR} is visually ambiguous with shell variable expansion inside recipes, so reserving curly braces for shell context (like $${rust}) and parens for make context makes it easier to tell which layer is doing the expansion.

  • TOOLCHAIN_NAME='' fixed to TOOLCHAIN_NAME=. Unlike in shell, make does not interpret quotes as delimiters: the old value was literally the two-character string '', not empty. This happened to be harmless (rustup would just fail to find a toolchain named '') but was misleading.

  • Removed the ECHO_CMD=echo variable, which was only used once and added indirection with no benefit. Replaced with a direct @echo.

Add a `make help` target that uses an awk script to parse structured
comments in the Makefile itself. `##` comments describe individual
targets; `###` comments act as section headers. The output is grouped
into four sections: Build, Test, Code quality, and Graph generation.
Internal helper targets (like `check-graphviz` and
`rustup-clear-toolchain`) are intentionally left without `##` comments
so they stay hidden from the help output.

Idiomatic fixes applied across the board:

- `.DEFAULT_GOAL := build` replaces the old `default: build` target.
  The old approach created a real target called `default` that showed
  up in tab-completion and could collide with other tooling;
  `.DEFAULT_GOAL` is the built-in make mechanism for this.

- `$(MAKE)` replaces bare `make` in the `golden` target. When make is
  invoked with flags (e.g., `make -j4`), a bare `make` in a recipe
  starts a fresh make process that loses those flags and, critically,
  the jobserver file descriptors. `$(MAKE)` preserves both.

- `.PHONY` is now declared immediately above every phony target. A
  phony target is one that doesn't produce a file of the same name
  (i.e., `make build` doesn't create a file called `build`). Without
  the declaration, if a file named `build` or `clean` happened to
  exist, make would see it as up-to-date and skip the target entirely.
  Previously several targets (`build`, `clean`, `golden`, `format`,
  `style-check`) were missing their declarations.

- Variable references normalized from `${VAR}` to `$(VAR)`. Both work
  identically in GNU make, but `$(VAR)` is the conventional style.
  `${VAR}` is visually ambiguous with shell variable expansion inside
  recipes, so reserving curly braces for shell context (like `$${rust}`)
  and parens for make context makes it easier to tell which layer is
  doing the expansion.

- `TOOLCHAIN_NAME=''` fixed to `TOOLCHAIN_NAME=`. Unlike in shell,
  make does not interpret quotes as delimiters: the old value was
  literally the two-character string `''`, not empty. This happened to
  be harmless (rustup would just fail to find a toolchain named `''`)
  but was misleading.

- Removed the `ECHO_CMD=echo` variable, which was only used once and
  added indirection with no benefit. Replaced with a direct `@echo`.
@cds-amal cds-amal marked this pull request as ready for review March 8, 2026 06:34
@cds-amal cds-amal requested review from a team and Copilot March 8, 2026 06:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a self-documenting make help target to expose supported developer workflows directly from structured comments in the Makefile, while also tightening Make idioms to avoid common invocation and phony-target pitfalls.

Changes:

  • Added a help target that parses ## (target descriptions) and ### (section headers) from Makefile via awk and prints grouped help output.
  • Replaced default: build with .DEFAULT_GOAL := build and switched recursive make invocation to $(MAKE) for jobserver/flag preservation.
  • Normalized Make variable references and expanded .PHONY declarations across targets; fixed TOOLCHAIN_NAME’s empty default value.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
@cds-amal cds-amal changed the title feat(make): You can make it if you try feat(make): add makefile help and idiomatic cleanup Mar 8, 2026
`\s` is not POSIX awk; BSD awk (macOS default) treats it as a literal
`s`. The patterns worked anyway because the comments are always at
column 0, but this was a latent portability bug. Use bare `^##` / `^###`
anchors instead.

Addresses review feedback on PR #139.
@cds-amal
Copy link
Copy Markdown
Collaborator Author

Replaced by #142

@cds-amal cds-amal closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants