1、用vi编辑器写一个hello.c程序
[maximus@maximus src]# vim hello.c
#include <stdio.h>
int main(void)
{
printf("Hello, Auto!\n");
return 0;
}
2、使用autoscan产生一个configure.in的原型,执行之后会产生configure.scan,可以用作configure.in的文件蓝本。
[maximus@maximus src]# autoscan
[maximus@maximus src]# ls
autoscan.log configure.scan hello.c
[maximus@maximus src]# mv configure.scan configure.in
[maximus@maximus src]# ls
autoscan.log configure.in hello.c
3、编辑configure.in
原内容:
-*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
# 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_OUTPUT
修改之后内容:
-*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT(hello,0.1,[email protected])AM_INIT_AUTOMAKE(hello,0.1)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
# 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_OUTPUT(Makefile)
4、执行aclocal和autoconf,分别产生aclocal.m4和configure
[maximus@maximus src]# aclocal
aclocal.m4 autom4te.cache autoscan.log configure.in hello.c
[maximus@maximus src]# autoconf
[maximus@maximus src]# ls
aclocal.m4 autom4te.cache autoscan.log configure configure.in hello.c
5、编辑Makefile.am
[maximus@maximus src]# vi Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
6、执行autoheader
[maximus@maximus src]# autoheader
[maximus@maximus src]# ls
aclocal.m4 autoscan.log configure hello.c autom4te.cache config.h.in configure.in Makefile.am
7、执行automake –a
[maximus@maximus src]$ automake -a
configure.in:6: installing `./install-sh'
configure.in:6: installing `./missing'
Makefile.am: installing `./depcomp'
[maximus@maximus src]$ ls
aclocal.m4 config.h.in depcomp Makefile.am
autom4te.cache configure hello.c Makefile.in
autoscan.log configure.in install-sh missing
8、执行./configure
[maximus@maximus src]$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
[maximus@maximus src]$ ls
aclocal.m4 config.h.in configure.in Makefile stamp-h1
autom4te.cache config.log depcomp Makefile.am
autoscan.log config.status hello.c Makefile.in
config.h configure install-sh missing
9、执行make
[maximus@maximus src]$ make
make all-am
make[1]: Entering directory `/home/maximus/source/sample/src'
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -o hello hello.o
make[1]: Leaving directory `/home/maximus/source/sample/src'
[maximus@maximus src]$ ls
aclocal.m4 config.h.in configure.in hello.o Makefile.in
autom4te.cache config.log depcomp install-sh missing
autoscan.log config.status hello Makefile stamp-h1
config.h configure hello.c Makefile.am
10、执行程序
[maximus@maximus src]$ ./hello
Hello,Auto!
这样一个简单的automake autoconf的过程就完成了,复杂的应用以后再学习