简单源代码包的制做

本文 软件以“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
添加,修改如下几行,其余的注释掉。
AC_INIT(hello.c) //括号内为您的源代码.
AC_PROG_CC
AM_INIT_AUTOMAKE(hello,1.0) //括号内hello为文档名,1.0为版本号.
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.本身编写makefile.am文档。
shell>vi makefile.am
此文档格式为:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
固然,有兴趣您也可对makefile.am文档进行扩展。
7.用automake --add-missing加入一些生成标准的 软件包所必需的文档。 shell>automake --add-missing 8.执行configure文档。 会生成make所需的makefile及其余文档。 shell>./configure 9.用make编译,后已生成可执行文档hello,但只能在当前目录下用./执行。要想在任何目录都能执行,还要进行make install.下述。 shell>make 10.make install,将可执行文档写入/usr/local/bin下。 shell>make install 11.最后一步,打包。会生成 .tar.gz的包,注意,这个包并不是是用tar命令生成的。 shell>make dist 至此,一个简单的源代码包制做完毕。ls 看一下,会有一个hello-1.tar.gz的源代码包生成了。 rocky