Makefile:$subst在依赖项列表中

Makefile:$subst在依赖项列表中,makefile,Makefile,我有一个Makefile,大致如下所示: FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps NUMBERS = 1 2 3 all : $(FIGURES) %.eps : $(foreach num, $(NUMBERS), $(subst B, $(num), %).out) # my_program($+, $@); %.out : Ax_1x_Cx.out Ax_2x_Cx.out Ax_3x_Cx.out 重点是我的图形

我有一个Makefile,大致如下所示:

FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps
NUMBERS = 1 2 3

all : $(FIGURES)

%.eps : $(foreach num, $(NUMBERS), $(subst B, $(num), %).out)
    # my_program($+, $@);

%.out :
Ax_1x_Cx.out
Ax_2x_Cx.out
Ax_3x_Cx.out
重点是我的图形的文件名包含某些信息(A、B、C),每个图形都是由我的_程序从几个(在示例3中)文件创建的。 虽然每个地物的文件名的格式为
Ax\u Bx\u Cx.eps
,但用于创建地物的数据文件的名称如下所示:

FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps
NUMBERS = 1 2 3

all : $(FIGURES)

%.eps : $(foreach num, $(NUMBERS), $(subst B, $(num), %).out)
    # my_program($+, $@);

%.out :
Ax_1x_Cx.out
Ax_2x_Cx.out
Ax_3x_Cx.out
因此,对于每个图,我需要一个动态创建的具有多个文件名的依赖项列表。换句话说,我对上述示例的期望输出是:

#我的课程(A1_11_C1.out A1_21_C1.out A1_31_C1.out,A1_B1_C1.eps)

#我的课程(A2_12_C2.out A2_22_C2.out A2_32_C2.out,A2_B2_C2.eps)

#我的课程(A3_13_C3.out A3_23_C3.out A3_33_C3.out,A3_B2_C3.eps)

不幸的是,
subst
命令似乎被忽略,因为输出如下所示:

FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps
NUMBERS = 1 2 3

all : $(FIGURES)

%.eps : $(foreach num, $(NUMBERS), $(subst B, $(num), %).out)
    # my_program($+, $@);

%.out :
Ax_1x_Cx.out
Ax_2x_Cx.out
Ax_3x_Cx.out
#我的课程(A1_B1_C1.out A1_B1_C1.out A1_B1_C1.out,A1_B1_C1.eps)

#我的课程(A2_B2_C2.out A2_B2_C2.out A2_B2_C2.out,A2_B2_C2.eps)

#我的课程(A3_B3_C3.out A3_B3_C3.out A3_B3_C3.out,A3_B3_C3.eps)

我看了一下,但认为答案对我没有帮助,因为我使用的是
%
,而不是
$@
,这在前提条件中应该是可以的


很明显,我这里出了点问题。非常感谢您的任何帮助。

要进行奇特的先决条件操作,您至少需要make-3.82,它支持:

输出:

$ make
touch A1_11_C1.out
touch A1_21_C1.out
touch A1_31_C1.out
my_program(A1_11_C1.out A1_21_C1.out A1_31_C1.out, A1_B1_C1.eps)
touch A2_12_C2.out
touch A2_22_C2.out
touch A2_32_C2.out
my_program(A2_12_C2.out A2_22_C2.out A2_32_C2.out, A2_B2_C2.eps)
touch A3_13_C3.out
touch A3_23_C3.out
touch A3_33_C3.out
my_program(A3_13_C3.out A3_23_C3.out A3_33_C3.out, A3_B3_C3.eps)