Automake简单使用
这是一个HelloWorld!例子
一.准备三个文件,放在一个文件夹中,如hello
1. main.c //源程序
liuyc@ubuntu:~/Desktop/hello$cat main.c
#include<stdio.h>
void main()
{
printf("HelloWorld!\n");
}
2. Makefile.am //make需要的文件
liuyc@ubuntu:~/Desktop/hello$cat Makefile.am
bin_PROGRAMS= hello
hello_SOURCES= main.c
3. configure.ac //配置文件
liuyc@ubuntu:~/Desktop/hello$cat configure.ac
AC_INIT([hello],[1.0], [bug-automake@gnu.org])
AM_INIT_AUTOMAKE([-Wall-Werror foreign])
AC_PROG_CC
AC_OUTPUT([Makefile
])
二.该目录下执行autoreconf –install
liuyc@ubuntu:~/Desktop/hello$autoreconf --install
configure.ac:3:installing './compile'
configure.ac:2:installing './install-sh'
configure.ac:2:installing './missing'
Makefile.am:installing './depcomp'
三.该目录下执行./configure
checkingfor a BSD-compatible install... /usr/bin/install -c
checkingwhether build environment is sane... yes
checkingfor a thread-safe mkdir -p... /bin/mkdir -p
checkingfor gawk... no
checkingfor mawk... mawk
checkingwhether make sets $(MAKE)... yes
checkingwhether make supports nested variables... yes
checkingfor gcc... gcc
checkingwhether the C compiler works... yes
checkingfor C compiler default output file name... a.out
checkingfor suffix of executables...
checkingwhether we are cross compiling... no
checkingfor suffix of object files... o
checkingwhether we are using the GNU C compiler... yes
checkingwhether gcc accepts -g... yes
checkingfor gcc option to accept ISO C89... none needed
checkingwhether gcc understands -c and -o together... yes
checkingfor style of include used by make... GNU
checkingdependency style of gcc... gcc3
checkingthat generated files are newer than configure... done
configure:creating ./config.status
config.status:creating Makefile
config.status:executing depfiles commands
四.已经生成Makefile.in文件,可以执行make操作
liuyc@ubuntu:~/Desktop/hello$make
gcc-DPACKAGE_NAME=\"hello\" -DPACKAGE_TARNAME=\"hello\"-DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"hello\ 1.0\"-DPACKAGE_BUGREPORT=\"bug-automake@gnu.org\"-DPACKAGE_URL=\"\" -DPACKAGE=\"hello\"-DVERSION=\"1.0\" -I. -g-O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv-f .deps/main.Tpo .deps/main.Po
gcc -g -O2 -o hello main.o
五.执行hello,完成
liuyc@ubuntu:~/Desktop/hello$./hello
HelloWorld!
参考网站:
http://www.gnu.org/software/automake/manual/automake.html#Hello-World
其他:
Ubuntu版本:14.04.1 64位 虚拟机中
Automake版本: 2.69