makefile:如何在宏中调用宏
我的 make 文件中有以下宏:
pdf: // 做一些
干净的事情: // 只是另一个奇特的东西
不,我想声明一个宏 all: 其中包含(或调用)上面的宏。以下内容不起作用:
全部: pdf: clean:
我不想重复 pdf: 和 clean: 中的代码,以免违背 DRY 原则。
感谢您的帮助。
I have the following macros in my make file:
pdf:
// do something
clean:
// just another fancy thing
No I want to declare a macro all: which include (or call) the macros above. The following thing doesn't work:
all:
pdf:
clean:
I don't want to repeat the code from pdf: and clean: in order not to rebel against DRY principle.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些不是宏,它们是目标。
Makefile 采用 [target] 语法:[dependent target 1] [dependent target 2]
尝试:
Those are not macros, they are targets.
Makefiles take the syntax of [target]: [dependent target 1] [dependent target 2]
Try:
这是不正确的。文件中的第一个普通目标是默认目标。 all 并没有什么神奇之处,尽管按照惯例将其用作第一个目标。
That's not correct. The first normal target in the file is the default target. There's nothing magical about all, though it is conventional to use that as the first target.
您还可以运行:
无论如何,all 通常用作默认 make 目标 - 换句话说,执行不带参数的 make 与调用 make all 相同。对于有经验的用户来说,这可能非常令人困惑,因此如果您想要“这样的快捷方式”,请尊重地称呼它(例如cpdf)
You also can run:
Any way, all is commonly used as a default make target - in other words executing make without argument is same as calling make all. This maybe very confusing for expirienced users, therefore if you want "such a shortcut", call it deferently (e.g. cpdf)