Makefile templates: one template, multiple instances in pre-order

I hope this is the main question about the rules for creating templates: I want to use a wildcard several times in pre-order for the rule, i.e. In my makefile I have

data/%P1.m: $(PROJHOME)/data/%/ISCAN/%P1.RAW @echo " Writing temporary matlab file for $*" # do something data/%P2.m: $(PROJHOME)/data/%/ISCAN/AGP2.RAW @echo " Writing temporary matlab file for $*" # do something 

In this example, I am trying to call make when wildcard% AG. Both $ (PROJHOME) /data/AG/ISCAN/AGP1.RAW and $ (PROJHOME) /data/AG/ISCAN/AGP2.RAW files both exist. I am trying to execute the following make commands and get this output:

 [ jshen@iLab10 gender-diffs]$ make data/AGP1.m make: *** No rule to make target `data/AGP1.m'. Stop. [ jshen@iLab10 gender-diffs]$ make data/AGP2.m Writing temporary matlab file for AG, part 2... [ jshen@iLab10 gender-diffs]$ ls data/AG/ISCAN/AG* data/AG/ISCAN/AGP1.RAW data/AG/ISCAN/AGP2.RAW 

How can I implement multiple instances of the same template in the first make rule?

+4
source share
1 answer

this seemed to work:

 .SECONDEXPANSION: data/%P1.m: $(PROJHOME)/data/$$*/ISCAN/$$*P1.RAW @echo "Writing temporary matlab file for $*, part 1..." 
+4
source

Source: https://habr.com/ru/post/1308305/


All Articles