Configure,Makefile.am, Makefile.in, Makefile文件之間關係

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

 

       1.autoscan (autoconf): 掃描源代碼以搜尋普通的可移植性問題,好比檢查編譯器,庫,頭文件等,生成文件configure.scan,它是configure.ac的一個雛形。vim

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

       2.aclocal (automake):根據已經安裝的宏,用戶定義宏和acinclude.m4文件中的宏將configure.ac文件所須要的宏集中定義到文件 aclocal.m4中。this

       aclocal是一個perl 腳本程序,它的定義是:「aclocal - create aclocal.m4 by scanning configure.ac」spa

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

 

       3.autoheader(autoconf): 根據configure.ac中的某些宏,好比cpp宏定義,運行m4,聲稱config.h.in.net

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

 

       4.automake: automake將Makefile.am中定義的結構創建Makefile.in,而後configure腳本將生成的Makefile.in文件轉換 爲Makefile。若是在configure.ac中定義了一些特殊的宏,好比AC_PROG_LIBTOOL,它會調用libtoolize,不然它 會本身產生config.guess和config.subcode

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

      5.autoconf:將configure.ac中的宏展開,生成configure腳本。這個過程可能要用到aclocal.m4中定義的宏。blog

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

 

 6. ./configure的過程

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

 
 7. make過程

【編譯器】Configure,Makefile.am, Makefile.in, Makefile文件之間關係 - 八月照相館 - 八月照相館

 

實例:在/hello/目錄下建立一個hello.c文件,並編譯運行它: 
#cd /hello/ip

(1) 編寫源文件hello.c:ci

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

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

 

1、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)

 

2、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

 

3、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

 

4、編寫Makefile.am: 
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c

 

5、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

 

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

 
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/dolphin98629/archive/2009/11/16/4815835.aspx

相關文章
相關標籤/搜索