makefile:运行目标时忽略依赖项

use*_*932 3 makefile gnu-make

我的 Makefile 中有这个设置。

action1:
  does something

action2: action1
  does something else
Run Code Online (Sandbox Code Playgroud)

我想保留我的配置,以防我想action1用作 的依赖项action2,但有时我想在运行时忽略 action1 make action2(例如,我想运行make action2而不必包含action1)。我可以设置某种标志以在运行目标时忽略依赖项,我该怎么做?

Jef*_*own 8

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.
Run Code Online (Sandbox Code Playgroud)