[bug #51311] Checking search retries for implicit make rules

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[bug #51311] Checking search retries for implicit make rules

Robert Morell
URL:
  <http://savannah.gnu.org/bugs/?51311>

                 Summary: Checking search retries for implicit make rules
                 Project: make
            Submitted by: elfring
            Submitted on: Sun 25 Jun 2017 09:40:47 PM CEST
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.2.1
        Operating System: Any
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

The documentation contains the following information
<https://www.gnu.org/software/make/manual/html_node/Goals.html>:
“…
Any target in the makefile may be specified as a goal (…). Even targets not
in the makefile may be specified, if make can find implicit rules that say how
to make them.
…”


my_info?=echo
my_compilation?=echo
my_preparation?=cat
footer?=MOTD.txt
prepared_file?=MOTD.in

MOTD.info: ${footer}
        ${my_info} "$(shell date): Is this acceptable?: $(shell cat ${footer})" > $@

MOTD%.log: MOTD%.txt MOTD%.in
        ${my_compilation} "$<: $(shell cat ${prepared_file} ${footer})" > $@

${prepared_file}: MOTD.draft
        ${my_preparation} $< > $@


Test result:

elfring@Sonne:~/Projekte/Bau> LANG=C make --no-builtin-rules -f
../GNU/make/rule-check3.make -d MOTD.log

Updating goal targets....
Considering target file 'MOTD.log'.
 File 'MOTD.log' does not exist.
 Looking for an implicit rule for 'MOTD.log'.
 No implicit rule found for 'MOTD.log'.
 Finished prerequisites of target file 'MOTD.log'.
Must remake target 'MOTD.log'.
make: *** No rule to make target 'MOTD.log'.  Stop.



I would interpret the second rule as a make pattern rule
<https://www.gnu.org/software/make/manual/html_node/Pattern-Match.html> which
is also categorised as an implicit rule then. An explicit make rule does not
exist in this small test example for the specified (non-default) goal. So I
would expect that another search try will be performed.
Why do I observe a mismatch there?

How much does it matter in this test case that I would like to try a
prerequisite out which should contain two “patterns”?




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51311>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[bug #51311] Checking search retries for implicit make rules

Robert Morell
Follow-up Comment #1, bug #51311 (project make):

Markus,

You've opened this as a bug. I believe it is not a bug.  Again. I'm not a
maintainer.

Please note two things.

1. while "MOTD%.log: MOTD%.txt" is a pattern rule, "MOTD%.log: MOTD%.txt
MOTD%.in" is not a pattern rule, because it has two entries after the colon.
So your interpretation is incorrect.

2. The '%' (the stem) in a pattern rule doesn't, if I recall correctly, match
a null string.  It needs to match at least a single character, so building
MOTD.log won't work.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51311>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [bug #51311] Checking search retries for implicit make rules

Philip Guenther-2
On Sun, 25 Jun 2017, Mike Gran wrote:
> Follow-up Comment #1, bug #51311 (project make): You've opened this as a
> bug. I believe it is not a bug.  Again. I'm not a maintainer.
>
> Please note two things.
>
> 1. while "MOTD%.log: MOTD%.txt" is a pattern rule, "MOTD%.log: MOTD%.txt
> MOTD%.in" is not a pattern rule, because it has two entries after the colon.

This is incorrect.  To quote the make info pages, section 10.5.1
"Introduction to Pattern Rules":
-----
A pattern rule contains the character `%' (exactly one of them) in the
target; otherwise, it looks exactly like an ordinary rule.  The target
is a pattern for matching file names; the `%' matches any nonempty
substring, while other characters match only themselves.  
-----

There's no restriction in the documention on the number of prequisites on
the rule and they may contain any mix of pattern and non-pattern names.  
See that page and the others in that section for further details.



> 2. The '%' (the stem) in a pattern rule doesn't, if I recall correctly, match
> a null string.  It needs to match at least a single character, so building
> MOTD.log won't work.

This is correct, as per the documentation quoted above.


Philip Guenther

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [bug #51311] Checking search retries for implicit make rules

Mike Gran
On Sun, Jun 25, 2017 at 02:10:03PM -0700, Philip Guenther wrote:
> > 1. while "MOTD%.log: MOTD%.txt" is a pattern rule, "MOTD%.log: MOTD%.txt
> > MOTD%.in" is not a pattern rule, because it has two entries after the colon.
>
> This is incorrect.  To quote the make info pages, section 10.5.1
> "Introduction to Pattern Rules":

Apologies for the noise.



_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[bug #51311] Checking search retries for implicit make rules

Robert Morell
In reply to this post by Robert Morell
Follow-up Comment #2, bug #51311 (project make):

From Mike Gran:
“…
So your interpretation is incorrect.
…”

I find that the documentation can be clarified a bit more on this aspect.

I propose another software extension then.


From Mike Gran:
“…
It needs to match at least a single character,
…”

I would appreciate to use a placeholder which can occasionally also be
resolved to the empty string at the discussed script place.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51311>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [bug #51311] Checking search retries for implicit make rules

SF Markus Elfring
In reply to this post by Philip Guenther-2
> To quote the make info pages, section 10.5.1 "Introduction to Pattern Rules":
> -----
> A pattern rule contains the character `%' (exactly one of them)

I interpreted this description in the way that one placeholder would be supported
for each element in the list of prerequisites.


> …; the `%' matches any nonempty substring, while other characters match only themselves.  
> -----

How do you think about to mention the requirement “non-empty string” at another place?
https://www.gnu.org/software/make/manual/html_node/Pattern-Match.html


> There's no restriction in the documention on the number of prequisites on
> the rule and they may contain any mix of pattern and non-pattern names.

I find that this wording can be only partly appropriate.

* Is there a current software restriction that only a single pattern
  is supported within the prerequisites list for a specific make rule?

* Will any more developers become interested in related software extensions?

Regards,
Markus

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[bug #51311] Checking search retries for implicit make rules

Robert Morell
In reply to this post by Robert Morell
Update of bug #51311 (project make):

                  Status:                    None => Duplicate              
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #3:

As pointed out on the mailing list, it's not true that there can only be one
prerequisite containing the pattern character (%).  In fact there can be zero,
one, or as many prerequisites containing the pattern character as you like.
Essentially if the target contains a pattern character then it's a pattern
rule: the prerequisites list doesn't matter.

As Mike points out, the reason your example doesn't work is that a pattern
character must match at least one character.

As for allowing pattern characters to match zero characters, that is already
filed as an enhancement request as bug #29448 so we don't need another one.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51311>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[bug #51311] Checking search retries for implicit make rules

Robert Morell
Follow-up Comment #4, bug #51311 (project make):

> In fact there can be zero, one, or as many prerequisites containing the
pattern character as you like. Essentially if the target contains a pattern
character then it's a pattern rule:

Can examples in the manual cause the impression that there is any limitation?


>…, the reason your example doesn't work is that a pattern character must
match at least one character.

Can this information appear in another section of the manual?

Do I need to pair standard pattern rules with concrete make rules so that the
placeholder “%” will be handled in special cases as if it would be
optional?

I am curious on how the software will evolve further for the previous
clarification request “pattern rules: % doesn't match empty string”
<https://savannah.gnu.org/bugs/?29448> then.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51311>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [bug #51311] Checking search retries for implicit make rules

Edward Welbourne-3
In reply to this post by Robert Morell
Mike Gran (25 June 2017 22:54)
> The '%' (the stem) in a pattern rule doesn't, if I recall correctly,
> match a null string.  It needs to match at least a single character,
> so building MOTD.log won't work.

At the risk of stating the obvious, note that there is a trivial
work-around for this - there is nothing special about dot in patterns,
so you could merge the dot into what % matches to make it non-empty:

MOTD%log: MOTD%txt MOTD%in

... or, of course, merge the D in from the other end:

MOT%.log: MOT%.txt MOT%.in

        Eddy.

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [bug #51311] Checking search retries for implicit make rules

SF Markus Elfring
> At the risk of stating the obvious, note that there is a trivial
> work-around for this - there is nothing special about dot in patterns,
> so you could merge the dot into what % matches to make it non-empty:

It might be acceptable to give up a character from either end
of the prefix (or suffix) for my toy example.

Will the pattern match be a bit more flexible with this trick
than what was originally intended?


I imagine that direct support would be nice for a placeholder
which can be treated as optional in such an use case.

Regards,
Markus

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Loading...