Automake簡單使用,網上很多的都報錯,參考官方文檔改了一些,行了

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], [[email protected]])

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=\"[email protected]\"-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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章