Sh4*_*4pe 7 dependencies build-process makefile gnu-make
我的问题涉及GNU的制作.
如果您有一系列命令可用作多个目标的配方,则罐装配方会派上用场.我可能看起来像这样:
define run-foo
# Here comes a
# sequence of commands that are
# executed line by line
endef
Run Code Online (Sandbox Code Playgroud)
现在您可以像这样使用罐装配方:
file1: input1:
$(run-foo)
$(pattern) : sub/% : %.inp
$(run-foo)
Run Code Online (Sandbox Code Playgroud)
等等.我想知道是否有可能定义带参数的罐装食谱(或类似的东西),以便我可以像这样执行它们:
file2: input2
$(run-foo) specific-parameter2 "additional"
file3: input3
$(run-foo) another-parameter3 "text"
Run Code Online (Sandbox Code Playgroud)
这可能吗?任何提示欢迎:)
Mik*_*han 12
你这样做:
$1,$2...等define$(call ...)例如:
define recipe
echo $1
endef
all: t1 t2
t1:
$(call recipe,"One")
t2:
$(call recipe,"Two")
Run Code Online (Sandbox Code Playgroud)