如何将变量传递给make命令?

时间:2020-08-31 20:10:39

标签: makefile

我的makefile文件带有:

zvals: resize
    zMin=$$(gdalinfo -mm ./crop_xl.tmp.tif | sed -ne 's/.*Computed Min\/Max=//p'| tr -d ' ' | cut -d "," -f 1 | cut -d . -f 1);\
    zMax=$$(gdalinfo -mm ./crop_xl.tmp.tif | sed -ne 's/.*Computed Min\/Max=//p'| tr -d ' ' | cut -d "," -f 2 | cut -d . -f 1);\
    echo Altidutes range: $$zMin $$zMax
    python ../script/slice.py $$zMin $$zMax $(SLICES) > ./slices.tmp.txt

最后一行失败,因为$$zMin中的$$zMaxpython ../script/slice.py $$zMin $$zMax $(SLICES) > ./slices.tmp.txt为空,并且无法为python命令提供任何数字。

同时,$$zMin中的$$zMaxecho Altidutes range: $$zMin $$zMax完全相同,可以正确打印Altidutes range: -

Hack

我的“ hack”是通过每行末尾的系统;\内联所有代码:

zvals: resize
    zMin=$$(gdalinfo -mm ./crop_xl.tmp.tif | sed -ne 's/.*Computed Min\/Max=//p'| tr -d ' ' | cut -d "," -f 1 | cut -d . -f 1);\
    zMax=$$(gdalinfo -mm ./crop_xl.tmp.tif | sed -ne 's/.*Computed Min\/Max=//p'| tr -d ' ' | cut -d "," -f 2 | cut -d . -f 1);\
    echo Altidutes range: $$zMin $$zMax;\
    python ../script/slice.py $$zMin $$zMax $(SLICES) > ./slices.tmp.txt

然后在python命令中定义$$zMin$$zMax,因此它们会接收所需的值并且可以正常工作。

评论和问题

这对我来说似乎很丑。 我应该如何正确地将值传递给我的Makefile中的最后一个python命令?

0 个答案:

没有答案