一.创建t.c文件
#include <stdio.h>
int main(){
printf("hello word\n");
}
二.自动编译环境配置
1.命令:autoscan
生成autoscan.log configure.scan
2.将configure.scan 修改为 configure.ac
//变更前
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([add.h])
AC_CONFIG_HEADERS([config.h])
//变更后
AC_INIT([t1], [1.0], [xie_jin_cheng@qq.com])
AC_CONFIG_SRCDIR([t1.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_FILES([Makefile])
3.命令:aclocal
aclocal.m4 和 autom4te.cache 文件夹添加
4.命令:autoheader
config.h.in 文件添加
5.创建 Makefile.am 添加如下内容
bin_PROGRAMS = t1
main_SOURCES = t1.c
6.命令 autoreconf -i 生成脚本
install-sh Makefile.in compile configure depcomp missing
7 执行脚本:./configure
Makefile 等文件生成
8 命令:make
9 ./t1
三.相关链接
automake安装及使用
https://blog.youkuaiyun.com/qq_44861043/article/details/132542507
GNU autotools(四)编写configure.ac
https://www.jianshu.com/p/cdffbe435a51
Makefile/Makefile.am/Makefile.in三者关系
https://blog.youkuaiyun.com/tianya_lu/article/details/105862306/
C、C++项目中 configure、makefile.am、makefile.in、makefile 之间的关系
https://blog.youkuaiyun.com/B11050729/article/details/132282316
四.附件
AC_INIT介绍
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_INIT是Autoconf的宏,用于初始化配置过程。它需要三个参数:
FULL-PACKAGE-NAME:完整的软件包名称。
VERSION:软件包的版本号。
BUG-REPORT-ADDRESS:软件包的报告缺陷的邮箱地址。
举例:AC_INIT([t1], [1.0], [myemail@example.com])