spe*_*ufo 11 configure autotools
是VAR=value ./configure
一样的./configure VAR=value
吗?
在第一种情况下,shell 设置环境变量,在第二种情况下,configure 脚本将字符串'VAR=value'
作为参数,然后大概设置变量。我想知道 configure 是否对变量执行了其他操作(可能会忽略或过滤某些值),以及为什么它首先将变量作为参数。
Tho*_*key 12
在这种情况下
VAR=value ./configure
Run Code Online (Sandbox Code Playgroud)
行为取决于您当前的外壳,而在此
./configure VAR=value
Run Code Online (Sandbox Code Playgroud)
行为取决于配置脚本。一些开发人员更喜欢后者,因为他们想选择是否在脚本内设置变量,而不是让某人从外部神奇地设置脚本的变量。
在实践中,几乎没有区别,因为
例如,bash 配置脚本的--help
消息显示:
Some influential environment variables:
DEBUGGER_START_FILE
location of bash debugger initialization file
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
YACC The `Yet Another C Compiler' implementation to use. Defaults to
the first program found out of: `bison -y', `byacc', `yacc'.
YFLAGS The list of arguments that will be passed by default to $YACC.
This script will default YFLAGS to the empty string to avoid a
default value of `-d' given by some make applications.
Run Code Online (Sandbox Code Playgroud)
在每种情况下,设置变量的任何一种方式都有效。
但请记住开发人员的偏好,以防有人决定“改进”事物。
进一步阅读:
./configure
config.status
AC_ARG_VAL
,从 automake 的角度(并表达开发人员的偏好):该
AC_ARG_VAR
宏用于将特定(环境)变量声明为脚本的参数,为其提供描述和特定用途。虽然在 autoconf 的历史中最近才添加了此功能,但它确实很重要。反映它最近的存在,该宏不需要AS_HELP_STRING
帮助程序,只需要两个参数:变量的名称和在 ./configure --help 期间打印的字符串:
AC_ARG_VAR(var-name, help-string)
并继续对长期实践发表评论:
默认情况下,configure 像任何其他 sh 脚本一样从环境中选取变量。其中大部分都被忽略了。那些不应该通过这个宏声明的。通过这种方式,它们被标记为一个宝贵的变量。
标记为珍贵的变量在 Makefile.in 中被替换而无需调用显式
AC_SUBST
,但这不是定义中最重要的部分。重要的是变量被缓存。
AC_ARG_VAR
,再次表达开发人员的偏好。:
启动 configure 时变量的值保存在缓存中,包括它是否不是在命令行中指定而是通过环境指定的。事实上,虽然configure 可以注意到'./configure CC=bizarre-cc' 中CC 的定义,但不可能在'CC=bizarre-cc ./configure' 中注意到它,不幸的是,这是大多数用户所做的。
归档时间: |
|
查看次数: |
4157 次 |
最近记录: |