自动化构建:从 Autoconf 到 Automake
1. AC_OUTPUT 宏详解
AC_OUTPUT 宏是配置过程中的关键部分,在 configure 文件里,它会展开成基于之前宏展开数据生成 config.status 脚本的 shell 代码。所有其他宏必须在 AC_OUTPUT 展开之前使用,不然对生成的 configure 脚本价值不大。虽然可以在 configure.ac 里 AC_OUTPUT 之后添加额外的 shell 脚本,但这不会影响 config.status 执行的配置和文件生成操作。
为了让用户清楚构建系统基于指定命令行选项的配置情况,可以在 AC_OUTPUT 之后添加 shell 的 echo 或 print 语句,还能告知用户 make 的其他有用目标。例如:
AC_OUTPUT echo \ "------------------------------------------------- ${PACKAGE_NAME} Version ${PACKAGE_VERSION} Prefix: '${prefix}'. Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}' Package features: Async Execution: ${async_exec} Now type 'make @<:@<target>@:>@' where the optional <target> is: all - build all binaries inst