[bug #62162] patsubst not working in prerequisites under .SECONDEXPANSION

2022-03-10 Thread Mikhail
Follow-up Comment #5, bug #62162 (project make):

Oh, I got it now, % expands as a stem of static pattern rule, and not being
used by patsubst. 

The issue is resolved. 

Thanks,
Mikhail

___

Reply to this item at:

  

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




[bug #62162] patsubst not working in prerequisites under .SECONDEXPANSION

2022-03-10 Thread Mikhail
Follow-up Comment #4, bug #62162 (project make):

Thanks, _$$(percent)_ trick makes the job done. 

However what is happening is still obscure. For example, here _patsubst_ does
everything correctly


lib1_SRCS := main.c try.c test.c
lib2_SRCS := lib.c api.c

.SECONDEXPANSION:
lib1 lib2: $$(patsubst %.c,%.o,$$($$@_SRCS))


and _lib1_  depends on main.o, try.o and test.o.

Reworking it in static pattern rule fashion results in prerequisites main.c,
try.c and test.c for _lib1_, i.e. patsubst does nothing.


lib1_SRCS := main.c try.c test.c
lib2_SRCS := lib.c api.c

.SECONDEXPANSION:
lib1 lib2: lib% : $$(patsubst %.c,%.o,$$(lib$$*_SRCS))


___

Reply to this item at:

  

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




[bug #62162] patsubst not working in prerequisites under .SECONDEXPANSION

2022-03-10 Thread Dmitry Goncharov
Follow-up Comment #3, bug #62162 (project make):

A typo, ofcourse should be $$(percent)



percent:=%
$(files) : %.ext : $$(patsubst r$$(percent),$$(percent),$$(lastword $$(subst
.stem., ,$$*)))-prereq


___

Reply to this item at:

  

___
  Сообщение отправлено по Savannah
  https://savannah.gnu.org/




[bug #62162] patsubst not working in prerequisites under .SECONDEXPANSION

2022-03-10 Thread Dmitry Goncharov
Follow-up Comment #2, bug #62162 (project make):

You can store % in a variable


percent:=%
$(files) : %.ext : $$(patsubst r$(percent),$(percent),$$(lastword $$(subst
.stem., ,$$*)))-prereq


___

Reply to this item at:

  

___
  Сообщение отправлено по Savannah
  https://savannah.gnu.org/




[bug #62162] patsubst not working in prerequisites under .SECONDEXPANSION

2022-03-10 Thread Andreas Schwab
Follow-up Comment #1, bug #62162 (project make):

The replacement of % by the stem happens before the secondary expansion is
performed.

___

Reply to this item at:

  

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




[bug #62162] patsubst not working in prerequisites under .SECONDEXPANSION

2022-03-10 Thread anonymous
URL:
  

 Summary: patsubst not working in prerequisites under
.SECONDEXPANSION
 Project: make
Submitted by: None
Submitted on: Thu 10 Mar 2022 10:06:34 AM UTC
Severity: 3 - Normal
  Item Group: Bug
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: 4.3
Operating System: POSIX-Based
   Fixed Release: None
   Triage Status: None

___

Details:

For some reason `patsubst` function doesn't do its work in the following
snippet. 

```
prereq_files = 1-prereq 2-prereq
all: prefix.stem.r1.ext

files = $(foreach file,$(prereq_files),prefix.stem.r$(patsubst
%-prereq,%,$(file)).ext)
# Files is prefix.stem.r1.ext prefix.stem.r2.ext
$(files) : %.ext : $$(patsubst r%,%,$$(lastword $$(subst .stem.,
,$$*)))-prereq
cat $< > $@
```

I get `make: *** No rule to make target 'r1-prereq'` error, when trying to
make `prefix.stem.r1.ext` which by design should depend on `1-prereq`.
patsubst doesn't do its job and makes it depend on r1-prereq which is
non-existent. Weirdly if I just use $(subst r,,<...>) everything is fine. 

Any ideas?
-Mikhail



___

File Attachments:


---
Date: Thu 10 Mar 2022 10:06:34 AM UTC  Name: Makefile  Size: 253B   By: None



___

Reply to this item at:

  

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