configure.ac (configure.in)

configure.ac (sometimes also named: configure.in) is an input file for autoconf. It contains tests that check for conditions that are likely to differ on different platforms. The tests are made by actually invoke autoconf macros.
configure.ac is processed by m4 which produces ./configure. Basically, configure.ac is copied, but macros found within configure.ac are expanded.
A configure.ac should contain the following macros:
autoscan helps create a configure.ac file by examining source files. It creates a configure.scan file which can then be changed for a configure.ac file.

Typical layout

AC_INIT(package, version, bug-report-address)
package information
program checks
library checks
header file checks
type checks
structure checks
compiler characteristics checks
library functions check
system service checks
AC_CONFIG_FILES([...])
AC_OUTPUT

Macros

AC_INIT

AC_INIT(package, version, [bug-report], [tar-name])
AC_INIT and AC_OUTPUT are the two only required macros by the configure script.
program_file is used to check wheter autoconf finds it. If it doesn't find it, it is somehow screwed up.
AC_INIT generates the following m4 macros, output variables and preprocessor symbols:
  • [AC_]PACKAGE_NAME
  • [AC_]PACKAGE_TARNAME
  • [AC_]PACKAGE_VERSION
  • [AC_]PACKAGE_STRING
  • [AC_]PACKAGE_BUGREPORT

AC_PREREQ

AC_PREREQ(version)
Indicates the version of autoconf that is used.

AM_INIT_AUTOMAKE

AM_INIT_AUTOMAKE([options])
The following form obsolete: the package and the version can be optained by AC_INIT
AM_INIT_AUTOMAKE(package, version [, no-define])
This macro is always needed for automake

AC_DEFINE

Defines a c preprocessor macro
For example AC_DEFINE(DEBUG) or AC_DEFINE(VERSION, "2.3")

AC_DEFINE_UNQUOTED

Defines a preprocessor macro with shell expansion AC_DEFINE_UNQUOTED(FOO, "${some_variable}")

AC_CHECK_LIB

Checks for a symbol within a library

AC_ARG_ENABLE

AC_OUTPUT

AC_OUTPUT(Makefile foo_config)
There should be an AC_OUTPUT for each Makefile.am in the project.
AC_INIT and AC_OUTPUT are the two only required macros by the configure script.
AC_OUTPUT generates the files that are required for the building process.
Lists the names of the files that will be output by the ./configure script.

AC_CHECK_FUNCS(func-name-1 func-name-2)

Checks if a functions exist (within the c library ???).
If they exist, it defines HAVE_func-name-n

AC_HEADERS

Defines STDC_HEADER if Ansi C header files are present. It actually assumes that the header files are present if it finds stdlib.h stdarg.h string.h and float.h.

AC_HEADERS

Checks if a header file is present. ???
If so, defines HAVE_header.

AC_EGREP_HEADER

AC_FUNC_xxx

AC_FUNC_STRFTIME

Checks if strftime exists. Includes libintl in LIBS if needed (eg for SCO).

AC_FUNC_MEMCMP

Checks if memcmp exists and is 8-bit clean.

AC_FUNC_UTIME_NULL

Checks whether utime accepts a NULL second argument to set the file change time to the current time.
See also AC_FUNC_xxx

AC_PROG_INSTALL

Generates an install target, so that it is possible to install the program with
make install
Sets INSTALL to a BSD compatible install programm, if possible. If not possible, sets it to some-dir/install-sh. In order to determine some-dir, it checkes the directories specified with AC_CONFIG_AUX_DIR.
Also sets variable INSTALL_PROGRAM to ${INSTALL} and INSTALL_DATA to ${INSTALL} -m 644.
If AC_PROG_INSTALL is used but configure cannot find an install-sh, configure will report an error.

AC_CONFIG_AUX_DIR

AC_CONFIG_HEADER

AC_CONFIG_SRCDIR

AC_CONFIG_FILES

AC_PROG_CC

Checks for a working C compiler and discovers its characteristics.

AC_PROG_CXX

Like AC_PROG_CC, but for C++ compilers.

AM_DISABLE_SHARED

AM_PROG_LIBTOOL

Used if building libraries. By default, libraries are built as shared libraries. In order to build static libraries, AM_DISABLE_SHARED needs to be defined before AM_PROG_LIBTOOL. This behaviour can be overriden with the --enable_shared and --disable_shared configure options.

AM_CONFIG_HEADER

AM_CONFIG_HEADER(config.h)
AM_CONFIG_HEADER(config.h:config.in)
It may optionally name the input file for the output file, by default this is config.h.in, however, this works poorly on dos.
Names the header file which will hold the preprocessor macro definitions for compile time. Normally, this is config.h. The source files will then #include "config.h".
Generates a portability header file, requires a accconfig.h file.
???? Use AC_CONFIG_HEADER instead of AM_CONFIG_HEADER if you're not using automake. ????
??? In order to use AM_CONFIG_HEADER, a stamp-h file is needed ???.

AM_MAINTAINER_MODE

AC_EXEEXT

Always present in Cygnus configure scripts, finds the executable suffix on the system (.exe for windows, empty for unix).

AC_STRUCT_TM

Defines TM_IN_SYS_TIME if <time
`configure.ac` 文件是一个用于生成 `configure` 脚本的模板文件,通常位于开源项目的根目录中。这个 `configure` 脚本用于检测系统环境并配置项目以适应该环境,它是由 `autoconf` 工具处理 `configure.ac` 文件生成的。要运行 `configure.ac` 文件,你需要遵循以下步骤: 1. 安装 `autoconf` 和 `automake` 工具(如果尚未安装): - 在Debian/Ubuntu系统上,可以使用命令 `sudo apt-get install autoconf automake` 安装。 - 在Red Hat/CentOS系统上,可以使用命令 `sudo yum install autoconf automake` 安装。 - 在macOS上,可以使用Homebrew通过命令 `brew install autoconf automake` 安装。 2. 打开终端,切换到包含 `configure.ac` 文件的目录。 3. 执行以下命令生成 `configure` 脚本: ``` aclocal && autoconf && autoheader && automake --add-missing --foreign ``` 这些命令的含义如下: - `aclocal`:生成 `aclocal.m4` 文件,它是 `autoconf` 的宏文件。 - `autoconf`:根据 `configure.ac` 文件生成 `configure` 脚本。 - `autoheader`:生成用于生成 `Makefile.in` 模板文件的 `config.h.in` 文件。 - `automake`:生成 `Makefile.in` 文件,这些文件用于 `make` 命令编译项目。 4. 在项目根目录中,你将看到生成的 `configure` 脚本。运行此脚本,可以按如下方式: ``` ./configure [选项] ``` 其中 `[选项]` 是一些可选的参数,比如 `--prefix=/指定目录` 用于指定安装路径等。 确保你在一个有足够权限的环境中操作,特别是在安装软件时,可能需要管理员权限。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值