git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Makefile: add help target

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 8, 2022, 15:44 UTC
Message-ID
<220408.86a6cvbme0.gmgdl@evledraar.gmail.com>
In-Reply-To
<YlBVBlwNVc8mEjn5@nand.local>
On Fri, Apr 08 2022, Taylor Blau wrote:
Show 16 quoted lines
> On Fri, Apr 08, 2022 at 07:45:24AM +0000, Elia Pinto wrote:
>> Add a help target to the Makefile to be able to run make help, in the same way
>> does the Makefiles self-generated by some build systems.
>>
>> The target list has been statically extracted from the git Makefile with a
>> script and the results have been filtered in an essentially arbitrary way to
>> leave the ones that i imagines most interesting and frequent for a developer.
>
> I could definitely see something like "make help" being helpful, since
> make itself doesn't have a convenient way to list all of a Makefile's
> targets.
>
> I worry about this list getting stale, though. If we add a new target,
> will we remember to update the "help" list here? It would be nice if we
> could dynamically generate this list, but I think that loses out on the
> filtering you've done here.

There's some nice suggestions at: https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile

I managed to get pretty close to this by massaging the various parsers that were suggested there.

But I wonder if defining help as we go along wouldn't be the best and least likely to break, and most likely to be kept up-to-date. I.e. some variant of the comments added there.

Or better (maybe it's discussed in that SO thing, I didn't skim it all), something like:

    HELP_all = the default target
    all::
    [...]

We could then even print a heading showing what target(s) we're running by looking at MAKECMDGOALS.

Also, Elia's ad-hoc script here copied from StackOverflow looks awfully similar to what I have in /usr/share/bash-completion/completions/make installed with my OS. Available here: https://github.com/scop/bash-completion/blob/master/completions/make

So maybe we could just make this an optional target that depended on that widely-available bash completion?

That would also have the nice benefit that to the extent that the output sucked we could maybe massage our Makefile a bit to make it better, and then we'd not only benefit "make help" users, but anyone doing "make <TAB>".

Previous: Taylor BlauNext: Junio C Hamano
Message 4 of 5 in “Makefile: add help target”
  1. Makefile: add help targetElia Pinto, Apr 8, 2022
  2. Philip OakleyApr 8, 2022
  3. Taylor BlauApr 8, 2022
  4. Ævar Arnfjörð BjarmasonApr 8, 2022
  5. Junio C HamanoApr 8, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.