[Top][All Lists]

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

Re: Make's assumption that files it does not create do not change

From: Kaz Kylheku
Subject: Re: Make's assumption that files it does not create do not change
Date: Wed, 13 Apr 2022 09:02:26 -0700
User-agent: Roundcube Webmail/1.4.13

On 2022-04-13 06:39, Renaud Pacalet wrote:
On 13/04/2022 15:27, Paul Smith wrote:
On Tue, 2022-04-12 at 14:58 -0700, Kaz Kylheku wrote:
I also somewhat regret implementing the feature because it is
The feature is built on the the implementation of pattern rules,
which already supported multiple targets many years before &:.

Just to mention that these options including &: and just using pattern
rules were discussed in the GitHub issue and the followup comments so
these were known to the folks implementing the change.

I don't really agree that using pattern rules is a sufficient
alternative.  Forcing targets to have a common stem is not always
great.  I for one am happy that this feature exists!

Agreed. I was really expecting this feature. Not only because of the
common stem constraint but also because most pattern rules that I was
writing just for this grouped target feature were extremely unnatural.
It even happened that somebody else decided to "fix" them because I
had forgotten to add a big "don't touch" comment.

I am very happy too that this feature exists.

I hear both of you. My alpha charlie example deliberately emphasizes
the weirdness of looking for an incidental common stem which bears no

But there is a (seemingly) simple fix for that: allow empty stems.

That's it: allow the % pattern wildcard to have an empty match,
and then you can do the following, which is much better:

  alpha% bravo% : delta% charlie%

When a file called bravo needs to be updated, it will match bravo%,
binding the % variable to the empty string "". and off we go:
the grouped target rule we want is instantiated for us.

Any non-empty set of strings always has a common infix: the empty string,
and by convention you can use the leading or trailing one.

(Is there some deep reason why % cannot bind to an empty string?)

Oh, I just remembered something. I last thought about this issue
several years ago, and had this idea at that time.

Also, a way to give a common stem to some files is to move them
into a subdirectory. This will work even if the tool involved has
hard-coded names.

  %/alpha %/bravo : %/delta %/charlie
        cd $* ; tool-with-fixed-names

  whole: part subdir/alpha
        @echo build $@ from $^

  part: subdir/bravo
        @echo build $@ from $^

too-with-fixed-names accesses "alpha", "bravo", in its working

  $ make -f Makefile2
  cd subdir ; echo tool-with-fixed-names
  build part from subdir/bravo
  build whole from part subdir/alpha

reply via email to

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