首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 开源 FAQ 第二书店 博文视点 程序员
频道: 研发 数据库 中间件 信息化 视频 .NET Java 游戏 移动 服务: 人才 外包 培训
    图书品种:235680
       
热门搜索: ASP.NET Ajax Spring Hibernate Java

3.7.2  使用autotools所生成的Makefile

autotools生成的Makefile除具有普通的编译功能外,还具有以下主要功能(感兴趣的读者可以查看这个简单的hello.c程序的makefile):

1make

键入make默认执行”make all”命令,即目标体为all,其执行情况如下所示:

 

[root@localhost automake]# make

if Gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"hello\" -DVERSION=\"1.0\"  -I. -I.     -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \

then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi

Gcc  -g -O2   -o hello  hello.o

此时在本目录下就生成了可执行文件“hello”,运行“./hello”能出现正常结果,如下所示:

 

[root@localhost automake]# ./hello

Hello!Autoconf!

2make install

此时,会把该程序安装到系统目录中去,如下所示:

 

[root@localhost automake]# make install

if Gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"hello\" -DVERSION=\"1.0\"  -I. -I.     -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \

then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi

Gcc  -g -O2   -o hello  hello.o

make[1]: Entering directory '/root/workplace/automake'

test -z "/usr/local/bin" || mkdir -p -- "/usr/local/bin"

  /usr/bin/install -c 'hello' '/usr/local/bin/hello'

make[1]: Nothing to be done for 'install-data-am'.

make[1]: LeaVing directory '/root/workplace/automake'

 

此时,若直接运行hello,也能出现正确结果,如下所示:

 

[root@localhost automake]# hello

Hello!Autoconf!

3make clean

此时,make会清除之前所编译的可执行文件及目标文件(object file, *.o),如下所示:

 

[root@localhost automake]# make clean

test -z "hello" || rm -f hello

rm -f *.o

4make dist

此时,make将程序和相关的文档打包为一个压缩文档以供发布,如下所示:

 

[root@localhost automake]# make dist

[root@localhost automake]# ls hello-1.0-tar.gz

hello-1.0-tar.gz

 

可见该命令生成了一个hello-1.0-tar.gz的压缩文件。

由上面的讲述读者不难看出,autotools确实是软件维护与发布的必备工具,也鉴于此,如今GUN的软件一般都是由automake来制作的。

 

*

想一想

对于automake制作的这类软件,应如何安装呢?

查看所有评论(0)条】

最近评论



正在载入评论列表...
热点评论