Configure,Makefile.am, Makefile.in, Makefile文件之间关系

来源:互联网 发布:linux系统操作命令 编辑:程序博客网 时间:2024/06/05 00:16

1.autoscan (autoconf): 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。

    your source files --> [autoscan*] --> [configure.scan] --> configure.ac

2.aclocal (automake):根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件 aclocal.m4中。aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”
user input files   optional input     process          output files================   ==============     =======          ============                    acinclude.m4 - - - - -.                                          V                                      .-------,configure.ac ------------------------>|aclocal|                 {user macro files} ->|       |------> aclocal.m4                                      `-------'3.autoheader(autoconf): 根据configure.ac中的某些宏,比如cpp宏定义,运行m4,声称config.h.inuser input files    optional input     process          output files================    ==============     =======          ============                    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

user input files   optional input   processes          output files================   ==============   =========          ============                                     .--------,                                     |        | - - -> COPYING                                     |        | - - -> INSTALL                                     |        |------> install-sh                                     |        |------> missing                                     |automake|------> mkinstalldirsconfigure.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中定义的宏。

user input files   optional input   processes          output files================   ==============   =========          ============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 - - ->|configure| - - -> 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  |{project sources} ---------------->|        |--------> {project targets}                                 .-+        +--,                                 | `--------'  |                                 |   libtool   |                                 |   missing   |                                 |  install-sh |                                 |mkinstalldirs|                                 `-------------'
实例
在/hello/目录下创建一个hello.c文件,并编译运行它:

#cd /hello/

(1) 编写源文件hello.c:

#include<stdio.h> 
int main(int argc, char** argv)
{
printf("Hello, GNU!n");
return 0;
}

[litao@vm0000131 hello]$ ll
total 4
-rw-rw-r-- 1 litao litao 68 Aug 12 12:02 hello.c

一、autoscan

[litao@vm0000131 hello]$ autoscan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[litao@vm0000131 hello]$ ll
total 8
-rw-rw-r-- 1 litao litao   0 Aug 12 12:03 autoscan.log
-rw-rw-r-- 1 litao litao 457 Aug 12 12:03 configure.scan
-rw-rw-r-- 1 litao litao  68 Aug 12 12:02 hello.c

已经生成了configure.scan,autoscan.log文件

将configure.scan 修改为 configure.in,最后修改的内容如下:

[litao@vm0000131 hello]$ mv configure.scan configure.in    
[litao@vm0000131 hello]$ vim configure.in 

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

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)
# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_OUTPUT(Makefile)

二、acloacl

[litao@vm0000131 hello]$ aclocal 

生成 aclocal.m4 和 autom4te.cache (生成aclocal.m4的过程中涉及到configure.in)

[litao@vm0000131 hello]$ ll
total 44
-rw-rw-r-- 1 litao litao 31120 Aug 12 12:08 aclocal.m4
drwxr-xr-x 2 litao litao  4096 Aug 12 12:08 autom4te.cache
-rw-rw-r-- 1 litao litao     0 Aug 12 12:03 autoscan.log
-rw-rw-r-- 1 litao litao   496 Aug 12 12:08 configure.in
-rw-rw-r-- 1 litao litao    68 Aug 12 12:02 hello.c

三、antoconf

[litao@vm0000131 hello]$ autoconf
生成 configure (根据 configure.in, 和 aclocal.m4)

[litao@vm0000131 hello]$ ll
total 168
-rw-rw-r-- 1 litao litao  31120 Aug 12 12:08 aclocal.m4
drwxr-xr-x 2 litao litao   4096 Aug 12 12:11 autom4te.cache
-rw-rw-r-- 1 litao litao      0 Aug 12 12:03 autoscan.log
-rwxrwxr-x 1 litao litao 122297 Aug 12 12:11 configure
-rw-rw-r-- 1 litao litao    496 Aug 12 12:08 configure.in
-rw-rw-r-- 1 litao litao     68 Aug 12 12:02 hello.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@vm0000131 hello]$ automake
configure.in: required file `./install-sh' not found
configure.in: required file `./missing' not found
Makefile.am: required file `./depcomp' not found
[litao@vm0000131 hello]$ automake --add-missing
configure.in: installing `./install-sh'
configure.in: installing `./missing'
Makefile.am: installing `./depcomp'
[litao@vm0000131 hello]$ ll
total 192
-rw-rw-r-- 1 litao litao  31120 Aug 12 12:08 aclocal.m4
drwxr-xr-x 2 litao litao   4096 Aug 12 12:14 autom4te.cache
-rw-rw-r-- 1 litao litao      0 Aug 12 12:03 autoscan.log
-rwxrwxr-x 1 litao litao 122297 Aug 12 12:11 configure
-rw-rw-r-- 1 litao litao    496 Aug 12 12:08 configure.in
lrwxrwxrwx 1 litao litao     31 Aug 12 12:16 depcomp -> /usr/share/automake-1.9/depcomp
-rw-rw-r-- 1 litao litao     68 Aug 12 12:02 hello.c
lrwxrwxrwx 1 litao litao     34 Aug 12 12:16 install-sh -> /usr/share/automake-1.9/install-sh
-rw-rw-r-- 1 litao litao     69 Aug 12 12:15 Makefile.am
-rw-rw-r-- 1 litao litao  16561 Aug 12 12:16 Makefile.in
lrwxrwxrwx 1 litao litao     31 Aug 12 12:16 missing -> /usr/share/automake-1.9/missing

六、configure
生成 Makefile, config.log, 和 config.status


from:http://blog.csdn.net/dolphin98629/article/details/4815835



0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 在泰国钱包丢了怎么办 中山车牌网上选号后怎么办 买楼房70年以后怎么办 暂住证过期2个月怎么办 换领驾驶证超期了怎么办 车牌租出去要不回来怎么办 汽车放久了没电怎么办 上海网约车资格证怎么办 手机掉在滴滴上怎么办 在滴滴上丢手机怎么办 把东西落在出租车上怎么办 租好房子后悔了怎么办 转租房东不退押金怎么办 亲戚借户口本办公租房怎么办 7.1深圳禁行货车怎么办 怎么办无锡市的货车临时通行证 武汉医保卡密码忘了怎么办 打出租车被黑了怎么办 行李掉在出租车上怎么办 家庭农场买农机怎么办补贴 在异地买的保险怎么办 理发店被投诉工商局找我怎么办? 临安市民卡丢了怎么办 合肥分期付款买手机被骗怎么办 公司注销后还遇到投诉怎么办 超市购物结账时少收钱怎么办 卖给顾客东西时会有斜念怎么办 实体店家纺想换货怎么办 劳动仲裁裁决部分不服怎么办 劳动仲裁公司拒不履行怎么办? 苹果手机被黑客锁了怎么办 出租大面积厂房的中介费用怎么办 中山房子网签不了怎么办 物业服务太差该怎么办 取完公积金的卡怎么办 车卖了对方不过户怎么办 卫生间下水道堵了怎么办妙招 教练不让你练车怎么办 教练不让我练车怎么办 考三要练车教练不给练怎么办 科目二指纹打卡指纹不清楚怎么办