使用automake生成静态库

一. 主函数Makefile创建


1. autoscan->生成 configure.scan 和 autoscan.log


2.将configure.scan 修改为 configure.in:
并修改configure.in内容如下
  # Process this file with autoconf to produce a configure script.
    AC_INIT(hello.c)
    AM_INIT_AUTOMAKE(hello, 1.0)
  # Checks for programs.
    AC_PROG_CC
  # Checks for library functions.
    AC_OUTPUT(Makefile)


3. aclocal
->生成 aclocal.m4 和 autom4te.cache (生成aclocal.m4的过程中涉及到configure.in)


4. autoconf
->生成 configure (根据 configure.in, 和 aclocal.m4)


5. autoheader
        ->生成 config.h.in 宏定义


6. 编写Makefile.am


   AUTOMAKE_OPTIONS=foreign
   INCLUDES=-I../include
   bin_PROGRAMS=hello
   hello_SOURCES=hello.c
   hello_LDADD=../lib/libhello.a


7. touch NEWS AUTHORS README ChangeLog 


8. automake --add-missing
->生成 Makefile.in, depcomp, install-sh, 和 missing (根据 Makefile.am, 和 aclocal.m4)


9. ./configure
->生成 Makefile, config.log, 和 config.status


10. make


二. 静态库Makefile创建


1. configure.in创建


   # configure.in
   # Process this file with autoconf to produce a configure script.
     AC_PREREQ(2.59)
     AC_INIT(libhello.a,1.1,[])
     AM_INIT_AUTOMAKE
   # Checks for programs.
     AC_PROG_CC
   # Checks for libraries.
     AC_PROG_RANLIB//需要加入的内容,因为使用了静态库
   # Checks for header files.
   # Checks for typedefs, structures, and compiler characteristics.
   # Checks for library functions.
     AC_OUTPUT([Makefile])
     AC_INIT(FILE)


   #Makefile.am
   AUTOMAKE_OPTIONS=foreign
   noinst_LIBRARIES=libhello.a
   libhello_a_SOURCES=test.c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值