AutoTools 简单应用

Jump to: navigation, search

简述

本文将演示使用autotools的方法

下载

准备

在自己准备的路径下建立目录,例如:

mkdir auto

cd auto

mkdir test

cd test

写c文件

例如将写一个autotool文件

  1. include <stdio.h>

void main()

{

 printf("Welcome to use AutoTools!");

}


产生configure文件

产生一个 configure.in 的原型,产生configure.scan.   % autoscan

% ls

configure.scan autotool.c

2.edit configure.scan 内容如下


AC_INIT(autotool.c)

AM_INIT_AUTOMAKE(autotool, 1.0)

AC_PROG_CC

AC_OUTPUT(Makefile)

3.产生 aclocal.m4 及 configure

% aclocal

% Autoconf

% ls

aclocal.m4 configure configure.in autotool.c

产生makefile

1.编辑 Makefile.am 文件

bin_PROGRAMS= autotool

autotool_SOURCES= autotool.c

2. 执行 Automake --add-missing

% Automake --add-missing

Automake: configure.in: installing `./install-sh'

Automake: configure.in: installing `./mkinstalldirs'

Automake: configure.in: installing `./missing'

3. 执行 ./configure:

% ./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: executing depfiles commands

实验

% make

. autoscan.log configure.in autotool.c Makefile.am

.. config.log depcomp autotool.o Makefile.in

aclocal.m4 config.status .deps install-sh missing

autom4te.cache configure autotool Makefile


此时就已经成功完成!