如何调用其他目录中的Makefile? [英] How to call Makefile located in other directory?

查看:552
本文介绍了如何调用其他目录中的Makefile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试这样做:

我想从其他目录中的shell脚本调用make(其他目录中存在Makefile,可以使用abc路径).我该怎么做呢?

I want to call a make (Makefile exists in some other directory, abc path can be used) from a shell script located in a different directory. How do I do this?

由于shell脚本不允许我cd进入Makefile目录并执行make,因此我该如何编写shell命令(通过提供要执行的Makefile的路径)来执行?

Since shell scripting does not allow me to cd into the Makefile directory and execute make, how can I write the shell command (by giving path to the Makefile to be executed) to execute make?

推荐答案

GNU make接受许多选项,尤其是-C在运行前更改目录,而-f用于跟随Makefile.

GNU make accepts many options, notably -C to change directory before running, and -f for giving the Makefile to follow.

适当组合它们.

考虑使用 remake 来简化与Makefile相关的调试(特别是使用-x)问题.对于GNU make版本4或更高版本,还请使用make --trace ...

Consider using remake to ease debugging (notably with -x) of Makefile related issues. With GNU make version 4 or better, also use make --trace...

您可以拥有自己的可执行Shell脚本(例如,在$HOME/bin/中的$PATH中),该脚本同时使用cdmake.

You could have your own executable shell script (e.g. in your $HOME/bin/ which would be in your $PATH) which uses both cd and make).

您可以考虑使用其他构建自动化工具(

You could consider other build automation tools (ninja perhaps)

也请阅读P.Miller的论文 递归使之被视为有害

Read also P.Miller's paper Recursive Make considered harmful

这篇关于如何调用其他目录中的Makefile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆