手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

一个用Autotools生成Makefile的简单例子

[日期:2009-10-12] 来源:purpleroom.blog.sohu.com  作者:purpleroom [字体:大 中 小]

1. 建立auto文件夹,写两个简单代码文件:hello.c, hello.h

2. 使用命令autoscan 生成configure.scan  

3. 修改configure.scan如下 (添加红色部分),将修改后的configure.scan重命名为configure.in
AC_PREREQ([2.63])
#AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])

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

4. 使用命令aclocal生成aclocal.m4 和 autom4te.cache

5. 使用命令autoconf生成configure

6. 使用autoheader生成config.h.in

7. 用Vi编辑Makefile.am文件如下:

             AUTOMAKE_OPTIONS=foreign
              bin_PROGRAMS=hello
               hello_SOURCES=hello.c hello.h

 8. 运行automake如下:

$ automake --add-missing

9. 运行./configure
10. 运行 make
11. 运行./hello
12.运行make install
13.运行hello
14. 运行:make dist
15.  在当前目录下解压hello-1.0.tar.gz:
      tar -zxvf hello-1.0.tar.gz
16. 进入目录:hello-1.0
17. 下面开始Linux常见的安装步骤:
       ./configure
18. 运行:make
19. 运行:./hello
20. 运行:make install
21. 运行:hello

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款