Chinaunix首页 | 论坛 | 博客
  • 博客访问: 421047
  • 博文数量: 247
  • 博客积分: 185
  • 博客等级: 入伍新兵
  • 技术积分: 1005
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-10 10:39
文章分类

全部博文(247)

文章存档

2015年(3)

2014年(21)

2013年(53)

2012年(170)

分类:

2012-12-12 14:39:11

本文软件以“hello world”程软件式为例,简单说明linux下源代码包(.tar.gz)的制作。当然,本身把hello world制作成源代码包是没什么意义的。在此,谨以说明源代码包的制作过程。
首先,确保您的系统装有以下GNU软件:
Automake
Autoconf
m4
perl
libtool

1.新建一目录,将您的源代码放在此目录下,以下的操作均在此目录里进行。
shell> mkdir hello
2.执行autoscan命令来扫描源代码。
shell>autoscan
执行该命令后会生成configure.scan 和configure.log文档。
3.修改configure.scan文档。
shell>vi configure.scan
添加,修改以下几行,其他的注释掉。
[root@EmbedSky hello]# cat configure.in
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
#AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])

AC_INIT([hello], [1.0], [672528110@qq.com])
AM_INIT_AUTOMAKE(hello,1.0)//括号内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_OUTPUT(Makefile)//在括号内加入makefile.

保存文档,并修改此文档名为configure.in
shell>mv configure.scan configure.in
4.运行aclocal命令,之后会生成aclocal.m4文档。
shell>aclocal
5.运行autoconf命令,之后会生成autom4te.cache目录和configure可执行文档。
shell>autoconf

6.autoheader命令生成config.h.in

    $ autoheader通过autoheader命令,我们就可以得到config.h.in这个东东了。有了它,./configure才会生成config.h这个东东,所以不可大意。

autoheader这个工具通常会从“acconfig.h”文件中复制用户附加的符号定义,因此此处没有附加符号定义,所以不需要创建“acconfig.h”文件。


7.自己编写makefile.am文档。
shell>vi makefile.am
此文档格式为:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
当然,有兴趣您也可对makefile.am文档进行扩展。
8.用automake --add-missing或者 automake a加入一些生成标准的软件包所必需的文档。
shell>automake --add-missing
9.执行configure文档。 会生成make所需的makefile及其他文档。
shell>./configure
10.用make编译,后已生成可执行文档hello,但只能在当前目录下用./执行。要想在任何目录都能执行,还要进行make install.下述。
shell>make
11.make install,将可执行文档写入/usr/local/bin下。
shell>make install
12.最后一步,打包。会生成 .tar.gz的包,注意,这个包并非是用tar命令生成的。
shell>make dist
至此,一个简单的源代码包制作完毕。ls 看一下,会有一个hello-1.tar.gz的源代码包生成了。
阅读(194) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~