如何在makefile中的perl one liner中命名默认变量

时间:2013-12-02 19:07:42

标签: perl makefile swig

我在运行下面的Makefile代码时遇到了困难:

SWIG = swig

SWIG_VER      = $(shell $(SWIG) -version 2>&1 | head -2 | tail -1 | cut -d' ' -f3)
SWIG_VER_NUM  = $(shell echo $(SWIG_VER) | tr -d '.' | perl -lne 'chomp;while(length($$_)<4){$$_*=10}; print')
SWIG_VER_TEST = $(shell if [ $(SWIG_VER_NUM) -lt 1334 ]; then echo 1; else echo 0; fi)

获取以下错误:

Bareword found where operator expected at -e line 1, near "/usr/bin"
    (Missing operator before bin?)
syntax error at -e line 1, near "/usr/bin"
syntax error at -e line 1, near ";}"
Execution of -e aborted due to compilation errors.
/bin/sh: line 0: [: -lt: unary operator expected

可能错误地转义了perl的默认变量......

注意:

SWIG版本输出(包括新行):

> swig -version

SWIG Version 2.0.1

Compiled with g++ [x86_64-unknown-linux-gnu]

Configured options: +pcre

Please see http://www.swig.org for reporting bugs and further information

SWIG_VER行输出:

> swig -version 2>&1 | head -2 | tail -1 | cut -d' ' -f3
2.0.1

0 个答案:

没有答案