2. 进入项目根目录
执行流程图:
a. autoscan-->"configure.scan"
b. mv configure.scan [configure.in|configure.ac]
c. vim [configure.in|configure.ac]
d. vim Makefile.am [for each src dir]
e. aclocal -----|
d. autoconf -----|-----> "configure"
f. automake -a --------> "Makefile.in" [for each src dir]
g. ./configure --arguments ----> Makefile [for each src dir]
h. make
i. make install
f. make dist -----"xxxx.tar.gz"
2.1 编写configure.in
整个configure.in[ac]文件的编写过程按以下步骤。
2.1.0 文件模板:
#步骤一: 项目初始化设置 project init set
AC_INIT(file)
#步骤五: 项目编译期检查 project compile checks
#checks for programs
#checks for libraries
#checks for header files
#checks for typedefs
#checks for structures
#checks for compiler characteristics
#checks for library functions
#checks for system services
#步骤二: 项目选项设置 project custom options set
#步骤三: 项目选项变量导出 options varies export to makefile
#步骤四: 项目文件输出设置 project outputs file set
AC_OUTPUT([file...])
2.1.1 步骤一: 项目初始化设置
2.1.1.1 初始化设置 必填项
AC_INIT (package, version, [bug-report], [tarname])
2.1.1.2 项目文件验证, 选填项
AC_CONFIG_SRCDIR (unique-file-in-source-dir)
项目目录Makefile.am:
if COND_OPT
MAYBE_OPT = opt
endif
SUBDIRS = common $(MAYBE_OPT) exe .
注:
定义SUBDIRS只是对 make all有效, 会根据用户的设置判断是否需要进行opt目录编译。
如果使用 make dist 命令,则 所有子目录都会递归执行。
Automake 会自动定义 DIST_SUBDIRS = common opt exe .
方法二:通过AC_SUBST宏定义输出变量
configure.ac
if test "$want_opt" = yes; then
MAYBE_OPT=opt
else
MAYBE_OPT=
fi
AC_SUBST([MAYBE_OPT])
AC_CONFIG_FILES([Makefile common/Makefile opt/Makefile exe/Makefile])
项目目录Makefile.am:
SUBDIRS = common $(MAYBE_OPT) exe .