multi-wildcard pattern rules of GNU Make

前端 未结 3 1781
轮回少年
轮回少年 2021-01-03 23:13

I want to write something like regex:

SRC:=\"a.dat.1 a.dat.2\"    
$(SRC): %.dat.%: (\\\\1).rlt.(\\\\2)    
      dat2rlt $^ $@

so that

3条回答
  •  攒了一身酷
    2021-01-04 00:11

    For the limited example you gave, you can use a pattern with one %.

    SRC := a.dat.1 a.dat.2
    ${SRC}: a.dat.%: a.rlt.%    
          dat2rlt $^ $@
    
    1. $* in the recipe will expand to whatever the % matched.
    2. Note that the "s around your original macro are definitely wrong.
    3. Have a look at .SECONDEXPANSION in the manual for more complicated stuff (or over here).

提交回复
热议问题