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

Linux下AutoTools工具集使用教程

[日期:2012-11-20] 来源:Linux社区  作者:Linux [字体:大 中 小]

使用make命令

产生了makefile后我们就要使用make工程管理器去实现makefile的制定。

1、make

make默认执行make all命令,其执行情况如下所示:

[root@localhosthello]# make

make all-am

make[1]: Entering directory `/root/hello'

if gcc -DHAVE_CONFIG_H -I.-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]: Leaving directory `/root/hello'

如果之前makefile操作无误,那么执行make命令会出现上面这段执行内容,而且会在目录下生成hello可执行文件,运行hello程序:

[root@localhosthello]# ./hello

Hello,Make!

2、make install

把hello程序安装到系统目录中去:

[root@localhosthello]# make install

make[1]: Entering directory `/root/hello'

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/hello'

此时,若直接运行hello能出现如下结果就说明操作正确:

[root@localhosthello]# hello

Hello,Make!

3、make clean

此命令是清除之前所编译的可执行文件及目标文件(object file, *.o):

[root@localhosthello]# make clean

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

rm -f *.orm -f*.o

4、make dist

当我们做好了一切工作,最后一步是压缩文档以供发布:

[root@localhost hello]# make dist

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

hello-1.0.tar.gz

hello-1.0-tar.gz就是我们最终要发布的压缩文件。autoTools的整个流程都介绍完毕,现实中更多会用到autoTools来为我们生成makefile文档。

小结

本章介绍了make工程管理器的命令、作用和怎样编写简单实用的makefile,并且还讨论了make规则和make的一些有用的命令行选项。通过学习本章,同学们应该已经能够使用make来管理软件项目的的创建和维护过程了。

linux
相关资讯       Autotools   Linux使用教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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