新闻中心

EEPW首页>嵌入式系统>设计应用> Linux下C编程基础之:使用autotools

Linux下C编程基础之:使用autotools

作者: 时间:2013-09-13 来源:网络 收藏

本文引用地址://m.amcfsurvey.com/article/257148.htm

3.6.2使用所生成的makefile

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

1.make

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

[root@localhostautomake]#make

ifgcc-DPACKAGE_NAME=\-DPACKAGE_TARNAME=\-DPACKAGE_VERSION=\-DPACKAGE_STRING=\-DPACKAGE_BUGREPORT=\-DPACKAGE=hello-DVERSION=1.0-I.-I.-g-O2-MThello.o-MD-MP-MF.deps/hello.Tpo-c-ohello.ohello.c;

thenmv-f.deps/hello.Tpo.deps/hello.Po;elserm-f.deps/hello.Tpo;exit1;fi

gcc-g-O2-ohellohello.o

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

[root@localhostautomake]#./hello

Hello!Autoconf!

2.makeinstall

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

[root@localhostautomake]#makeinstall

ifgcc-DPACKAGE_NAME=\-DPACKAGE_TARNAME=\-DPACKAGE_VERSION=\-DPACKAGE_STRING=\-DPACKAGE_BUGREPORT=\-DPACKAGE=hello-DVERSION=1.0-I.-I.-g-O2-MThello.o-MD-MP-MF.deps/hello.Tpo-c-ohello.ohello.c;

thenmv-f.deps/hello.Tpo.deps/hello.Po;elserm-f.deps/hello.Tpo;exit1;fi

gcc-g-O2-ohellohello.o

make[1]:Enteringdirectory'/root/workplace/automake'

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

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

make[1]:Nothingtobedonefor'install-data-am'.

make[1]:Leavingdirectory'/root/workplace/automake'

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

[root@localhostautomake]#hello

Hello!Autoconf!

3.makeclean

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

[root@localhostautomake]#makeclean

test-zhello||rm-fhello

rm-f*.o

4.makedist

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

[root@localhostautomake]#makedist

[root@localhostautomake]#lshello-1.0-tar.gz

hello-1.0-tar.gz

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

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

想一想

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

linux操作系统文章专题:linux操作系统详解(linux不再难懂)

上一页 1 2 3 下一页

评论


相关推荐

技术专区

关闭