Autoconf 学习笔记(1)

1. 建立源码目录

mkdir  hello
cd  hello
mkdir  src

2. 编辑源码

/*
 * hello.c
 *
 * 2008-01-14, mymtom
 
*/
 

#include 
< stdio.h >  

int  main( void )
{
        printf(
"Hello, Automake! ");
        
return 0;
}

3. 编写Makefile.am和src/Makefile.am

 

#
# Makefile.am
#
# 2008-01-14, mymtom


AUTOMAKE_OPTIONS 
=  foreign
SUBDIRS 
=  src

 

#
# src/Makefile.am
#
# 2008-01-14, mymtom


bin_PROGRAMS 
=  hello
hello_SOURCES 
=  hello . c

4. 运行用autoscan产生configure.scan

 

#                                                -*- Autoconf -*-
# Process this file with autoconf to produce a configure script. 


AC_PREREQ(
2.59 )
AC_INIT(FULL
- PACKAGE - NAME ,  VERSION ,  BUG - REPORT - ADDRESS)
AC_CONFIG_SRCDIR([src
/ 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
                 src
/ Makefile])
AC_OUTPUT

5. 以configure.scan为基础, 编写configure.ac

#                                                -*- Autoconf -*-
# Process this file with autoconf to produce a configure script. 


AC_INIT(hello
,   1.0 ,  mymtom @hotmail . com)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src
/ 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
                 src
/ Makefile])
AC_OUTPUT

6. 运行aclocal, autoheader, autoconf和automake

aclocal
autoheader
autoconf
automake --add-missing

7. 运行./configure

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
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 src/Makefile
config.status: creating config.h
config.status: executing depfiles commands

8. 运行make

make  all-recursive
Making all in src
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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值