help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is there a make style guide somewhere?


From: Robert P. J. Day
Subject: Re: is there a make style guide somewhere?
Date: Sat, 2 Nov 2019 05:09:42 -0400 (EDT)
User-agent: Alpine 2.21 (LFD 202 2017-01-01)

On Sat, 2 Nov 2019, David wrote:

> On Fri, 1 Nov 2019 at 02:08, Robert P. J. Day <address@hidden> wrote:
>
> [...]
>
> >   my suggestion was, for any targets for which it is feasible to
> > invoke directly, add a redirection(?) target with a meaningful name:
> >
> >   turn_src_into_elf: $(OUTPUT_DIR)/target.elf
> >   $(OUTPUT_DIR)/target.elf: $(INPUT_DIR)/src.c
> >         ... do what it takes to turn src.c into target.elf ...
> >
> > at which point, of course:
> >
> >   $ make turn_src_into_elf
> >
> > does this make sense? is it a well-known make idiom? is there a list
> > somewhere of such idioms and style recommendations?
>
> Makes sense to me.
>
> FYI, because the recipe does not actually create a file named
> "turn_src_into_elf", it is named a "phony target", and it is a good
> idea to inform make that fact, using this statement: .phony
> turn_src_into_elf

  ah, so because "turn_src_into_elf" is just my pet name for an
*actual* possibly updated file, my pet name should be .PHONY, as
in:

.PHONY: turn_src_into_elf
turn_src_into_elf: $(OUTPUT_DIR)/target.elf
$(OUTPUT_DIR)/target.elf: $(INPUT_DIR)/src.c
         ... recipe ...

while its dependency would, of course, not be. that's the
clarification i was after.

> Doing so has some benefits, which are documented here:
> https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets

  working my way through make manual as we speak, thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                         http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



reply via email to

[Prev in Thread] Current Thread [Next in Thread]