GCC使用configure.ac(通过autoconf)来生成configure文件。configure.ac顶层目录下的configure.ac有三千多行,用来在配置阶段做各种测试检测,并将结果替换到Makefile.in中,生成最终的Makefile。本文简单介绍了configure.ac中所要做的事请,并没有覆盖所有的细节问题。
1、导出原始的configure参数
progname=$0
# if PWD already has a value, it is probably wrong.
if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi
# Export original configure arguments for use by sub-configures.
# Quote arguments with shell meta charatcers.
TOPLEVEL_CONFIGURE_ARGUMENTS=
set -- "$progname" "$@"
for ac_arg
do
case "$ac_arg" in
*" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\']]*)
ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
# if the argument is of the form -foo=baz, quote the baz part only
ac_arg=`echo "'$ac_arg'" | sed "s/^'\([[-a-zA-Z0-9]]*=\)/\\1'/"` ;;
*) ;;
esac
# Add the quoted argument to the list.
TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
done
if test "$silent" = yes; then
TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
fi
# Remove the initial space we just introduced and, as these will be
# expanded by make, quote '$'.
TOPLEVEL_CONFIGURE_ARGUMENTS=`echo "x$TOPLEVEL_CONFIGURE_ARGUMENTS" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS)
这部分代码位于38-64行,用来将configure的参数保存到变量TOPLEVEL_CONFIGURE_ARGUMENTS中,以供子目录的configure使用。
2、一些基本的测试
# Find the build, host, and target systems. ACX_NONCANONICAL_BUILD ACX_NONCANONICAL_HOST ACX_NONCANONICAL_TARGET ... ... AC_CANONICAL_SYSTEM AC_ARG_PROGRAM m4_pattern_allow([^AS_FOR_TARGET$])dnl m4_pattern_allow([^AS_FOR_BUILD$])dnl # Get 'install' or 'install-sh' and its variants. AC_PROG_INSTALL ACX_PROG_LN AC_PROG_LN_S AC_PROG_SED AC_PROG_AWK ...
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-39818-1.html
装备落后的体现以及人员素质低于日本人的体现