步驟:
1)編輯源代碼文件
2)執行autoscan
3)改名configure.scan文件爲configure.in並修改內容
4)執行aclocal
5)執行autoconf
6)執行autoheader
7)新建編輯Makefile.am文件
8)執行automake --add-missing
所有操作命令流程如下
[root@localhost Mediu]# mkdir autoMakeTest
[root@localhost Mediu]# cd autoMakeTest/[root@localhost autoMakeTest]# vi hello.c
#include<stdio.h>
int main(int argc,char **argv)
{
printf("\nMy first automake Test!\n");
return 0;
}
[root@localhost autoMakeTest]# autoscan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[root@localhost autoMakeTest]# ls
autoscan.log configure.scan hello.c
[root@localhost autoMakeTest]# mv configure.scan configure.in
[root@localhost autoMakeTest]# vi configure.in
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello,0.0.1)
AM_INIT_AUTOMAKE(hello,0.0.1)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([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_CONFIG_FILES([Makefile])
AC_OUTPUT
[root@localhost autoMakeTest]# aclocal
[root@localhost autoMakeTest]# ls
aclocal.m4 autom4te.cache autoscan.log configure.in hello.c
[root@localhost autoMakeTest]# autoconf
[root@localhost autoMakeTest]# ls
aclocal.m4 autom4te.cache autoscan.log configure configure.in hello.c
[root@localhost autoMakeTest]# autoheader
[root@localhost autoMakeTest]# ls
aclocal.m4 autoscan.log configure hello.c
autom4te.cache config.h.in configure.in
[root@localhost autoMakeTest]# vi Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
~
[root@localhost autoMakeTest]# ls
aclocal.m4 autoscan.log configure hello.c
autom4te.cache config.h.in configure.in Makefile.am
[root@localhost autoMakeTest]# automake --add-missing
configure.in: installing `./install-sh'
configure.in: installing `./missing'
Makefile.am: installing `./depcomp'
[root@localhost autoMakeTest]# ls
aclocal.m4 autoscan.log configure depcomp install-sh Makefile.in
autom4te.cache config.h.in configure.in hello.c Makefile.am missing
[root@localhost autoMakeTest]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
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 ANSI C... 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
[root@localhost autoMakeTest]# ls
aclocal.m4 config.h config.status depcomp Makefile missing
autom4te.cache config.h.in configure hello.c Makefile.am stamp-h1
autoscan.log config.log configure.in install-sh Makefile.in
[root@localhost autoMakeTest]# make
make all-am
make[1]: Entering directory `/home/boylove1/Mediu/autoMakeTest'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi
gcc -g -O2 -o hello hello.o
make[1]: Leaving directory `/home/boylove1/Mediu/autoMakeTest'
[root@localhost autoMakeTest]# 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
[root@localhost autoMakeTest]# ./hello
My first automake Test!
[root@localhost autoMakeTest]#