makefile:运行目标时忽略依赖项
我的Makefile中有这个设置makefile:运行目标时忽略依赖项,makefile,gnu-make,Makefile,Gnu Make,我的Makefile中有这个设置 action1: does something action2: action1 does something else 我想保留我的配置,以防我想使用action1作为action2的依赖项,但有时我想在运行makeaction2时忽略action1(例如,我想运行makeaction2,而不必包含action1)。我是否可以设置某种标志,以便在运行目标时忽略依赖关系?我如何执行此操作?您可以这样做: ACTION1 = action1 acti
action1:
does something
action2: action1
does something else
我想保留我的配置,以防我想使用
action1
作为action2
的依赖项,但有时我想在运行makeaction2
时忽略action1(例如,我想运行makeaction2
,而不必包含action1
)。我是否可以设置某种标志,以便在运行目标时忽略依赖关系?我如何执行此操作?您可以这样做:
ACTION1 = action1
action1:
does something
action2: $(ACTION1)
does something else
现在,如果您运行make
,那么这两个都将生成。如果运行makeaction1=
,则该变量将为空,action2
将不依赖于ACTION1
。当然,您可以随意调用该变量。make-o允许您忽略依赖项及其所有含义。从手册页:
-o file, --old-file=file, --assume-old=file
Do not remake the file file even if it is older than
its dependencies, and do not remake anything on account
of changes in file. Essentially the file is treated as
very old and its rules are ignored.
你可以有
action3:
,它没有prereq,但是做了其他的事情
@Beta我不想重复:(我想我可以使用一个函数tho来消除重复性,但最好使用某种标志。在这里使用:=
而不是=
。耸耸肩。在这种情况下,这并没有什么区别。