

Use make variable in built in shell function in a Makefile
source link: https://www.codesd.com/item/use-make-variable-in-built-in-shell-function-in-a-makefile.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Use make variable in built in shell function in a Makefile
I have this make file
all : CONFIG=config.ini
debug : CONFIG=config-debug.ini
CONFIG_FILES := $(shell python parse_config.py -i $(CONFIG))
all: $(CONFIG) $(CONFIG_FILES)
echo $(CONFIG) $(CONFIG_FILES)
When I run make all
it shows some python error saying -i
option param is missing. So it seems $(CONFIG)
is not going through shell
function.
How can make all
invoke python parse_config.py -i 'config.ini'
?
same way make debug
invoke python parse_config.py -i 'config-debug.ini'
?
Update:
After running make all SHELL+=-x
I get following output.
+ python parse_config.py -p static -i
usage: parse_config.py [-h] -i INPUT_JSB3 [-p PREFIX]
parse_config.py: error: argument -i: expected one argument
But after that I get
+ python parse_config.py -p static -i static/config.ini
And make seems to continue to work.
The problem is that this:
all : CONFIG=config.ini
all: $(CONFIG) $(CONFIG_FILES)
...
will not work. The value of target-specific variables are only available inside the recipe. You cannot use target-specific variables as prerequisites. That's also why it's not set within the $(CONFIG_FILES)
variable when you use it in the prerequisites list.
You can do something like this:
CONFIG_FILES = $1 $(shell python parse_config.py -i $1)
all: $(call CONFIG_FILES,config.ini)
debug: $(call CONFIG_FILES,config-debug.ini)
perhaps. You could write it out explicitly. You could run a recursive make invocation overriding CONFIG_FILES. You could auto-generate included files. You could define some variables then use secondary expansion. There are a lot of ways to do this.
You just can't do it with target-specific variables in the prerequisites list.
Recommend
-
60
README.md 对于我这种英语渣来说, 有时候给一个函数或者变量取一个适当的名字还是比较麻烦的, 一般都要打开 Google 翻译, 翻译一段中文, 然后拷贝到 Emacs 中做各种修改,...
-
11
Makefile与Shell的问题 2013-06-21 18:28:00 大概只要知 道Makefile的人,都知道Makefile可以调用Shell脚本。但是在实际使用时,并不那么简单,一些模棱两可的地方可能会让你抓狂。你若不信,可以先看几个例子,想...
-
23
Applying a function to a multidimensional array with a grouping variable advertisements I have what I thought would be a simple problem, but I...
-
8
UnsplashCSS provides some functions such as calc , var etc. If you are usin...
-
9
Makefile defining a variable in the if statement in a target advertisements I have a Makefile with the following: AVAR="" all...
-
9
Linux软件包管理器 - yum Linux下安装软件的方式 在Linux下安装软件的方法大概有以下三种: 1)下载到程序的源代码,自行进行编译,得到可执行程序。 2)获取rpm安装包,通过rpm命令进行安装。(未解决软件的依赖关系)...
-
7
Make 命令的简单用法 Makefile 的编写规则 Statements: 笔记的内容转自 阮一峰老师的 Make 命令教程 代码变成可执行文件,...
-
7
Usage: This is an example for a function myfn that: Takes a local input file name FILE Returns an abs_filename, created by using the global variable PATH ...
-
6
Francis T. O'Donovan Senior Data Science Manager at Hospital IQ – Planet discoverer, researcher, dev...
-
6
How can I add an environment variable to a process launched via ShellExecuteEx or IContextMenu?
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK