English 中文(简体)
在规则一节中执行 Makefile 特定命令
原标题:Execute Makefile specific commands in rule section
  • 时间:2012-05-28 09:41:45
  •  标签:
  • makefile

我有一个 包括 指令:

包括 dep/dep.mk

将其他必要的信息纳入我的建筑中。 然而,我只想在建立某些目标后才能将这些信息纳入其中。 我该怎么做呢?

例如:

test: foo.c bar.c
     include dep/dep.mk

在此情况下, 包含 无效, 因为理解它为空壳命令 。

问题回答

无法做到这一点 。 如果您正在使用由足够现代的古董制成的 GNU, 您可以使用 $( eval 包括 dep/ dep.mk) , 但请注意, 包含的 makefile < em> cannot 定义任何规则。 一旦开始构建目标, 即使有 < code>$( eval...) , 也无法定义新的规则/ 目标 。

您所能做的最好就是拥有那些命令, 这些命令想要包含被引用的文件, 使子游戏可以包含文件 。 @ action: inmenu

但我同意Eldar的观点;你需要重新考虑你的要求,也许你解释一下你为什么想这么做,我们可以提供更好的建议。





相关问题
makefile: how to show line numbers for debugging?

Is there a way to have make display the line number where it declares an error? The -d switch doesn t seem to cut it. Updated: Example output: Reaping winning child 0x08aa8648 PID 9381 /bin/sh: ...

What is the reasoning behind the Makefile whitespace syntax?

I m revisiting Python after Michael Sparks s excellent walk through of Peter Norvig s Python spell checker at the SO DevDay in London. One of the points he highlighted was how clean Python is to look ...

Debugging GNU make

Is there a command line way in make to find out which of the prerequisites of a target is not updated?

How to add an all rule to this Makefile?

I want to just type make all and have the following Makefile do everything it s supposed to do: LEX = lex YACC = yacc CC = gcc calcu: y.tab.o lex.yy.o $(CC) -o calcu y.tab.o lex.yy.o -ly -lfl ...

How to discover number of *logical* cores on Mac OS X?

How can you tell, from the command line, how many cores are on the machine when you re running Mac OS X? On Linux, I use: x=$(awk /^processor/ {++n} END {print n+1} /proc/cpuinfo) It s not ...

Using extern in C doesn t work as expected

I have created two files: tunables.h #ifndef TUNABLES_H #define TUNABLES_H void tunables_load_conservative(); void tunables_load_aggressive(); extern int timer_x; #endif /*TUNABLES_H */ and ...