automake 安装及使用

http://blog.csdn.net/lusehu/article/details/6415213

autotools是个系列工具,首先确认你的Ubuntu系统是否安装了以下工具(可以通过which命令查看):

    aclocal
    autoscan
    autoconf
    autoheader
    automake

  安装方法:
       root@ubuntu:~# sudo apt-get install autoconf (
我只执行了这一条安装指令  下面的使用中没有出错

  显示如下:
         正在读取软件包列表... 完成
         正在分析软件包的依赖关系树       
         正在读取状态信息... 完成       
         E: 无法找到软件包 autoscan
        将会安装下列额外的软件包:
         automake autotools-dev m4
        建议安装的软件包:
        autoconf2.13 autobook autoconf-archive gnu-standards autoconf-doc libtool
        gettext
        下列【新】软件包将被安装:
         autoconf automake autotools-dev m4
        共升级了 0 个软件包,新安装了 4 个软件包,要卸载 0 个软件包,有 28 个软件未被升级。
         需要下载 1315kB 的软件包。
         解压缩后会消耗掉 4366kB 的额外空间。
         您希望继续执行吗?[Y/n] 
        输入y,安装

 

最好一起安装它建议安装的软件包,否则autotools工具使用可能出错。

root@ubuntu:~# sudo apt-get install autotools-dev m4 autoconf2.13 autobook autoconf-archive gnu-standards autoconf-doc libtool



使用:

官方文档http://www.gnu.org/software/automake/manual/index.html

流程

第一部份:执行autoscan  修改configure.scan  成   configure.in

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

AC_PREREQ(2.68)
AC_INIT(hello,1.0)
AM_INIT_AUTOMAKE(hello,1.0)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([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])
AC_OUTPUT

第二部份:执行aclocal   执行autoconf

第三部份: 执行autoheader

第四部份: 新建makefile.am  执行automake  -a

AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c


 最后:

。/configure   make    make install   make clean



教程:

                             http://public0821.iteye.com/blog/665786

这片文章不错 : http://www.cnblogs.com/276815076/archive/2010/09/30/1839589.html

                          http://www.jcwcn.com/article-22327-1.html

文库教程: http://wenku.baidu.com/view/bcb0074669eae009581becbb.html


实例:(应注意观察每一步的执行结果是否正确,是否生成了想要的文件


实例1:精简实例很不错

(我测试过没问题 只是中间有个单词写错了

vim Makefile.am

文件内容为:

AUTOMAKE——OPTIONS=foreign

bin_PROGRAMS=hello

hello_SUORCES=hello.c  此处应为 hello_SOURCES=hello.c 

)

 http://www.cnblogs.com/276815076/archive/2010/09/30/1839589.html



实例2:(未测试,但流程正确)

http://blog.163.com/adam_mhl/blog/static/64278267200710291130488/

   建立目录:mkdir include src
    编写程序:include/str.h
        #include <stdio.h>
        int str(char *string);


    编写程序:src/str.c
       #include "str.h"
//print string
int str(char *string){
       printf("\n----PRINT STRING----\n\"%s\"\n",string);
       return 0;
}

//interface of this program
int main(int argc , char **argv){
       char str_read[1024];
       printf("Please INPUT something end by [ENTER]\n");
       scanf("%s",str_read);
       return str(str_read );
}


第一部份:(执行一条命令+修改一个文件)
3、生成configure.in
include   src
[root@localhost str]#autoscan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[root@localhost str]# ls
autoscan.log   configure.scan(上面的命令生成此文件)   include   src
[root@localhost str]# cp configure.scan configure.ac
修改 configure.scan 成 condigure.in:
1,修改AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)为
AC_INIT(str,0.0.1, [bug@sounos.org])   
(注解:FULL-PACKAGE-NAME 为程序名称,VERSION为当前版本, BUG-REPORT-ADDRESS为bug汇报地址)

2,添加AM_INIT_AUTOMAKE 
3,添加AC_CONFIG_FILES([Makefile])

修改后文件为:
#                                               -*- 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_INIT(str, 0.0.1, [bug@sounos.org])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([include/str.h])
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])
AC_OUTPUT


第二部份:(执行两条命令)
执行aclocal
[root@localhost str]# aclocal
/usr/share/aclocal/libfame.m4:6: warning: underquoted definition of AM_PATH_LIBFAME
   run info '(automake)Extending aclocal'
   or see http://sources.redhat.com/automake/automake.html#Extending-aclocal

执行autoconf
[root@localhost str]# autoconf
[root@localhost str]# ls
aclocal.m4    autoscan.log   config.h.in configure.scan   include     Makefile.am   NEWS
AUTHORS       ChangeLog     configure     COPYING       INSTALL     Makefile.in   README
autom4te.cache   compile    configure.ac   depcomp       install-sh   missing    src


第三部份(执行一条命令)

5、autoheader

root@localhost str]# autoheader



第四部份(新建文件+执行automake)
6、创建Makefile.am
[root@localhost str]# cat Makefile.am
#Makefile.am
bin_PROGRAMS = str
str_SOURCES     = include/str.h src/str.c
str_CPPFLAGS = -I include/

7、automake必须文件(可略过此步):
*   install-sh
* missing
* INSTALL
* NEWS
* README
* AUTHORS
* ChangeLog
* COPYING
* depcomp
其中
* install-sh
* missing
* INSTALL
* COPYING
* depcomp
可以通过automake -a选项自动生成,所以这里只需要建立如下文件
[root@localhost str]# touch NEWS README AUTHORS ChangeLog(也可不加这一步)
8、执行automake -a
[root@localhost str]# automake -a
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./INSTALL'
Makefile.am: installing `./COPYING'
Makefile.am: installing `./compile'
Makefile.am: installing `./depcomp'


最后一步:

10、执行测试:
执行./configure
执行 make   此时应该已经生成可执行文件,ls看一下
执行 make install
11、测试程序:#可执行文件

make clean   清除编译过程生成的文件

make uninstall   卸载


辅助知识
12. 添加测试包:make dist-gzip
13.添加一个支持子目录、静态库、自定义configure选项的包
支持子目录Makefile.am 选项 SUBDIR =
#Automake interface 
SUBDIRS = src

支持静态库Makefile.am
EXTRA_DIST   用于添加除源码外的文件到dist包
#Automake interface
bin_PROGRAMS = hello
hello_SOURCES = hello.c lib/sbase.h
hello_CPPFLAGS = -I lib
hello_LDFLAGS = -static lib/libsbase.a
EXTRA_DIST = lib/libsbase.a

configure.ac:
AC_PREREQ(2.59)
#AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_INIT(hello, 0.0.1, [SounOS@gmail.com])
#AM 声明
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.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdint.h stdlib.h sys/socket.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T

#用于自定义configure 选项,见acinclude.am
AC_CHECK_EXTRA_OPTIONS
# Checks for library functions.

AC_CONFIG_FILES([Makefile
                src/Makefile])
AC_OUTPUT

  • 6
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
安装automake,可以按照以下步骤进行操作: 1. 首先,确保你已经安装automake的相关工具。这些工具包括aclocal、autoscan、autoconf、autoheader和automake等命令。 2. 下载automake的源代码,并将其解压缩。可以使用如下命令:tar -xf automake-1.14.tar 3. 进入解压后的目录,执行configure命令来配置安装选项。你可以使用--prefix参数来指定安装位置,默认情况下会安装到/usr/local/bin下。例如:./configure --prefix=/usr/local/bin 4. 执行make命令来编译automake。这个过程可能需要一些时间,请耐心等待。例如:make 5. 最后,执行make install命令来将编译好的automake安装到指定位置。例如:make install 这样,你就成功地安装automake。请注意,这里的步骤只是一个简单的示例,实际操作中可能会有一些差异。建议参考automake的官方文档或者相关教程来获取更详细的安装指导。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [automake创建Makefile](https://blog.csdn.net/weixin_30319097/article/details/98348538)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [安装automake](https://blog.csdn.net/xnn_1993/article/details/85007380)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值