[bug #56732] VPATH doesn't work with pattern rules

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #56732] VPATH doesn't work with pattern rules

anonymous
URL:
  <https://savannah.gnu.org/bugs/?56732>

                 Summary: VPATH doesn't work with pattern rules
                 Project: make
            Submitted by: None
            Submitted on: Thu 08 Aug 2019 11:26:35 AM UTC
                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: POSIX-Based
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

VPATH doesn't work with pattern rules, at least when using link libraries. I
can see nothing in the manual to suggest it shouldn't. Here's a reduced test
case.

Steps to reproduce:

In an empty directory, create the following dirs/files:

mkdir libs
touch libs/libAbc.a
mkdir input
touch input/example.in
touch input/example2.in
mkdir output


Create a Makefile with the following contents:


VPATH = libs

#irrelevant_recipe : -lAbc
# echo "This recipe is never run"

output/% : input/%.in -lAbc
        @echo "Running recipe to build $@ from $<"



Run this command:

make output/example


Actual behaviour:


> make output/example
make: *** No rule to make target `output/example'.  Stop.


Expected behaviour:


> make output/example
Running recipe to build output/example from input/example.in


Note: Uncommenting the "irrelevant" recipe causes the pattern rule to work in
the above case. However, this workaround only works for one item - if you try
to build example and example2 at the same time, it still fails to build
whichever one comes second. But either can be built individually:


> make output/example
Running recipe to build output/example from input/example.in
> make output/example2
Running recipe to build output/example2 from input/example2.in
> make output/example output/example2
Running recipe to build output/example from input/example.in
make: *** No rule to make target `output/example2'.  Stop.


This makes it not useful as a workaround, as really the point of pattern rules
is to build multiple items using the same rule.





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56732>

_______________________________________________
  Message sent via Savannah
  https://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
|

[bug #56732] VPATH doesn't work with pattern rules

anonymous
Follow-up Comment #1, bug #56732 (project make):

Your example doesn't seem to rely on VPATH in any way. Remember: VPATH is used
as a place to look for files.

Also you are using "-lAbc" as prerequisite for output/%. It seems you are
intending to use linker flags as input to the recipe. The way you wrote is it
wrong, it will cause make to look for a file named "-lAbc" (which it won't
find and abort recipe search). Run make with the flag "-d" to see makes
reasoning.

Read up on using implicit rules, and the variables used for the builtin rules
by make. You might want to replace "-lAbc" with  "libAbc.a" and maybe add
appropriate variables if you use the built-in recipes.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56732>

_______________________________________________
  Message sent via Savannah
  https://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
|

[bug #56732] VPATH doesn't work with pattern rules

anonymous
Follow-up Comment #2, bug #56732 (project make):

Thanks for looking at this. Make supports linker flags as dependencies of a
recipe and automatically searches for the .a/.so file using VPATH. See the
relevant section of the manual, 4.5.6 "Directory Search for Link Libraries".

I should have emphasised that this *does* work if it's *not* a pattern rule.
In other words, if you replace this line:


output/% : input/%.in -lAbc


with:


output/example : input/example.in -lAbc


then the recipe works as expected (but, obviously, only for a file named
"example"; unfortunately in my use case I need to build an arbitrary set of
files, i.e. I need a pattern rule).

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56732>

_______________________________________________
  Message sent via Savannah
  https://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
|

[bug #56732] VPATH doesn't work with pattern rules

anonymous
Follow-up Comment #3, bug #56732 (project make):

OK, this is a special case I didn't remembered. The wording in the manual
doesn't touch implicit rules, so one can assume it should work for them too.

I don't know how much application of rules differs between normal and implicit
ones, so I can't help beyond this point.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56732>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


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

Re: [bug #56732] VPATH doesn't work with pattern rules

JZB
On 8/10/19 8:16 AM, anonymous wrote:
> Follow-up Comment #3, bug #56732 (project make):
>
> OK, this is a special case I didn't remembered. The wording in the manual
> doesn't touch implicit rules, so one can assume it should work for them too.
>
> I don't know how much application of rules differs between normal and implicit
> ones, so I can't help beyond this point.
>

The Make manual also shows that the implementation of library search
rules as discussed here is itself a pattern rule, so it wouldn't
surprise me if a pattern rule within a pattern rule is unsupported.

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

[bug #56732] VPATH doesn't work with pattern rules

anonymous
In reply to this post by anonymous
Update of bug #56732 (project make):

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

    _______________________________________________________

Follow-up Comment #4:

This is a duplicate of bug #29104
Thanks for the report!

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56732>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/