1. 安装相关工具 : sudo apt-get install autoconf
2.自动生成Makefile
(1)运行 autoscan命令
(2)重命名configure.scan为configure.ac,并且修改其相关内容
(3)运行 aclocal命令
(4)运行 autoheader命令
(5)运行autoconf命令
(6)在项目目录下创建Makefile.am文件,并且修改
(7)运行automake --add-missing命令
(8)运行configure生成Makefile。
修改如下:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
2.自动生成Makefile
(1)运行 autoscan命令
(2)重命名configure.scan为configure.ac,并且修改其相关内容
(3)运行 aclocal命令
(4)运行 autoheader命令
(5)运行autoconf命令
(6)在项目目录下创建Makefile.am文件,并且修改
(7)运行automake --add-missing命令
(8)运行configure生成Makefile。
3.具体过程
原测试文件main.c
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("\nRun successfully\n");
return 0;
}
(1)运行 autoscan
autoscan.log configure.scan main.c
(2)运行
mv configure.scan configure.ac
修改如下:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([test], [1.0], [test@163.com])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(test,1.0])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
(3)运行 aclocal
aclocal.m4 autom4te.cache autoscan.log configure.ac main.c
(4)运行 autoheader
aclocal.m4 autom4te.cache autoscan.log config.h.in configure.ac main.c
(5)运行 autoconf
aclocal.m4 autom4te.cache autoscan.log config.h.in configure configure.ac main.c
(6)创建 Makefile.am文件
AUTOMARK_OPTIONS=foreign
noinst_PROGRAMS=test
HelloWorld_SOURCES=main.c
(7)运行 touch NEWS README AUTHORS ChangeLog 和 automake --add-missing
aclocal.m4 autom4te.cache ChangeLog config.h.in configure.ac depcomp install-sh Makefile.am missing README
AUTHORS autoscan.log compile configure COPYING INSTALL main.c Makefile.in NEWS
(8)运行 ./configure
aclocal.m4 autom4te.cache ChangeLog config.h config.log configure COPYING INSTALL main.c Makefile.am missing README
AUTHORS autoscan.log compile config.h.in config.status configure.ac depcomp install-sh Makefile Makefile.in NEWS stamp-h
(9)运行 make
aclocal.m4 autoscan.log config.h config.status COPYING install-sh Makefile missing stamp-h1
AUTHORS ChangeLog config.h.in configure depcomp main.c Makefile.am NEWS test
autom4te.cache compile config.log configure.ac INSTALL main.o Makefile.in README
(10)运行 test
~/tmp/c/test$ ./test
Run successfully