makefile - make 运行所有目标

标签 makefile

我想只为安装编写一个makefile。我想拥有一个 install目标和 all目标。 all目标将仅作为默认目标存在,因此运行 make会说“没什么可 build 的”。但是,当我做一个小测试并运行 make 时或 make all ,看来安装目标也运行了。这是生成文件:

vimprefix=/usr/share/vim/vim73

.PHONY: all
all: 
    @echo "Nothing to build. Run `make install` to install configurations."

.PHONY: install
install:
    test -d $(vimprefix)

这是 make 的输出:
$ make
Nothing to build. Run make[1]: Entering directory `/home/user/documents/conf'
test -d /usr/share/vim/vim73
make[1]: Leaving directory `/home/user/documents/conf' to install configurations.

我注意到如果我输入类似 touch all 的内容就不会发生这种情况。在 all目标。有人可以解释为什么会发生这种情况吗?

最佳答案

呵呵,不错的。 :)

Run `make install` to 

这包含反引号,它调用命令 make install .使用简单的撇号。

关于makefile - make 运行所有目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23186068/

相关文章:

c++ - 编译 C++ 代码时如何解决版本控制问题?

包含 ddd 调试器选项的 C++ Makefile

visual-studio - GCC 与 Visual Studio 一起使用吗?

c - 什么是头文件和库文件?

makefile - 尝试在 Windows 子系统中为 Linux 错误编译内核模块

makefile - 在 Makefile 中激活 virtualenv

c - bmake : Proper use of Automatic Variables

macos - 使用 C++11 在 g++ 中编译库

c++ - Makefile 模式规则 : Circular makefile. o <- makefile 依赖项已删除

makefile - 匹配任何模式规则