Makefile:如何在调用变量时增加变量? (bash中的var ++) [英] Makefile : how to increment a variable when you call it? (var++ in bash)

查看:109
本文介绍了Makefile:如何在调用变量时增加变量? (bash中的var ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的makefile的一部分:

Here is part of my makefile :

LISTEINC = $(DEST)/file.inc $(DEST)/otherfile.inc $(DEST)/anotherfile.inc
compteur = 1

$(DEST)/file: $(LISTEINC)
       #action

$(DEST)/%.inc: $(DEST)/%.jpg
      ./script $< $compteur $(DEST) > $@

如何将变量compteur设置为1(文件),2(其他文件),3(另一个文件)?

How to have the variable compteur at 1 for file, 2 for otherfile, 3 for anotherfile?

$(((compteur ++)))可以在bash脚本中工作,但是在这里我真的不知道这是什么.我尝试了$$()++ +1等的多种组合. 有人可以帮我吗?

$((compteur++)) would work in bash script, but here I really don't know what the equivalent is. I tried many combination of $$ () ++ +1 etc... Nothing worked. Anyone could help me please?

推荐答案

可以通过eval来完成:

$(eval compteur=$(shell echo $$(($(compteur)+1))))

从手册中:

eval函数非常特殊:它允许您定义新的 非恒定的makefile构造;这是由于 评估其他变量和功能.评估的论点 函数被扩展,然后将该扩展的结果解析为 makefile语法.扩展后的结果可以定义新的制造变量, 目标,隐式或显式规则等

The eval function is very special: it allows you to define new makefile constructs that are not constant; which are the result of evaluating other variables and functions. The argument to the eval function is expanded, then the results of that expansion are parsed as makefile syntax. The expanded results can define new make variables, targets, implicit or explicit rules, etc

这篇关于Makefile:如何在调用变量时增加变量? (bash中的var ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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