【发布时间】:2014-01-23 20:44:48
【问题描述】:
我正在编写一个名为run.mk的简单makefile,如下代码所示。
a = 0
b := $(shell echo `expr $(a) + 1`)
app: main.o
gcc -o app main.o
main.o: main.c
gcc -c main.c
test:
while [ $(a) -lt 10 ];\
do\
echo $(a);\
a:= $(shell echo `expr $(a) + 1`);\
echo $(a);\
done
当我使用命令 make -f run.mk test 运行此 makefile 时,出现错误:a not found 并且循环无限运行,即变量 a 的值未更新在 a:= $(shell echo expr $(a) + 1) 在 while 循环中。但是在开始时,变量 b 的值通过相同的代码行 $(shell echo expr $(a) + 1) 设置为 1。有人请告诉如何在循环中更新变量 a 的值。
谢谢。
【问题讨论】:
-
借助 GNU make 4.0,您可以使用 Guile 来做复杂的事情。
标签: c linux variables makefile