包括makefile,(搜索路径)(没有〜扩展)...是什么意思?

Joh*_*han 3 makefile gnu-make

今天,当我使用 --debug=v 构建我的项目时,我注意到一些我并不真正理解它的含义的东西。

在他包含“子生成文件”的顶部有一个奇怪的打印输出,它告诉我(搜索路径)(没有〜扩展)......这是什么意思?

打印输出如下所示:

Reading makefiles...
Reading makefile `Makefile'...
Reading makefile `make_pc.mk' (search path) (no ~ expansion)...
Reading makefile `print_ring/make.mk' (search path) (no ~ expansion)...
Reading makefile `vendor/unity/make.mk' (search path) (no ~ expansion)...
Reading makefile `test01/make.mk' (search path) (no ~ expansion)...
Run Code Online (Sandbox Code Playgroud)

使用 include 的主 Makefile 中的行如下所示:

TEST := test01
include $(TEST)/make.mk
Run Code Online (Sandbox Code Playgroud)

包含的 makefile 可能如下所示:

CFLAGS  += -Itest01/
OBJ += test_main.o
test_main.o: test01/test_main.c
    @ echo ".compiling"
    $(CC) $(CFLAGS) -o $@ $<
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法来使用搜索路径?但是 ~ 会扩展到我的 unix 用户主目录吗?

注意:我在 Linux (Ubuntu) 机器上执行此操作。

注意:所有文件都可以在这个github 项目中找到

/谢谢

Joh*_*all 5

其中一些信息针对的是人们调试 Make 自身而不是调试他们自己项目的构建基础结构,因此如果它没有真正记录或特别用于跟踪您自己的构建问题,这并不奇怪。

也就是说,您可以通过花几分钟时间了解 GNU Make 源代码来弄清楚这些意味着什么。

(search path)是 Make 的内部RM_INCLUDED标志,这(我过度概括)意味着这个 makefile 是通过include另一个 makefile遇到的,并且-I可能已经检查了搜索路径以找到它。

(no ~ expand )是它的内部RM_NO_TILDE标志,并在 Make 的read.c 的此注释中进行了解释:

/* Expand ~ in FILENAME unless it came from `include',
   in which case it was already done.  */
Run Code Online (Sandbox Code Playgroud)

GNU Make 确实将 ~ 扩展到主目录,并且这个标志阻止它发生两次——我想这可能会对一些非常不寻常的文件系统布局产生影响。