Configure,Makefile.am, Makefile.in, Makefile文件之间关系
2016-05-05 15:08
686 查看
1.autoscan(autoconf):扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。
yoursourcefiles-->[autoscan*]-->[configure.scan]-->configure.ac
2.aclocal(automake):根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件aclocal.m4中。aclocal是一个perl脚本程序,它的定义是:“aclocal-createaclocal.m4byscanningconfigure.ac”
4.automake:automake将Makefile.am中定义的结构建立Makefile.in,然后configure脚本将生成的Makefile.in文件转换为Makefile。如果在configure.ac中定义了一些特殊的宏,比如AC_PROG_LIBTOOL,它会调用libtoolize,否则它会自己产生config.guess和config.sub
5.autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。
实例:
在/hello/目录下创建一个hello.c文件,并编译运行它:
#cd/hello/
(1)编写源文件hello.c:
#include<stdio.h>
intmain(intargc,char**argv)
{
printf("Hello,GNU!n");
return0;
}
[litao@vm0000131hello]$ll
total4
-rw-rw-r--1litaolitao68Aug1212:02hello.c
一、autoscan
[litao@vm0000131hello]$autoscan
autom4te:configure.ac:nosuchfileordirectory
autoscan:/usr/bin/autom4tefailedwithexitstatus:1
[litao@vm0000131hello]$ll
total8
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rw-rw-r--1litaolitao457Aug1212:03configure.scan
-rw-rw-r--1litaolitao68Aug1212:02hello.c
已经生成了configure.scan,autoscan.log文件
将configure.scan修改为configure.in,最后修改的内容如下:
[litao@vm0000131hello]$mvconfigure.scanconfigure.in
[litao@vm0000131hello]$vimconfigure.in
#-*-Autoconf-*-
#Processthisfilewithautoconftoproduceaconfigurescript.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME,VERSION,BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([hello.c])
#AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(hello,1.0)
#Checksforprograms.
AC_PROG_CC
#Checksforlibraries.
#Checksforheaderfiles.
#Checksfortypedefs,structures,andcompilercharacteristics.
#Checksforlibraryfunctions.
AC_OUTPUT(Makefile)
二、acloacl
[litao@vm0000131hello]$aclocal
生成aclocal.m4和autom4te.cache(生成aclocal.m4的过程中涉及到configure.in)
[litao@vm0000131hello]$ll
total44
-rw-rw-r--1litaolitao31120Aug1212:08aclocal.m4
drwxr-xr-x2litaolitao4096Aug1212:08autom4te.cache
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rw-rw-r--1litaolitao496Aug1212:08configure.in
-rw-rw-r--1litaolitao68Aug1212:02hello.c
三、antoconf
[litao@vm0000131hello]$autoconf
生成configure(根据configure.in,和aclocal.m4)
[litao@vm0000131hello]$ll
total168
-rw-rw-r--1litaolitao31120Aug1212:08aclocal.m4
drwxr-xr-x2litaolitao4096Aug1212:11autom4te.cache
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rwxrwxr-x1litaolitao122297Aug1212:11configure
-rw-rw-r--1litaolitao496Aug1212:08configure.in
-rw-rw-r--1litaolitao68Aug1212:02hello.c
四、编写Makefile.am:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
五、automake
生成Makefile.in,depcomp,install-sh,和missing(根据Makefile.am,和aclocal.m4)
[litao@vm0000131hello]$automake
configure.in:requiredfile`./install-sh'notfound
configure.in:requiredfile`./missing'notfound
Makefile.am:requiredfile`./depcomp'notfound
[litao@vm0000131hello]$automake--add-missing
configure.in:installing`./install-sh'
configure.in:installing`./missing'
Makefile.am:installing`./depcomp'
[litao@vm0000131hello]$ll
total192
-rw-rw-r--1litaolitao31120Aug1212:08aclocal.m4
drwxr-xr-x2litaolitao4096Aug1212:14autom4te.cache
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rwxrwxr-x1litaolitao122297Aug1212:11configure
-rw-rw-r--1litaolitao496Aug1212:08configure.in
lrwxrwxrwx1litaolitao31Aug1212:16depcomp->/usr/share/automake-1.9/depcomp
-rw-rw-r--1litaolitao68Aug1212:02hello.c
lrwxrwxrwx1litaolitao34Aug1212:16install-sh->/usr/share/automake-1.9/install-sh
-rw-rw-r--1litaolitao69Aug1212:15Makefile.am
-rw-rw-r--1litaolitao16561Aug1212:16Makefile.in
lrwxrwxrwx1litaolitao31Aug1212:16missing->/usr/share/automake-1.9/missing
六、configure
生成Makefile,config.log,和config.status
Summarize:
如果拿到的工程文件中,没有Makefile文件,而只有configure.in和Makefile.am文件,我们是不能够直接进行编译的,必须根据configure.in和Makefile.am文件生成编译所需的Makefile文件。具体操作步骤如下:
1、执行aclocal,产生aclocal.m4文件
aclocal是一个perl脚本程序,它的定义是:“aclocal-createaclocal.m4byscanningconfigure.ac”。aclocal根据configure.in文件的内容,自动生成aclocal.m4文件。而aclocal.m4文件中,包含了生成configure文件所必须的宏。
2、执行autoconf,生成configure文件
autoconf会根据configure.in和aclocal.m4文件,生成configure文件。其实,autoconf就是把configure.in和aclocal.m4文件中定义的内容,变成检查系统特性、环境变量、软件必须的参数的shell脚本。
3、执行automake命令,产生Makefile.in
具体命令为:automake--add-missing
automake会根据Makefile.am文件产生一些文件,包含最重要的Makefile.in。前面所生成的configure,会根据Makefile.in文件,来生成最终的Makefile文件。
4、执行configure命令,生成Makefile文件
这样,就产生了编译所需要的Makefile文件。运行make,即可编译。
yoursourcefiles-->[autoscan*]-->[configure.scan]-->configure.ac
2.aclocal(automake):根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件aclocal.m4中。aclocal是一个perl脚本程序,它的定义是:“aclocal-createaclocal.m4byscanningconfigure.ac”
userinputfilesoptionalinputprocessoutputfiles ================================================= acinclude.m4-----. V .-------, configure.ac------------------------>|aclocal| {usermacrofiles}->||------>aclocal.m4 `-------' 3.autoheader(autoconf):根据configure.ac中的某些宏,比如cpp宏定义,运行m4,声称config.h.in userinputfilesoptionalinputprocessoutputfiles ================================================= aclocal.m4-------. | V .----------, configure.ac----------------------->|autoheader|---->autoconfig.h.in `----------'
4.automake:automake将Makefile.am中定义的结构建立Makefile.in,然后configure脚本将生成的Makefile.in文件转换为Makefile。如果在configure.ac中定义了一些特殊的宏,比如AC_PROG_LIBTOOL,它会调用libtoolize,否则它会自己产生config.guess和config.sub
userinputfilesoptionalinputprocessesoutputfiles =================================================== .--------, ||--->COPYING ||--->INSTALL ||------>install-sh ||------>missing |automake|------>mkinstalldirs configure.ac----------------------->|| Makefile.am----------------------->||------>Makefile.in ||------>stamp-h.in .---+|--->config.guess |||--->config.sub |`------+-' ||---->config.guess |libtoolize|---->config.sub ||-------->ltmain.sh ||-------->ltconfig `----------'
5.autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。
userinputfilesoptionalinputprocessesoutputfiles =================================================== aclocal.m4,autoconfig.h.in-------. V .--------, configure.ac----------------------->|autoconf|------>configure
6../configure的过程
.------------->[config.cache]
configure*--------------------------+------------->config.log
|
[config.h.in]-.v.-->[autoconfig.h]
+------->config.status*-+
Makefile.in---'`-->Makefile
7.make过程
[autoconfig.h]-.
+-->make*--->程序
Makefile---'
.---------,
config.site--->||
config.cache--->|<strong><span>configure</span>
</strong>
|--->config.cache
|+-,
`-+-------'|
||---->config.status
config.h.in------->|config-|---->config.h
Makefile.in------->|.status|---->Makefile
||---->stamp-h
|+--,
.-+||
|`------+--'|
ltmain.sh------->|ltconfig|------->libtool
|||
`-+------'|
|config.guess|
|config.sub|
`------------'
.--------,
Makefile------>||
config.h------>|make
|
{projectsources}---------------->||-------->{projecttargets}
.-++--,
|`--------'|
|libtool|
|missing|
|install-sh|
|mkinstalldirs|
`-------------'
实例:
在/hello/目录下创建一个hello.c文件,并编译运行它:
#cd/hello/
(1)编写源文件hello.c:
#include<stdio.h>
intmain(intargc,char**argv)
{
printf("Hello,GNU!n");
return0;
}
[litao@vm0000131hello]$ll
total4
-rw-rw-r--1litaolitao68Aug1212:02hello.c
一、autoscan
[litao@vm0000131hello]$autoscan
autom4te:configure.ac:nosuchfileordirectory
autoscan:/usr/bin/autom4tefailedwithexitstatus:1
[litao@vm0000131hello]$ll
total8
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rw-rw-r--1litaolitao457Aug1212:03configure.scan
-rw-rw-r--1litaolitao68Aug1212:02hello.c
已经生成了configure.scan,autoscan.log文件
将configure.scan修改为configure.in,最后修改的内容如下:
[litao@vm0000131hello]$mvconfigure.scanconfigure.in
[litao@vm0000131hello]$vimconfigure.in
#-*-Autoconf-*-
#Processthisfilewithautoconftoproduceaconfigurescript.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME,VERSION,BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([hello.c])
#AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(hello,1.0)
#Checksforprograms.
AC_PROG_CC
#Checksforlibraries.
#Checksforheaderfiles.
#Checksfortypedefs,structures,andcompilercharacteristics.
#Checksforlibraryfunctions.
AC_OUTPUT(Makefile)
二、acloacl
[litao@vm0000131hello]$aclocal
生成aclocal.m4和autom4te.cache(生成aclocal.m4的过程中涉及到configure.in)
[litao@vm0000131hello]$ll
total44
-rw-rw-r--1litaolitao31120Aug1212:08aclocal.m4
drwxr-xr-x2litaolitao4096Aug1212:08autom4te.cache
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rw-rw-r--1litaolitao496Aug1212:08configure.in
-rw-rw-r--1litaolitao68Aug1212:02hello.c
三、antoconf
[litao@vm0000131hello]$autoconf
生成configure(根据configure.in,和aclocal.m4)
[litao@vm0000131hello]$ll
total168
-rw-rw-r--1litaolitao31120Aug1212:08aclocal.m4
drwxr-xr-x2litaolitao4096Aug1212:11autom4te.cache
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rwxrwxr-x1litaolitao122297Aug1212:11configure
-rw-rw-r--1litaolitao496Aug1212:08configure.in
-rw-rw-r--1litaolitao68Aug1212:02hello.c
四、编写Makefile.am:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
五、automake
生成Makefile.in,depcomp,install-sh,和missing(根据Makefile.am,和aclocal.m4)
[litao@vm0000131hello]$automake
configure.in:requiredfile`./install-sh'notfound
configure.in:requiredfile`./missing'notfound
Makefile.am:requiredfile`./depcomp'notfound
[litao@vm0000131hello]$automake--add-missing
configure.in:installing`./install-sh'
configure.in:installing`./missing'
Makefile.am:installing`./depcomp'
[litao@vm0000131hello]$ll
total192
-rw-rw-r--1litaolitao31120Aug1212:08aclocal.m4
drwxr-xr-x2litaolitao4096Aug1212:14autom4te.cache
-rw-rw-r--1litaolitao0Aug1212:03autoscan.log
-rwxrwxr-x1litaolitao122297Aug1212:11configure
-rw-rw-r--1litaolitao496Aug1212:08configure.in
lrwxrwxrwx1litaolitao31Aug1212:16depcomp->/usr/share/automake-1.9/depcomp
-rw-rw-r--1litaolitao68Aug1212:02hello.c
lrwxrwxrwx1litaolitao34Aug1212:16install-sh->/usr/share/automake-1.9/install-sh
-rw-rw-r--1litaolitao69Aug1212:15Makefile.am
-rw-rw-r--1litaolitao16561Aug1212:16Makefile.in
lrwxrwxrwx1litaolitao31Aug1212:16missing->/usr/share/automake-1.9/missing
六、configure
生成Makefile,config.log,和config.status
Summarize:
如果拿到的工程文件中,没有Makefile文件,而只有configure.in和Makefile.am文件,我们是不能够直接进行编译的,必须根据configure.in和Makefile.am文件生成编译所需的Makefile文件。具体操作步骤如下:
1、执行aclocal,产生aclocal.m4文件
aclocal是一个perl脚本程序,它的定义是:“aclocal-createaclocal.m4byscanningconfigure.ac”。aclocal根据configure.in文件的内容,自动生成aclocal.m4文件。而aclocal.m4文件中,包含了生成configure文件所必须的宏。
2、执行autoconf,生成configure文件
autoconf会根据configure.in和aclocal.m4文件,生成configure文件。其实,autoconf就是把configure.in和aclocal.m4文件中定义的内容,变成检查系统特性、环境变量、软件必须的参数的shell脚本。
3、执行automake命令,产生Makefile.in
具体命令为:automake--add-missing
automake会根据Makefile.am文件产生一些文件,包含最重要的Makefile.in。前面所生成的configure,会根据Makefile.in文件,来生成最终的Makefile文件。
4、执行configure命令,生成Makefile文件
这样,就产生了编译所需要的Makefile文件。运行make,即可编译。
相关文章推荐
- Android中什么是anr ? 原因 or 解决方法
- Android Studio单元测试入门
- 线程池 异步I/O线程 <第三篇>
- 盒子中的margin问题
- 在Powerdesigner中创建概念数据模型
- 面试之路(25)-斐波那契数列类问题的详解
- 面试之路(25)-斐波那契数列类问题的详解
- 面试之路(25)-斐波那契数列类问题的详解
- Memcached 一致性hash实现
- 线程池之ThreadPool类与辅助线程 - <第二篇>
- 线程初步了解 - <第一篇>
- 开启PowerDesigner15工具栏上的被禁用掉的图标
- 第27条 泛型——优先考虑泛型方法
- c3p0的使用
- 第十、十一周学习进度表
- Android-Universal-Image-Loader三大组件DisplayImageOptions、ImageLoader、ImageLoaderConfiguration详解
- 自己修改的MBProgressHUD 代码
- yaffs2文件系统的制作
- 对Set的遍历
- 二十一 实例属性和类属性