help-make
[Top][All Lists]
Advanced

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

is there a make style guide somewhere?


From: Robert P. J. Day
Subject: is there a make style guide somewhere?
Date: Thu, 31 Oct 2019 10:17:34 -0400 (EDT)
User-agent: Alpine 2.21 (LFD 202 2017-01-01)

  was dropped into an existing project where the makefiles were
designed based on the only understood workflow at the time, and those
makefiles are not really compatible with what we're trying to do now,
and some of it has to do with what looks like pretty basic design
issues. here's just one of them.

  lots of the makefiles have recipes of the form:

  $(OUTPUT_DIR)/target.elf: $(INPUT_DIR)/src.c
        ... do what it takes to turn src.c into target.elf ...

perfectly respectable, as long as that target is invoked within the
context of the makefile so that those variables have values. however,
it makes it difficult to invoke *just* that target since you never
know what the OUTPUT_DIR or INPUT_DIR might be.

  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?

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]