参考: http://hi.baidu.com/yetao19860606/item/033148eb42fd9a3387d9de78
经常需要写一些小工具,这些工具有时候简单的就用python,性能高一点的就需要c,而我又喜欢用命令行和vi写程序,所以写makefile自然就成了麻烦中的麻烦了,不过好在可以使用automake,不过网上并没有很详细的说automake如何使用(都是东说一块西说一块的),查了一下然后整理了一下,发上来,就当自己做笔记,也方便了后面的人,高手自然自动飘过即可。
首先我们假设在这个目录下已经有一些代码了,例如main.c,我们使用automake来创建makefile,步骤如下。
1)首先在目录下运行autoscan。
2)修改configure.scan为configure.in。
3)编辑configure.in
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
# 这下面都是需要填写的内容,如包的名称,版本号和bug报告的邮箱
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([main.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_OUTPUT
我们可以看到上面的默认配置,我们修改一下配置,修改后就成了下面这个样子。
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
# 添加我们的配置,如包的名称为helloworld,版本0.1,邮箱等
AC_INIT(helloworld, 0.1, soundbbg@gmail.com)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([config.h])
# 添加一些基本配置
AM_INIT_AUTOMAKE(main, 1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
# 在这里添加输出makefile
AC_OUTPUT([makefile])
4)修改完成后退出,运行aclocal。
5)运行完成后运行autoheader
6)完成之后,我们创建一个makefile.am,并修改如下。
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=main.c
7)修改完成后运行automake –a
8) 运行 autoconf
9)运行完成后运行./configure
OK我们的makefile就生成好了,这个时候只要我们make一下就可以编译程序了。编译完成后可以运行./xxxx 来运行自己的程序。
(大致生成流程图如下:)
相关推荐
NULL 博文链接:https://lindows.iteye.com/blog/1172686
该文档是本人对automake 实现过程的一个详解说明,对初学linux下automake 的肯定有益
linux下automake用法.pdf
linux下automake用法[文].pdf
讲解linux中automake 以及makefile makefile.am makefile.in关系
依次执行命令:aclocal,libtoolize -f -c,autoconf,automake --add-missing,./configure,make。 3、cd */project/swap 依次执行命令:aclocal,autoconf,automake --add-missing,./configure,make。 4、cd *...
Linux下Makefile的automake生成全攻略
linux下的automake和autoconf.pdf 学习资料 复习资料 教学资源
Linux下Makefile的automake生成全攻略
自动创建 makefile 文件 Autoconf/Automake工具组简介
将给大家介绍如何使用autoconf和automake两个工具来帮助我们自动地生成符合自由软件惯例的Makefile,这样就可以象常见的GNU程序一样,只要使用“./configure”,“make”,“make instal”就可以把程序安装到Linux...
在linux下自动make编译的xz包,automake-1.15.tar.xz 希望可以帮助到您。
unix/linux下自动生成makefile的工具,对unix/linux初学编程,制作makefile有帮助作用
Linux系统下Automake创建工程流程,附带创建历程工程。 使用Automake创建自己的工程,方便管理及程序发布,是Linux下开源软件发布的必备工具。
怎样为你的程序创建一基于GNUAutoconf/Automake的配置脚本
自动创建makefile等编译文件,傻瓜式手把手教程,非常实用
T his book was written with GNU/Linux application developers in mind. You’ll note that topics such as the Linux kernel or device drivers are absent. This was intentional, and while they’re ...
用make命令来编译自己写的程序确实是很方便。一般情况下,大家都是手工写一个简单Makefile,如果要想写出一个符合自由软件惯例的Makefile就不那么容易了.