【问题标题】:autotools configure error when passing options using shell variable使用 shell 变量传递选项时 autotools 配置错误
【发布时间】:2019-07-12 01:07:21
【问题描述】:

我希望从这样的 bash 脚本调用配置命令(编译 nginx):

CONF_OPTS=' --with-cc-opt="-O2 -g"'
./configure ${CONF_OPTS}

但我收到以下错误:

./configure: error: invalid option "-g"

当我通过以下选项时:

./configure --with-cc-opt="-O2 -g"

我没有错误。

复制:

curl -O  http://nginx.org/download/nginx-1.14.2.tar.gz
tar xfz nginx-1.14.2.tar.gz
cd nginx-1.14.2

OPTS='--with-cc-opt="-O2 -g"'
./configure ${OPTS}

结果

./configure: error: invalid option "-g""

但是:

./configure --with-cc-opt="-O2 -g"

没关系

我认为这与 nginx 无关,但我认为这是 bash 引用替换问题。

【问题讨论】:

    标签: bash nginx autotools configure


    【解决方案1】:

    它将像这样工作:

    $ CC_OPTS=--with-cc-opt='-O2 -g'
    $ ./configure "$CC_OPTS"
    

    以便$CC_OPTS 的扩展作为单个参数传递给./configure

    但如果你也想通过,也许:

    --with-ld-opt='-Wl,-gc-sections -Wl,-Map=mapfile'
    

    通过一个变量,你需要:

    $ CC_OPTS=--with-cc-opt='-O2 -g'
    $ LD_OPTS=--with-ld-opt='-Wl,-gc-sections -Wl,-Map=mapfile'
    $ ./configure "$CC_OPTS" "$LD_OPTS"
    

    因为您需要将两个参数传递给./configure,并且:

    ./configure "$CC_OPTS $LD_OPTS"
    

    只通过一个,将失败。

    【讨论】:

      猜你喜欢
      • 2015-10-06
      • 1970-01-01
      • 1970-01-01
      • 2013-11-08
      • 2013-04-21
      • 2013-03-05
      • 1970-01-01
      • 2016-02-07
      • 2020-12-26
      相关资源
      最近更新 更多