且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从另一个Makefile调用Makefile?

更新时间:2023-09-26 10:32:28

我不太清楚您要问的是什么,但是使用-f命令行选项只是指定一个文件-它不会告诉make更改目录.如果要在另一个目录中进行工作,则需要cd到目录:

I'm not really too clear what you are asking, but using the -f command line option just specifies a file - it doesn't tell make to change directories. If you want to do the work in another directory, you need to cd to the directory:

clean:
    cd gtest-1.4.0 && $(MAKE) clean

请注意,Makefile中的每一行都在单独的外壳程序中运行,因此无需将目录改回.

Note that each line in Makefile runs in a separate shell, so there is no need to change the directory back.