我在Makefile中有这个设置。
action1:
does something
action2: action1
does something else
我想保留配置,以防我想action1
作为action2
的依赖项,但有时我想在运行make action2
时忽略action1(例如我想运行make action2
而不必包含action1
)。我可以设置某种标志来传递以在运行目标时忽略依赖关系,我该如何去做呢?
答案 0 :(得分:2)
你可以这样做:
".profile"
现在,如果你运行ACTION1 = action1
action1:
does something
action2: $(ACTION1)
does something else
,那么两者都将被构建。如果您运行make
,那么该变量将为空,make ACTION1=
将不依赖于action2
。当然你可以随意调用那个变量。
答案 1 :(得分:1)
make -o <name of dependency>
使您可以忽略依赖项及其所有含义。在手册页中:
-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.